From patchwork Mon Sep 11 17:14:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Grytsov X-Patchwork-Id: 9947755 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 1E2016024A for ; Mon, 11 Sep 2017 17:17:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0FBD428CD3 for ; Mon, 11 Sep 2017 17:17:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 04ABA28CD6; Mon, 11 Sep 2017 17:17:54 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, 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 7BB6C28CD3 for ; Mon, 11 Sep 2017 17:17:53 +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 1drSIx-0001vJ-R9; Mon, 11 Sep 2017 17:15:27 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drSIw-0001t5-N7 for xen-devel@lists.xenproject.org; Mon, 11 Sep 2017 17:15:26 +0000 Received: from [193.109.254.147] by server-5.bemta-6.messagelabs.com id 0A/5F-03454-EA4C6B95; Mon, 11 Sep 2017 17:15:26 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrKIsWRWlGSWpSXmKPExsVyMfS6k+7aI9s iDR5cM7b4vmUykwOjx+EPV1gCGKNYM/OS8isSWDPWz3jJUnBMu+LiziuMDYzPFLsYuTiEBKYz Sjy5uIkJxGEReMkisXnDDGYQR0Kgn1ViwbmDQA4nkBMnseLAHlYIO03i3Z13UPFKibVrnzKC2 EIC8hIHWy6zQ4ydxiTx9NlxJpAEm4CWxP3bK9hAbBEBJYl7qyaDxZkFUiT2rmsDaxYWcJNYNf cCWA2LgKrE74YdYMt4BRwktr84ArVYTuLmuU6wxZwCjhJLpnSxQix2kDjyvJN9AqPgAkaGVYw axalFZalFuoYmeklFmekZJbmJmTm6hgZmermpxcWJ6ak5iUnFesn5uZsYgUHHAAQ7GK9vDDjE KMnBpCTK++74lkghvqT8lMqMxOKM+KLSnNTiQ4waHBwCP5/+bWGUYsnLz0tVkuA1PLwtUkiwK DU9tSItMwcYFzClEhw8SiK8OSBp3uKCxNzizHSI1ClGS44Ldy79YeI4sOcWkOy4efcPkxDYPC lxXm6QBgGQhozSPLhxsNi9xCgrJczLCHSsEE9BalFuZgmq/CtGcQ5GJWGIq3gy80rgtr4COog J6CCeS1tADipJREhJNTBaPNoW3HB8QcKZy6fm7ec3Odi60eXFYuej1vWf6vXuKjgsytNWNZod J3hXIudw5MwFPb/W91d+Fzf5H5t8IvHKc9VpTAxzO7kzwnZ01ilw31zNy9PL/6f+f8X3AGu+q usOc+f5tUyed81Cti4gqPHN9a5I1fuXZn5lqI67Gj7d4c5BznMn/U4qsRRnJBpqMRcVJwIAuk wFmdgCAAA= X-Env-Sender: al1img@gmail.com X-Msg-Ref: server-15.tower-27.messagelabs.com!1505150125!63349866!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.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 1716 invoked from network); 11 Sep 2017 17:15:25 -0000 Received: from mail-lf0-f66.google.com (HELO mail-lf0-f66.google.com) (209.85.215.66) by server-15.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 11 Sep 2017 17:15:25 -0000 Received: by mail-lf0-f66.google.com with SMTP id y15so4244198lfd.0 for ; Mon, 11 Sep 2017 10:15:25 -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=pQ6J0b5XDNjmEHZudqVDrYc9AyB9frnR1gGjc5ZlGLM=; b=Xkn/EtBp5bdku01mTyFiohkeOpMsXPuPK4IG3cjs13b3EezWwzT2k6XZi1nY6UVHbr B9kQYwri0qRTl1fLdAINVuCI+Fjw/d4Eo6GpuAgUcY/govSpUYKMFI0Rhs3GIgBrmVQX PDGA0bikcaaAB86yz9tytzrO5V4e9tyd6DlCr5mmejPWSmJqtOsowrO26FY8hPpwVPYm tPCZHDVWzg7eBpHDjyhx3Nbmw8T7tJSW6c/I/nMJBf1eaA4zx1iyUy05dUgzyPYyPTZM dfwUDv03ORC2Vrs1zstxJ1iIvvR7ncrjQHQ77dbYtgQiatBsvs7CZAAIWLLCz2FoAcoV mhHA== 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=pQ6J0b5XDNjmEHZudqVDrYc9AyB9frnR1gGjc5ZlGLM=; b=EuFae379OIfGQXULTCKM3Mnj3snd6A1hXgUC2ygsOGd/sqVbZuBjrH+PymRV/+ASlY YtwsCn8majsBU+TdXloC0hguuDJaJLObfHDII1lBfKrT+Q7Vi4iI3CYTPcWx4+opAE/x T3yuthG6gSMglv77lAto2xbp/J9kMw9TvNWaXl2X446WCUMk5g+8Dr8eupQ1G1JE/5A7 vyPM8vcF3b+DQgEdVODroJOqycUwhb50g0OOYMFeUu/VftQ5lUysGJ6J57Wq7qG0Jepa e3awdS1XKBQn+M4LGF+XMZJYuL4sZOLhIG0K/jE8jdp3b7TIJFsx7nl033lF5ALpgXOg JmmA== X-Gm-Message-State: AHPjjUhyOyDuLWGMYjqBV47AByxENRgAl/C6TqPVM7WWBioNbpRyQhKM rNYbUMlR0BnfZSAS X-Google-Smtp-Source: AOwi7QCkiAqkinmc5YSnVr/QlZ1gziEcggv15NY1q6myrPzofWbHOjgbFq2416KIt3UnkdrPOss7tg== X-Received: by 10.46.64.216 with SMTP id r85mr3853882lje.120.1505150124763; Mon, 11 Sep 2017 10:15:24 -0700 (PDT) Received: from al1-pc.kyiv.epam.com (ll-57.209.223.85.sovam.net.ua. [85.223.209.57]) by smtp.gmail.com with ESMTPSA id g21sm1893044lje.52.2017.09.11.10.15.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Sep 2017 10:15:24 -0700 (PDT) From: Oleksandr Grytsov To: xen-devel@lists.xenproject.org Date: Mon, 11 Sep 2017 20:14:56 +0300 Message-Id: <1505150102-30806-7-git-send-email-al1img@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505150102-30806-1-git-send-email-al1img@gmail.com> References: <1505150102-30806-1-git-send-email-al1img@gmail.com> Cc: ian.jackson@eu.citrix.com, wei.liu2@citrix.com, Oleksandr Grytsov Subject: [Xen-devel] [PATCH v5 06/12] 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[];