From patchwork Tue Sep 12 13:48:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Grytsov X-Patchwork-Id: 9949277 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 22AD560360 for ; Tue, 12 Sep 2017 13:51:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14237287A9 for ; Tue, 12 Sep 2017 13:51:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0905A28FE3; Tue, 12 Sep 2017 13:51:11 +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 88854287A9 for ; Tue, 12 Sep 2017 13:51:10 +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-0005Yo-B5; 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-0005Vd-F0 for xen-devel@lists.xenproject.org; Tue, 12 Sep 2017 13:48:36 +0000 Received: from [85.158.143.35] by server-5.bemta-6.messagelabs.com id E0/A0-03454-3B5E7B95; Tue, 12 Sep 2017 13:48:35 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrMIsWRWlGSWpSXmKPExsVyMfS6o+6mp9s jDaZeZrf4vmUykwOjx+EPV1gCGKNYM/OS8isSWDOO3bzCUrDduGLrwT6mBsaDGl2MXBxCAjMY Je6/+M4O4rAIvGSR+PNnD1sXIyeHhEA/q8Spz6ldjBxAdpLE3mc6EOE0ibZNH9kh7GqJT8uOg dlCAvISB1sus0MMncIk8X/SbrA5bAJaEvdvrwCzRQSUJO6tmswEYjMLpEjsXdfGCGILC7hLfF z/lBXEZhFQlVj8eT9YDa+Ag8Sc1WtZIZbJSdw818kMYnMKOEq0/+5ihljsIHFlzR62CYyCCxg ZVjFqFKcWlaUW6Roa6iUVZaZnlOQmZuboGhqY6eWmFhcnpqfmJCYV6yXn525iBAYcAxDsYPy0 LOAQoyQHk5Ior/L97ZFCfEn5KZUZicUZ8UWlOanFhxg1ODgEfj7928IoxZKXn5eqJME76QlQn WBRanpqRVpmDjAmYEolOHiURHgrQdK8xQWJucWZ6RCpU4yWHBfuXPrDxHFgzy0g2XHz7h8mIb B5UuK8+SANAiANGaV5cONgcXuJUVZKmJcR6FghnoLUotzMElT5V4ziHIxKwrxbQKbwZOaVwG1 9BXQQE9BBPJe2gBxUkoiQkmpg3PxmfYPH3Z7jKpzF4fy77Y657ZoUX31HpYVLa7+075JwF+WF 8o4W7260e5yoX5e/cOvG9QWL3FTEbGXcmZzv8p8zK/m99PTi5GmM3zRaStMVoi8+j5o89Ti/m sYDmedRu7y6VSXfFoaJvOq5/FEq9JWqlZE0v2j1L2k9fRPDnntMknHs29uVWIozEg21mIuKEw HYTGbi1gIAAA== X-Env-Sender: al1img@gmail.com X-Msg-Ref: server-7.tower-21.messagelabs.com!1505224113!82506435!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 11406 invoked from network); 12 Sep 2017 13:48:34 -0000 Received: from mail-lf0-f65.google.com (HELO mail-lf0-f65.google.com) (209.85.215.65) by server-7.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 12 Sep 2017 13:48:34 -0000 Received: by mail-lf0-f65.google.com with SMTP id l196so5390565lfl.3 for ; Tue, 12 Sep 2017 06:48:33 -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=0phCAwADT5wWRtxvo0c/9tKlVO2h/mdROpVzmsGOv+0=; b=jrf1fYgOChVMBisi/fK1V8zRbsWiPacmr1BaIUn5nf103rNJuLTGJnj7p8y2Bc65mO vcNZXKsHyQhbbJbTgoFyZDA4+HcQQZiDS2JXfZK3uZK2+pWu3vHs30VxEnJsUXS6Nex2 5e5KeJsfegVo89Urvqtjx/ini2wl3BT/obifb1+ko5AISWCt1RMFxQqMTtxGI7C6YTpa yk1UZrd0DNclin96W/MqvWbOIm1RR70cB4Iao/9YIHDiGg+yDJCw+WL8BTf+rRgv2Ne/ jDOrNt0zcy4yOpDa5/2mZzOcd3vnYNhSTocZ2G79pL08Vhqeg88LmWykJU6eqKbZs99C onyw== 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=0phCAwADT5wWRtxvo0c/9tKlVO2h/mdROpVzmsGOv+0=; b=asBSbY5NIbrGDzBZCbSTsKVIIaPT3sn8valf8dGz4sNxIhn6QHbtHvDOyxxBOeFlMf P+C15UD0rGfmloaNFre5v3mJcrRP2K+m1ruf6rRNsUopfhJ/a2r49qM2v8VX/bzERs18 yKHAR5PieiS494spnR3ilrfvTgaHBLMDMuU+HBxDeqWx/d0hkZMhPww9B0UI0EgP+Nbr b+4AvtNm7Pred5lXuflI//KHXh3NIAGxUR4VKntAg+e0cp0Sv0rLzzWPtrGUO/WPDffK 0XxEwfdcv6XE15ytwtEkDbMd2a1icUJbwn5aZ5bZG3++esuZM697QGI8S+koPKk4GPyG gh/Q== X-Gm-Message-State: AHPjjUjCX8PrAeMv4PPXl7pxGU0d9KYg1+VBRSWqCx3mKvOoGeB8f494 sCRQ6QrfifauO+vrNvA= X-Google-Smtp-Source: AOwi7QC4hvdgJ3D/fv43kOmOn9MS3EsallMsag6YPWO0z3HQgny2pfZLX6JEdmeHcO4ARIlXnwxLXA== X-Received: by 10.25.129.196 with SMTP id c187mr3413042lfd.107.1505224113076; Tue, 12 Sep 2017 06:48:33 -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.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Sep 2017 06:48:32 -0700 (PDT) From: Oleksandr Grytsov To: xen-devel@lists.xenproject.org Date: Tue, 12 Sep 2017 16:48:12 +0300 Message-Id: <1505224098-19330-8-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 07/13] libxl: change vkb 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 | 5 +-- tools/libxl/libxl_dm.c | 6 ++-- tools/libxl/libxl_internal.h | 6 +--- 4 files changed, 19 insertions(+), 72 deletions(-) diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c index 6181b05..e4a0daf 100644 --- a/tools/libxl/libxl_console.c +++ b/tools/libxl/libxl_console.c @@ -583,11 +583,10 @@ int libxl_device_channel_getinfo(libxl_ctx *ctx, uint32_t domid, return rc; } -int libxl__device_vkb_setdefault(libxl__gc *gc, libxl_device_vkb *vkb) +static int libxl__device_vkb_setdefault(libxl__gc *gc, uint32_t domid, + libxl_device_vkb *vkb, bool hotplug) { - int rc; - rc = libxl__resolve_domid(gc, vkb->backend_domname, &vkb->backend_domid); - return rc; + return libxl__resolve_domid(gc, vkb->backend_domname, &vkb->backend_domid); } static int libxl__device_from_vkb(libxl__gc *gc, uint32_t domid, @@ -604,66 +603,8 @@ static int libxl__device_from_vkb(libxl__gc *gc, uint32_t domid, return 0; } -int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb, - const libxl_asyncop_how *ao_how) -{ - AO_CREATE(ctx, domid, ao_how); - int rc; - - rc = libxl__device_vkb_add(gc, domid, vkb); - if (rc) { - LOGD(ERROR, domid, "Unable to add vkb device"); - goto out; - } - -out: - libxl__ao_complete(egc, ao, rc); - return AO_INPROGRESS; -} - static LIBXL_DEFINE_UPDATE_DEVID(vkb, "vkb") -int libxl__device_vkb_add(libxl__gc *gc, uint32_t domid, - libxl_device_vkb *vkb) -{ - flexarray_t *front; - flexarray_t *back; - libxl__device device; - int rc; - - rc = libxl__device_vkb_setdefault(gc, vkb); - if (rc) goto out; - - front = flexarray_make(gc, 16, 1); - back = flexarray_make(gc, 16, 1); - - rc = libxl__device_vkb_update_devid(gc, domid, vkb); - if (rc) goto out; - - rc = libxl__device_from_vkb(gc, domid, vkb, &device); - if (rc != 0) goto out; - - flexarray_append(back, "frontend-id"); - flexarray_append(back, GCSPRINTF("%d", domid)); - flexarray_append(back, "online"); - flexarray_append(back, "1"); - flexarray_append(back, "state"); - flexarray_append(back, GCSPRINTF("%d", XenbusStateInitialising)); - - flexarray_append(front, "backend-id"); - flexarray_append(front, GCSPRINTF("%d", vkb->backend_domid)); - flexarray_append(front, "state"); - flexarray_append(front, 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; -} - int libxl__device_vfb_setdefault(libxl__gc *gc, libxl_device_vfb *vfb) { int rc; @@ -785,8 +726,17 @@ out: * 2. dynamically add/remove qemu chardevs via qmp messages. */ /* vkb */ + +#define libxl__add_vkbs NULL +#define libxl_device_vkb_list NULL +#define libxl_device_vkb_compare NULL + LIBXL_DEFINE_DEVICE_REMOVE(vkb) +DEFINE_DEVICE_TYPE_STRUCT(vkb, + .skip_attach = 1 +); + /* vfb */ LIBXL_DEFINE_DEVICE_REMOVE(vfb) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 26aa2a4..8c0c12d 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1349,7 +1349,7 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, } libxl_device_vkb_init(&vkb); - libxl__device_vkb_add(gc, domid, &vkb); + libxl__device_add(gc, domid, &libxl__vkb_devtype, &vkb); libxl_device_vkb_dispose(&vkb); dcs->sdss.dm.guest_domid = domid; @@ -1375,7 +1375,8 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, for (i = 0; i < d_config->num_vfbs; i++) { libxl__device_vfb_add(gc, domid, &d_config->vfbs[i]); - libxl__device_vkb_add(gc, domid, &d_config->vkbs[i]); + libxl__device_add(gc, domid, &libxl__vkb_devtype, + &d_config->vkbs[i]); } init_console_info(gc, &console, 0); diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index ee20930..0712a34 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -1986,9 +1986,9 @@ static void spawn_stub_launch_dm(libxl__egc *egc, goto out; } if (dm_config->num_vkbs) { - ret = libxl__device_vkb_add(gc, dm_domid, &dm_config->vkbs[0]); - if (ret) - goto out; + ret = libxl__device_add(gc, dm_domid, &libxl__vkb_devtype, + &dm_config->vkbs[0]); + if (ret) goto out; } if (guest_config->b_info.u.hvm.serial) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 87f6d32..c2ef67f 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1248,7 +1248,6 @@ _hidden int libxl__device_disk_setdefault(libxl__gc *gc, uint32_t domid, _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 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); @@ -2657,10 +2656,6 @@ struct libxl__multidev { * it's a valid state. */ -/* Internal function to connect a vkb device */ -_hidden int libxl__device_vkb_add(libxl__gc *gc, uint32_t domid, - libxl_device_vkb *vkb); - /* Internal function to connect a vfb device */ _hidden int libxl__device_vfb_add(libxl__gc *gc, uint32_t domid, libxl_device_vfb *vfb); @@ -3551,6 +3546,7 @@ static inline int *libxl__device_type_get_num( return (int *)((void *)d_config + dt->num_offset); } +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; extern const struct libxl_device_type libxl__vtpm_devtype;