From patchwork Tue Sep 12 13:48:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Grytsov X-Patchwork-Id: 9949275 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 1857360360 for ; Tue, 12 Sep 2017 13:51:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 095DE287A9 for ; Tue, 12 Sep 2017 13:51:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F26E228FE3; Tue, 12 Sep 2017 13:51:09 +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 720E5287A9 for ; Tue, 12 Sep 2017 13:51:09 +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-0005ZC-Hx; 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 1drlYK-0005Vk-N9 for xen-devel@lists.xenproject.org; Tue, 12 Sep 2017 13:48:36 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id 94/81-03093-3B5E7B95; Tue, 12 Sep 2017 13:48:35 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrCIsWRWlGSWpSXmKPExsVyMfS6i+7mp9s jDXa+4Lf4vmUykwOjx+EPV1gCGKNYM/OS8isSWDNevpUruGxaMWPqP7YGxqcaXYxcHEIC0xkl 9jc1MoE4LAIvWST+bmhhBnEkBPpZJfZuWs7WxcgJ5CRJTGh9CWWnSbw+fI4Vwq6UeD3/GwuIL SQgL3Gw5TI7xNgpTBLXtvcygSTYBLQk7t9eAdYsIqAkcW/VZLA4s0CKxN51bYwgtrCAu8TyD5 OZQWwWAVWJU4dPgtXwCjhI9LSfYYdYJidx81wnWA2ngKNE++8uZojFDhJX1uxhm8AouICRYRW jRnFqUVlqka6huV5SUWZ6RkluYmaOrqGBmV5uanFxYnpqTmJSsV5yfu4mRmDIMQDBDsbbGwMO MUpyMCmJ8irf3x4pxJeUn1KZkVicEV9UmpNafIhRg4ND4OfTvy2MUix5+XmpShK8YU+A6gSLU tNTK9Iyc4BRAVMqwcGjJMJrA5LmLS5IzC3OTIdInWK05Lhw59IfJo4De24ByY6bd/8wCYHNkx LnzQdpEABpyCjNgxsHi9xLjLJSwryMQMcK8RSkFuVmlqDKv2IU52BUEua1B5nCk5lXArf1FdB BTEAH8VzaAnJQSSJCSqqBMWfSreI7/T7xi22S+FJmsT3NfL5wbpDIt2eCHecUl1ju4p3VN2nT tNOJy+wV6pxVLux/PS9M9ZJJ4IEtpnt1N+2890aHheHrN/bvTDXpAdmS2/tSrz4SfHpG/N+cR 4svvP2zaSaP27qXqQxJdYvnus988HjlAm29BVPTX61nn92bH+KpvyldkU2JpTgj0VCLuag4EQ CPVGCl1wIAAA== X-Env-Sender: al1img@gmail.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1505224114!74469650!1 X-Originating-IP: [209.85.215.68] 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 63027 invoked from network); 12 Sep 2017 13:48:35 -0000 Received: from mail-lf0-f68.google.com (HELO mail-lf0-f68.google.com) (209.85.215.68) by server-5.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 12 Sep 2017 13:48:35 -0000 Received: by mail-lf0-f68.google.com with SMTP id h80so5384068lfe.1 for ; Tue, 12 Sep 2017 06:48:35 -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=Ai3cms7TWjmc7NY9QWni0YHSzofHSc9Hb4phWDoUFD8=; b=ItkY8HgT8IBgkF7P6jRwgmSCklFRFGhJ63Sr4WZAtCIlPABjORNvxIxzAEwDA9ztfr 3J3i75fB82ot349pUOl4R0mfHNo0pKsNxOM2Xvb7ZhnAMFIfVIgx3CRwg3zQ1ICpWzBx XmQHFz+ra8kXO/X+PxeAYPUQIBcKCgS+PIM6ZrX40AyFMZAS4Ry1zzJBShFEHBSfR8/7 QEVOWF2MSvLuGi44OllGY2OpLbY1Bn0x+Lbi6eVZQofpvakVQcbJRomVZybYLCyVcMZx AjNB6uPE8YpDSym2AHFt0Kf5iziluERhdDXRjsSSVdPGdOxEdWhrPfP8UM1viBxCQ1lT QQug== 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=Ai3cms7TWjmc7NY9QWni0YHSzofHSc9Hb4phWDoUFD8=; b=DEiUySuV9xe6hO0uHWJwk7uWUpUtFtlKV7WwmN9eScnT6zBmfJrMQKgosWQlebHB+C SSLBkupDJDQ+uUnbSjDao1/CwhClsst2A5NowcjFjSHsygUho4cBgHLWi6rEss1tjFow 6KLCCG3p2s13E8alaeu9HMVEcaVobUsm3IPITqHdFVXEYs/HExjCSOL2zT48kjgCamrc teBmvb6hyJoTXV4rvx+gBdSzQJ725uiG6ioXF9foRQFWRO+kfcVoJpTYt6hFd1HiVjiZ bipWiInWfPSMaeI6XtGVyMPMRTZ0ZQ84qYzvskFBdeocfiJ/TD/fPT6AVF1QQM39N3S5 w1FA== X-Gm-Message-State: AHPjjUiU5M2+qEaD596M7oQ9LrzeGuNWGTHFv8l3PPTq8xbevSqoXhy5 rVss07IE8ym7tmlfDGg= X-Google-Smtp-Source: AOwi7QAnPpOJK+xgKDGK082oUPH+nY6mofgZfnB6Heo0dEh7PPXztvtz/VH4nmmJsQ/mPo/NWvtvUQ== X-Received: by 10.25.149.83 with SMTP id x80mr4538787lfd.175.1505224114192; Tue, 12 Sep 2017 06:48:34 -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.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Sep 2017 06:48:33 -0700 (PDT) From: Oleksandr Grytsov To: xen-devel@lists.xenproject.org Date: Tue, 12 Sep 2017 16:48:13 +0300 Message-Id: <1505224098-19330-9-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 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 | 69 ++++++++++++-------------------------------- tools/libxl/libxl_create.c | 3 +- tools/libxl/libxl_dm.c | 6 ++-- tools/libxl/libxl_internal.h | 6 +--- 4 files changed, 25 insertions(+), 59 deletions(-) diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c index e4a0daf..6dcad8a 100644 --- a/tools/libxl/libxl_console.c +++ b/tools/libxl/libxl_console.c @@ -605,7 +605,8 @@ static int libxl__device_from_vkb(libxl__gc *gc, uint32_t domid, static LIBXL_DEFINE_UPDATE_DEVID(vkb, "vkb") -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; @@ -641,47 +642,13 @@ 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) -{ - 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; -} - static LIBXL_DEFINE_UPDATE_DEVID(vfb, "vfb") -int libxl__device_vfb_add(libxl__gc *gc, uint32_t domid, libxl_device_vfb *vfb) +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) { - 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); - - rc = libxl__device_vfb_update_devid(gc, domid, vfb); - if (rc) 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 +668,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: @@ -737,9 +694,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) +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 8c0c12d..70048fe 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1374,7 +1374,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 0712a34..275fabc 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -1981,9 +1981,9 @@ static void spawn_stub_launch_dm(libxl__egc *egc, goto out; } if (dm_config->num_vfbs) { - ret = libxl__device_vfb_add(gc, dm_domid, &dm_config->vfbs[0]); - if (ret) - goto out; + ret = libxl__device_add(gc, dm_domid, &libxl__vfb_devtype, + &dm_config->vfbs[0]); + if (ret) goto out; } if (dm_config->num_vkbs) { 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 c2ef67f..6b21812 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, bool hotplug); _hidden int libxl__device_nic_setdefault(libxl__gc *gc, uint32_t domid, libxl_device_nic *nic, bool hotplug); -_hidden int libxl__device_vfb_setdefault(libxl__gc *gc, libxl_device_vfb *vfb); _hidden void libxl__rdm_setdefault(libxl__gc *gc, libxl_domain_build_info *b_info); @@ -2656,10 +2655,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 @@ -3546,6 +3541,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;