From patchwork Tue Jul 18 14:25:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Grytsov X-Patchwork-Id: 9848535 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 E8986602C8 for ; Tue, 18 Jul 2017 14:28:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DBA7F2852B for ; Tue, 18 Jul 2017 14:28:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D087E28585; Tue, 18 Jul 2017 14:28:07 +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 4E1832852B for ; Tue, 18 Jul 2017 14:28:07 +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 1dXTRd-0002aG-Sg; Tue, 18 Jul 2017 14:25:49 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dXTRc-0002Xt-C8 for xen-devel@lists.xenproject.org; Tue, 18 Jul 2017 14:25:48 +0000 Received: from [85.158.137.68] by server-13.bemta-3.messagelabs.com id D7/99-01862-B6A1E695; Tue, 18 Jul 2017 14:25:47 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrDIsWRWlGSWpSXmKPExsVyMfS6k26WVF6 kwc7rlhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8afrjesBQfNK25uPsTYwPhWq4uRi0NIYDqj xJNjD5hAHBaBlywS+zrvgTkSAv2sEod3zGbrYuQEcpIkZj+cxw5hl0l86L3PCGILCchLHGy5z A5hT2OS+DHDC8RmE9CSuH97BViviICSxL1Vk5lAbGaBFIm969rAeoUF3CQm3+oA62URUJW4f/ 4PM4jNK+Ag8ezXHhaIXXISN891AsU5ODgFHCW2ziiHWOUgcaP1FfsERoEFjAyrGNWLU4vKUot 0zfWSijLTM0pyEzNzdA0NjPVyU4uLE9NTcxKTivWS83M3MQLDigEIdjA2fnc6xCjJwaQkyrv6 QG6kEF9SfkplRmJxRnxRaU5q8SFGDQ4OgZ9P/7YwSrHk5eelKknw8kjmRQoJFqWmp1akZeYAA x+mVIKDR0mEN18CKM1bXJCYW5yZDpE6xWjPceXKui9MHBtWrweSUw5sB5KvJvz/xiQENlVKnL cDZKoASFtGaR7cUFikXmKUlRLmZQQ6WYinILUoN7MEVf4VozgHo5IwbwHIFJ7MvBK43a+AzmI COkvYNwfkrJJEhJRUA6NWUZxF7ZkTNhcMJR9GuCyIfv1LdmfNhdL2h5rFH/tzOVo/CZ6e1dho y/VB4vCiiING29Q2fFLp6pH7rhwv+TxlqkjA6/ZfK5bXT7Fb9nX6g9mVpzSvPFwuvcioekn9J DMLY4HGnj1uxrKOF3otlmzb/Xb2q0MrpP+mTOx+6Zshpfv6zgwvmxwlluKMREMt5qLiRACga1 kAzwIAAA== X-Env-Sender: al1img@gmail.com X-Msg-Ref: server-10.tower-31.messagelabs.com!1500387946!105308640!1 X-Originating-IP: [209.85.215.66] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 34498 invoked from network); 18 Jul 2017 14:25:46 -0000 Received: from mail-lf0-f66.google.com (HELO mail-lf0-f66.google.com) (209.85.215.66) by server-10.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 18 Jul 2017 14:25:46 -0000 Received: by mail-lf0-f66.google.com with SMTP id t72so2015040lff.0 for ; Tue, 18 Jul 2017 07:25:46 -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=pYZGu0S3wzgJkV6uBjdwTSq9R4nqZ7PDS8AUFv9i6vo=; b=uhSYBiYG+oidSayQfV2Dt6Wgr4q2uFojoQdcM1UebefGD4UIHAKBeTPvyQH1UwU0mX toe0Q44x8ZTIexLz6aoTN82/e9weZynPLbp8ize32jFN8VzQBERmP3QECl2Fp0tftazt leQmJ4ljiyo+Gg4OowOiGqyBYGvGBKFg0/EJwGks08NwLfN0i11XkTW/zH0zqfMvKAOJ n7ECb784rcr9ToLQAoPGYm6VqGKafotlq2yxhxIqy6YVoCZPq7HLsDF35a/JHyGnTR78 3bSLeh76a5LNEImTc3dJK6F8d6rKoa7TqQliwuIQe8e4JMmMU555OUltITna2F0/YjqW b91w== 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=pYZGu0S3wzgJkV6uBjdwTSq9R4nqZ7PDS8AUFv9i6vo=; b=phwhaxnyUSqZoicCKQaGSyDTxr/1lVDexI9ZExXID1FBn+caFofVnJyslk9EQg1i04 Twf8q9CarajiQwI+tExqsU4d+VugAn8GbuMmPF2+OeQE2tnLawBQpVxsuykIpnJPaBXK w5/HS/8Js+se8TxohignsmKbELVLfooKlBIgO93RfdN5OSWqjAMUCSsTpPWCuT1sBqEU 9guLCJ5fPFjbrge7oOUGuEaoQqE9wzbCyIPEDSfJfV4O49QnbTS16D+xEz0d9k/fMxmm SUhsT7loNBeDls44Jvk5/a9JVLGuofQNuFsYLYDBmxMUZvgx3hYm7l6gYEmrCaxA54d1 o8tQ== X-Gm-Message-State: AIVw110pTUVyf6CNu1rFa3xcIgOhHQVFHtOzuRdh+3RafjlnJgUIuNZO xb0fFLqbnACq1SXZtew= X-Received: by 10.25.211.7 with SMTP id k7mr818074lfg.137.1500387946041; Tue, 18 Jul 2017 07:25:46 -0700 (PDT) Received: from al1-pc.kyiv.epam.com (ll-58.209.223.85.sovam.net.ua. [85.223.209.58]) by smtp.gmail.com with ESMTPSA id s134sm620442lfe.27.2017.07.18.07.25.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Jul 2017 07:25:45 -0700 (PDT) From: Oleksandr Grytsov To: xen-devel@lists.xenproject.org Date: Tue, 18 Jul 2017 17:25:23 +0300 Message-Id: <1500387930-16317-7-git-send-email-al1img@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500387930-16317-1-git-send-email-al1img@gmail.com> References: <1500387930-16317-1-git-send-email-al1img@gmail.com> Cc: ian.jackson@eu.citrix.com, wei.liu2@citrix.com, Oleksandr Grytsov Subject: [Xen-devel] [PATCH v4 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 --- tools/libxl/libxl_9pfs.c | 67 +++++++++++++++----------------------------- tools/libxl/libxl_create.c | 2 +- tools/libxl/libxl_internal.h | 7 +---- tools/libxl/libxl_types.idl | 2 +- tools/xl/xl_parse.c | 4 +-- 5 files changed, 28 insertions(+), 54 deletions(-) diff --git a/tools/libxl/libxl_9pfs.c b/tools/libxl/libxl_9pfs.c index 07e3e5f..394d8b4 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, @@ -39,49 +37,30 @@ static int libxl__device_from_p9(libxl__gc *gc, uint32_t domid, return 0; } - -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); - - if (p9->devid == -1) { - if ((p9->devid = libxl__device_nextid(gc, domid, "9pfs")) < 0) { - rc = ERROR_FAIL; - 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; } -LIBXL_DEFINE_DEVICE_REMOVE(p9) +#define libxl__add_p9s NULL +#define libxl_device_p9_list NULL +#define libxl_device_p9_compare NULL +LIBXL_DEFINE_DEVICE_REMOVE(p9) +static LIBXL_DEFINE_UPDATE_DEVID(p9, "9pfs") + +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 912bd21..f483475 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1325,7 +1325,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->p9[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 68c08aa..c53bbd1 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1252,8 +1252,6 @@ _hidden int libxl__device_vkb_setdefault(libxl__gc *gc, libxl_device_vkb *vkb); _hidden int libxl__device_pci_setdefault(libxl__gc *gc, libxl_device_pci *pci); _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, @@ -2668,10 +2666,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 @@ -3565,6 +3559,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[]; diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 25563cf..96dbaed 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -804,7 +804,7 @@ libxl_domain_config = Struct("domain_config", [ ("vfbs", Array(libxl_device_vfb, "num_vfbs")), ("vkbs", Array(libxl_device_vkb, "num_vkbs")), ("vtpms", Array(libxl_device_vtpm, "num_vtpms")), - ("p9", Array(libxl_device_p9, "num_p9s")), + ("p9s", Array(libxl_device_p9, "num_p9s")), ("vdispls", Array(libxl_device_vdispl, "num_vdispls")), # a channel manifests as a console with a name, # see docs/misc/channels.txt diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 2140905..19eadd9 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -1419,9 +1419,9 @@ void parse_config_data(const char *config_source, char *p, *p2, *buf2; d_config->num_p9s = 0; - d_config->p9 = NULL; + d_config->p9s = NULL; while ((buf = xlu_cfg_get_listitem (p9devs, d_config->num_p9s)) != NULL) { - p9 = ARRAY_EXTEND_INIT(d_config->p9, + p9 = ARRAY_EXTEND_INIT(d_config->p9s, d_config->num_p9s, libxl_device_p9_init); libxl_device_p9_init(p9);