From patchwork Tue Sep 12 13:48:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Grytsov X-Patchwork-Id: 9949267 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2F0BA60360 for ; Tue, 12 Sep 2017 13:50:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2018B28FEA for ; Tue, 12 Sep 2017 13:50:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 147E128FFA; Tue, 12 Sep 2017 13:50:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 83A4528FFC for ; Tue, 12 Sep 2017 13:50:56 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drlYM-0005Zn-Ps; Tue, 12 Sep 2017 13:48:38 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drlYL-0005XC-Fz for xen-devel@lists.xenproject.org; Tue, 12 Sep 2017 13:48:37 +0000 Received: from [85.158.143.35] by server-4.bemta-6.messagelabs.com id 81/FC-03283-4B5E7B95; Tue, 12 Sep 2017 13:48:36 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrEIsWRWlGSWpSXmKPExsVyMfS6o+7Gp9s jDf5tZLL4vmUykwOjx+EPV1gCGKNYM/OS8isSWDP6PvUyF7zTrvjfXd3A2KXUxcjJISQwjVFi 3Xe+LkYuDhaBlywSG8/NYwJxJAT6WSXed61hBKmSEEiSuHhlHiuEnSbx4MFqIJsDyK6QOLu3E mKQvMTBlsvsIL1CAlOYJJ41fGIDSbAJaEncv70CzBYRUJK4t2oyE4jNLJAisXddG9h8YQE3iV u314DFWQRUJZY93QxWzyvgILFg329miL1yEjfPdYLZnAKOEu2/u5ghFjtIXFmzh20Co+ACRoZ VjBrFqUVlqUW6RpZ6SUWZ6RkluYmZObqGBmZ6uanFxYnpqTmJScV6yfm5mxiB4cYABDsYDywK PMQoycGkJMqrfH97pBBfUn5KZUZicUZ8UWlOavEhRg0ODoGfT/+2MEqx5OXnpSpJ8E56AlQnW JSanlqRlpkDjAiYUgkOHiUR3kqQNG9xQWJucWY6ROoUoyXHhTuX/jBxHNhzC0h23Lz7h0kIbJ 6UOG8+SIMASENGaR7cOFjUXmKUlRLmZQQ6VoinILUoN7MEVf4VozgHo5IwbzXIFJ7MvBK4ra+ ADmICOojn0haQg0oSEVJSDYwF60Msv/ofUxD5c+rfIuYrrvvy93XEX+Le5ih2d+2s2rwfC3+a Odg8OqYVavxt3VEDl08HNY8tStx4fG2iZ50U60mVvfMmxuRyejTt6DvfeGLt3RSZDz1Lsh24F ZS/9O9X2cNnslj4uKRi9Xz+QI4gixbrKL4Vh3IXp/767f4uUm112pKM/k9KLMUZiYZazEXFiQ AhLCLA1QIAAA== X-Env-Sender: al1img@gmail.com X-Msg-Ref: server-13.tower-21.messagelabs.com!1505224112!76595940!1 X-Originating-IP: [209.85.215.65] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 35124 invoked from network); 12 Sep 2017 13:48:32 -0000 Received: from mail-lf0-f65.google.com (HELO mail-lf0-f65.google.com) (209.85.215.65) by server-13.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 12 Sep 2017 13:48:32 -0000 Received: by mail-lf0-f65.google.com with SMTP id c8so5379687lfe.2 for ; Tue, 12 Sep 2017 06:48:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iVnYMA+AF25/fMOuUU076q8pC791qdc+7iHT3SdW3vw=; b=YVOe4m+t4MlP2opzUQYKnAufnlvN1tyZOWGPGB1jaUNV/jGqIpJ8ABN9u1uHM4Ct2d P4uPIPmzKW135mutkcFDRp3WSvKm9pp3h2UMAglmRahVC62Va88V21FU/NcZbD62eFMw sRIToy3ifggLcB4tClsc4YdZBWwIlVf4IGXOx4NLo57DQdMFjpRX5zxAF2TiQ/ZvLwCs OLyKj5d71lK1iW2yZH3jZi2q/G4oU76vkV/DwOUPdmrJ89AvxCjuV96Z8Bgg3hRgY2IY vKhsxZHf6kMRAkHsn0Q8bLMQ27U0dz0m/RaVN6vhqQRz5M1jPAYO/EmHTPysBhV/CRd8 PlyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iVnYMA+AF25/fMOuUU076q8pC791qdc+7iHT3SdW3vw=; b=UYSpPs7I6GzsvCyJEo0BAvcK0Vc6XOh+DuAo74FAvBl8o5HeJkJXKtBM71KGjTF0QT MrLrAVSr0CeZEkZuXkeh7QacmLiTB2qhn/XxDngmg5YyDPHVJYBxEdzBHedVkSV83tQO eQXcr3m6kZ28k5EtoSdMzsxvtfwRVlgxEOea5bLf1PPJBjhBGoaXJxda5i7A727pOtl4 Gv/4cnIFdfvPbEHv922FPJPLyHOMpANNhhrZmJtqEjeCEV4kzQlW4uTxj6bqfjbvTrfK 50WG2updP7nhz8ePwtnd/+LQGiSfBPzzfEpe9utr8V+5QlU9w8FmeOBg6hl0gKH21oI0 i6Ew== X-Gm-Message-State: AHPjjUi0UbByF9cfIz/xQMomrOHRmxXom21lu3TD70icUnoSQIjSX6lL DxXHLBiAj61Gk6cUzKk= X-Google-Smtp-Source: AOwi7QA5GfMPzYKR/JfWo09K6aq5KoMglzstBp0L2YjvhUs43bx/gQdTw+Xor/SviRsFEc9Fju+E/g== X-Received: by 10.25.43.80 with SMTP id r77mr5639624lfr.130.1505224112018; Tue, 12 Sep 2017 06:48:32 -0700 (PDT) Received: from al1-pc.kyiv.epam.com (ll-56.209.223.85.sovam.net.ua. [85.223.209.56]) by smtp.gmail.com with ESMTPSA id s5sm690074lfb.14.2017.09.12.06.48.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Sep 2017 06:48:31 -0700 (PDT) From: Oleksandr Grytsov To: xen-devel@lists.xenproject.org Date: Tue, 12 Sep 2017 16:48:11 +0300 Message-Id: <1505224098-19330-7-git-send-email-al1img@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505224098-19330-1-git-send-email-al1img@gmail.com> References: <1505224098-19330-1-git-send-email-al1img@gmail.com> Cc: ian.jackson@eu.citrix.com, wei.liu2@citrix.com, Oleksandr Grytsov Subject: [Xen-devel] [PATCH v6 06/13] libxl: change p9 to use generec add function X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Oleksandr Grytsov Signed-off-by: Oleksandr Grytsov Acked-by: Wei Liu --- tools/libxl/libxl_9pfs.c | 59 ++++++++++++++++---------------------------- tools/libxl/libxl_create.c | 2 +- tools/libxl/libxl_internal.h | 7 +----- 3 files changed, 23 insertions(+), 45 deletions(-) diff --git a/tools/libxl/libxl_9pfs.c b/tools/libxl/libxl_9pfs.c index 5443f7a..61d284c 100644 --- a/tools/libxl/libxl_9pfs.c +++ b/tools/libxl/libxl_9pfs.c @@ -17,12 +17,10 @@ #include "libxl_internal.h" -int libxl__device_p9_setdefault(libxl__gc *gc, libxl_device_p9 *p9) +static int libxl__device_p9_setdefault(libxl__gc *gc, uint32_t domid, + libxl_device_p9 *p9, bool hotplug) { - int rc; - - rc = libxl__resolve_domid(gc, p9->backend_domname, &p9->backend_domid); - return rc; + return libxl__resolve_domid(gc, p9->backend_domname, &p9->backend_domid); } static int libxl__device_from_p9(libxl__gc *gc, uint32_t domid, @@ -41,44 +39,29 @@ static int libxl__device_from_p9(libxl__gc *gc, uint32_t domid, static LIBXL_DEFINE_UPDATE_DEVID(p9, "9pfs") -int libxl__device_p9_add(libxl__gc *gc, uint32_t domid, - libxl_device_p9 *p9) +static int libxl__set_xenstore_p9(libxl__gc *gc, uint32_t domid, + libxl_device_p9 *p9, + flexarray_t *back, flexarray_t *front, + flexarray_t *ro_front) { - flexarray_t *front; - flexarray_t *back; - libxl__device device; - int rc; - - rc = libxl__device_p9_setdefault(gc, p9); - if (rc) goto out; - - front = flexarray_make(gc, 16, 1); - back = flexarray_make(gc, 16, 1); - - rc = libxl__device_p9_update_devid(gc, domid, p9); - if (rc) goto out; - - rc = libxl__device_from_p9(gc, domid, p9, &device); - if (rc != 0) goto out; - - flexarray_append_pair(back, "frontend-id", libxl__sprintf(gc, "%d", domid)); - flexarray_append_pair(back, "online", "1"); - flexarray_append_pair(back, "state", GCSPRINTF("%d", XenbusStateInitialising)); - flexarray_append_pair(front, "backend-id", - libxl__sprintf(gc, "%d", p9->backend_domid)); - flexarray_append_pair(front, "state", GCSPRINTF("%d", XenbusStateInitialising)); - flexarray_append_pair(front, "tag", p9->tag); flexarray_append_pair(back, "path", p9->path); flexarray_append_pair(back, "security_model", p9->security_model); - libxl__device_generic_add(gc, XBT_NULL, &device, - libxl__xs_kvs_of_flexarray(gc, back), - libxl__xs_kvs_of_flexarray(gc, front), - NULL); - rc = 0; -out: - return rc; + flexarray_append_pair(front, "tag", p9->tag); + + return 0; } +#define libxl__add_p9s NULL +#define libxl_device_p9_list NULL +#define libxl_device_p9_compare NULL + LIBXL_DEFINE_DEVICE_REMOVE(p9) +DEFINE_DEVICE_TYPE_STRUCT(p9, + .skip_attach = 1, + .set_xenstore_config = (int (*)(libxl__gc *, uint32_t, void *, + flexarray_t *back, flexarray_t *front, + flexarray_t *ro_front)) + libxl__set_xenstore_p9 +); diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index f20bbf9..26aa2a4 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1328,7 +1328,7 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, } for (i = 0; i < d_config->num_p9s; i++) - libxl__device_p9_add(gc, domid, &d_config->p9s[i]); + libxl__device_add(gc, domid, &libxl__p9_devtype, &d_config->p9s[i]); switch (d_config->c_info.type) { case LIBXL_DOMAIN_TYPE_HVM: diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index c6f5868..87f6d32 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1251,8 +1251,6 @@ _hidden int libxl__device_vfb_setdefault(libxl__gc *gc, libxl_device_vfb *vfb); _hidden int libxl__device_vkb_setdefault(libxl__gc *gc, libxl_device_vkb *vkb); _hidden void libxl__rdm_setdefault(libxl__gc *gc, libxl_domain_build_info *b_info); -_hidden int libxl__device_p9_setdefault(libxl__gc *gc, - libxl_device_p9 *p9); _hidden const char *libxl__device_nic_devname(libxl__gc *gc, uint32_t domid, @@ -2667,10 +2665,6 @@ _hidden int libxl__device_vkb_add(libxl__gc *gc, uint32_t domid, _hidden int libxl__device_vfb_add(libxl__gc *gc, uint32_t domid, libxl_device_vfb *vfb); -/* Internal function to connect a 9pfs device */ -_hidden int libxl__device_p9_add(libxl__gc *gc, uint32_t domid, - libxl_device_p9 *p9); - /* Waits for the passed device to reach state XenbusStateInitWait. * This is not really useful by itself, but is important when executing * hotplug scripts, since we need to be sure the device is in the correct @@ -3564,6 +3558,7 @@ extern const struct libxl_device_type libxl__usbctrl_devtype; extern const struct libxl_device_type libxl__usbdev_devtype; extern const struct libxl_device_type libxl__pcidev_devtype; extern const struct libxl_device_type libxl__vdispl_devtype; +extern const struct libxl_device_type libxl__p9_devtype; extern const struct libxl_device_type *device_type_tbl[];