From patchwork Tue Jul 18 14:25:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Grytsov X-Patchwork-Id: 9848525 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 8CFF7602C8 for ; Tue, 18 Jul 2017 14:28:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8004E28577 for ; Tue, 18 Jul 2017 14:28:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7502328585; Tue, 18 Jul 2017 14:28:02 +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 E315C28577 for ; Tue, 18 Jul 2017 14:28:01 +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 1dXTRf-0002cI-CO; Tue, 18 Jul 2017 14:25:51 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dXTRe-0002b0-OP for xen-devel@lists.xenproject.org; Tue, 18 Jul 2017 14:25:50 +0000 Received: from [85.158.137.68] by server-2.bemta-3.messagelabs.com id A6/0C-22472-E6A1E695; Tue, 18 Jul 2017 14:25:50 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRWlGSWpSXmKPExsVyMfS6s26uVF6 kwaubohbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aedz9ZC3abVtyZdZS9gfGkRhcjF4eQwHRG iVfX37OAOCwCL1kk9h18DuZICPSzSrx/uYa9i5ETyEmS+LbhCxOEXSWx7e07ZhBbSEBe4mDLZ XaIUdOYJNZ1HWcBSbAJaEncv72CDcQWEVCSuLdqMlgzs0CKxN51bYwgtrCAu8S+7fvA6lkEVC UOb9sBNpRXwEFiye2XUIvlJG6e6wSKc3BwCjhKbJ1RDrHXQeJG6yv2CYwCCxgZVjGqF6cWlaU W6ZrqJRVlpmeU5CZm5ugaGhjr5aYWFyemp+YkJhXrJefnbmIEBlY9AwPjDsbLX50OMUpyMCmJ 8q4+kBspxJeUn1KZkVicEV9UmpNafIhRg4ND4OfTvy2MUix5+XmpShK8PJJ5kUKCRanpqRVpm TnA0IcpleDgURLhzZcASvMWFyTmFmemQ6ROMVpyXLmy7gsTx5QD24Hkqwn/vzEJgc2TEudVAJ knANKQUZoHNw4Wn5cYZaWEeRkZGBiEeApSi3IzS1DlXzGKczAqCfMWgEzhycwrgdv6CuggJqC DhH1zQA4qSURISTUw7m1UOhcc61gkcPCrnsvaxmulN7+ZXDrxveuLENuhKlVex2Q51RQxEfGE G0cdGNcsvuT7S7xvkl/VHMN9JQ9Vo++yPuqSONNW/6Rsr/zWP653S1REXX4dEniSpLaT772hz Xyx/Y5vdd7tUz2VnPN8n1W80vVDb+2sZS4vd/peqZ7y5dKWHdUTlViKMxINtZiLihMBEHXW+s oCAAA= X-Env-Sender: al1img@gmail.com X-Msg-Ref: server-10.tower-31.messagelabs.com!1500387948!105308647!1 X-Originating-IP: [209.85.215.67] 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 34731 invoked from network); 18 Jul 2017 14:25:49 -0000 Received: from mail-lf0-f67.google.com (HELO mail-lf0-f67.google.com) (209.85.215.67) by server-10.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 18 Jul 2017 14:25:49 -0000 Received: by mail-lf0-f67.google.com with SMTP id p11so1998243lfd.1 for ; Tue, 18 Jul 2017 07:25:49 -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=t3UQB8POC/MYjkSlG0ZfPdgn6NtjcmNZCDvYf366ths=; b=tYzJtEfO1cLVmkemNEDSm0zILc68MGGpRqm7ws6/N35popkf/MoCoW07ED6GiEnS/T TGKBi+UWOecTSzugCn95zx0vI9sXT6P3bPFOzMoq/RxKX7JCa5kDh1nxCpFkjWYvVWM5 Kt221/1YDjKNCdzHsOldlsc8GTU1UrVSGVD6xWRXZpY8z0pvgy0dM9PtvLJzXsnc4igZ 14Z5Z8teJqIjoP8byZmNHo6kImbExlZtYsDM9AwdtBMMO+w/zferv9icg/idElK1NfZh G19PAwiG/dRHBsLPfXOaUnUI+IJl6+/4RThyRW6OOpwLkjCWzYETFcdfqkyjaR4tASKG Xwgw== 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=t3UQB8POC/MYjkSlG0ZfPdgn6NtjcmNZCDvYf366ths=; b=WdaQV68nKzy704lWlOWj9lq5hwkAH4Fjt7plWiF+XFlGnpVwMZCpBzRHdbLaGfCfwp gBEl76p0+1KNcBKQ67kdw76IvRb91+e6sGm0JXnQyJXk1nCGpfnGKw9xkmx38VcTnirU 1JBf3Nj5u0mS2VLUEatL4RXihMDrW237F58rKnyDOSDqQywwZ4DCnvlw0oagDko0wPxI J2g0lRi+rJAZnJRsWCIezCUnz4l9p3b93qGvGe2p4X3bSdKpU0H+h9Azw33jkHzs/CO7 Om5w+d1TsPllhDzpgjt9aIczgaFhdunM0krY24FV/FD95Ri/q9dCu+GfNUX77UmPD7ob Tvtg== X-Gm-Message-State: AIVw113BtNlEfYHmeyT/k1MGHg1D2Bgl3jJIXC4o2CIt7wqcjwZT9bUE P7z9K5t8hxfm9CwxDSs= X-Received: by 10.25.208.199 with SMTP id h190mr687690lfg.174.1500387948365; Tue, 18 Jul 2017 07:25:48 -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.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Jul 2017 07:25:47 -0700 (PDT) From: Oleksandr Grytsov To: xen-devel@lists.xenproject.org Date: Tue, 18 Jul 2017 17:25:25 +0300 Message-Id: <1500387930-16317-9-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 08/13] libxl: change vfb 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_console.c | 74 ++++++++++++-------------------------------- tools/libxl/libxl_create.c | 3 +- tools/libxl/libxl_dm.c | 3 +- tools/libxl/libxl_internal.h | 6 +--- 4 files changed, 25 insertions(+), 61 deletions(-) diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c index 48fccec..4aae82c 100644 --- a/tools/libxl/libxl_console.c +++ b/tools/libxl/libxl_console.c @@ -603,7 +603,8 @@ static int libxl__device_from_vkb(libxl__gc *gc, uint32_t domid, return 0; } -int libxl__device_vfb_setdefault(libxl__gc *gc, libxl_device_vfb *vfb) +static int libxl__device_vfb_setdefault(libxl__gc *gc, uint32_t domid, + libxl_device_vfb *vfb, bool hotplug) { int rc; @@ -639,49 +640,11 @@ static int libxl__device_from_vfb(libxl__gc *gc, uint32_t domid, return 0; } -int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb, - const libxl_asyncop_how *ao_how) +static int libxl__set_xenstore_vfb(libxl__gc *gc, uint32_t domid, + libxl_device_vfb *vfb, + flexarray_t *back, flexarray_t *front, + flexarray_t *ro_front) { - AO_CREATE(ctx, domid, ao_how); - int rc; - - rc = libxl__device_vfb_add(gc, domid, vfb); - if (rc) { - LOGD(ERROR, domid, "Unable to add vfb device"); - goto out; - } - -out: - libxl__ao_complete(egc, ao, rc); - return AO_INPROGRESS; -} - -int libxl__device_vfb_add(libxl__gc *gc, uint32_t domid, libxl_device_vfb *vfb) -{ - flexarray_t *front; - flexarray_t *back; - libxl__device device; - int rc; - - rc = libxl__device_vfb_setdefault(gc, vfb); - if (rc) goto out; - - front = flexarray_make(gc, 16, 1); - back = flexarray_make(gc, 16, 1); - - if (vfb->devid == -1) { - if ((vfb->devid = libxl__device_nextid(gc, domid, "vfb")) < 0) { - rc = ERROR_FAIL; - goto out; - } - } - - rc = libxl__device_from_vfb(gc, domid, vfb, &device); - if (rc != 0) goto out; - - flexarray_append_pair(back, "frontend-id", GCSPRINTF("%d", domid)); - flexarray_append_pair(back, "online", "1"); - flexarray_append_pair(back, "state", GCSPRINTF("%d", XenbusStateInitialising)); flexarray_append_pair(back, "vnc", libxl_defbool_val(vfb->vnc.enable) ? "1" : "0"); flexarray_append_pair(back, "vnclisten", vfb->vnc.listen); @@ -701,17 +664,7 @@ int libxl__device_vfb_add(libxl__gc *gc, uint32_t domid, libxl_device_vfb *vfb) flexarray_append_pair(back, "display", vfb->sdl.display); } - flexarray_append_pair(front, "backend-id", - GCSPRINTF("%d", vfb->backend_domid)); - flexarray_append_pair(front, "state", GCSPRINTF("%d", XenbusStateInitialising)); - - 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; + return 0; } /* The following functions are defined: @@ -738,8 +691,21 @@ DEFINE_DEVICE_TYPE_STRUCT(vkb, .skip_attach = 1 ); +#define libxl__add_vfbs NULL +#define libxl_device_vfb_list NULL +#define libxl_device_vfb_compare NULL + /* vfb */ LIBXL_DEFINE_DEVICE_REMOVE(vfb) +static LIBXL_DEFINE_UPDATE_DEVID(vfb, "vfb") + +DEFINE_DEVICE_TYPE_STRUCT(vfb, + .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_vfb +); libxl_xen_console_reader * libxl_xen_console_read_start(libxl_ctx *ctx, int clear) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 9634811..8089713 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1371,7 +1371,8 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, libxl__device device; for (i = 0; i < d_config->num_vfbs; i++) { - libxl__device_vfb_add(gc, domid, &d_config->vfbs[i]); + libxl__device_add(gc, domid, &libxl__vfb_devtype, + &d_config->vfbs[i]); libxl__device_add(gc, domid, &libxl__vkb_devtype, &d_config->vkbs[i]); } diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index b37f47e..0a4f811 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -1975,7 +1975,8 @@ static void spawn_stub_launch_dm(libxl__egc *egc, if (ret) goto out; } - ret = libxl__device_vfb_add(gc, dm_domid, &dm_config->vfbs[0]); + ret = libxl__device_add(gc, dm_domid, &libxl__vfb_devtype, + &dm_config->vfbs[0]); if (ret) goto out; ret = libxl__device_add(gc, dm_domid, &libxl__vkb_devtype, diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 49440d7..36b4d1e 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1247,7 +1247,6 @@ _hidden int libxl__device_disk_setdefault(libxl__gc *gc, uint32_t domid); _hidden int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic, uint32_t domid, bool hotplug); -_hidden int libxl__device_vfb_setdefault(libxl__gc *gc, libxl_device_vfb *vfb); _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); @@ -2657,10 +2656,6 @@ struct libxl__multidev { * it's a valid state. */ -/* Internal function to connect a vfb device */ -_hidden int libxl__device_vfb_add(libxl__gc *gc, uint32_t domid, - libxl_device_vfb *vfb); - /* 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 @@ -3547,6 +3542,7 @@ static inline int *libxl__device_type_get_num( return (int *)((void *)d_config + dt->num_offset); } +extern const struct libxl_device_type libxl__vfb_devtype; extern const struct libxl_device_type libxl__vkb_devtype; extern const struct libxl_device_type libxl__disk_devtype; extern const struct libxl_device_type libxl__nic_devtype;