From patchwork Thu Oct 5 09:30:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Grytsov X-Patchwork-Id: 9986675 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 D5D64605B4 for ; Thu, 5 Oct 2017 09:33:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C78C728BE1 for ; Thu, 5 Oct 2017 09:33:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC7EC28C03; Thu, 5 Oct 2017 09:33:12 +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 37BD228C0A for ; Thu, 5 Oct 2017 09:33:12 +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 1e02Ud-0005im-UQ; Thu, 05 Oct 2017 09:30:59 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e02Uc-0005ic-QY for xen-devel@lists.xenproject.org; Thu, 05 Oct 2017 09:30:58 +0000 Received: from [85.158.139.211] by server-1.bemta-5.messagelabs.com id B8/7F-02036-1DBF5D95; Thu, 05 Oct 2017 09:30:57 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrCIsWRWlGSWpSXmKPExsVyMfS6s+7F31c jDZ7fFbf4vmUykwOjx+EPV1gCGKNYM/OS8isSWDPOn/jPWrDFsqJjXTtTA2OLdhcjF4eQwExG ie9dc9hAHBaBlywSbU+eM4E4EgL9rBKrls1m7mLkBHKyJBpObmOCsNMkJvSdgYqXSmz8PoMVx BYSkJc42HKZHWLsFCaJd9NWsIEk2AS0JO7fhrBFBJQk7q2aDDaIWSBFYu+6NsYuRg4OYQF/iV VNtSBhFgFViaX7W8BKeAUcJO7N284CsUtO4ua5TrC9nAKOEl++HWaD2Osg0d9zk2kCo+ACRoZ VjBrFqUVlqUW6RgZ6SUWZ6RkluYmZObqGBqZ6uanFxYnpqTmJScV6yfm5mxiBIVfPwMC4g7Fx tt8hRkkOJiVRXq2vVyOF+JLyUyozEosz4otKc1KLDzFqcHAI/Hz6t4VRiiUvPy9VSYKX6wNQn WBRanpqRVpmDjAqYEolOHiURHh/fwRK8xYXJOYWZ6ZDpE4xWnJcuHPpDxPHgT23gGTHzbt/mI TA5kmJ8/KCzBMAacgozYMbB4vcS4yyUsK8jAwMDEI8BalFuZklqPKvGMU5GJWEeW+ATOHJzCu B2/oK6CAmoIPmNF0BOagkESEl1cCYGe4/J6ulWTjWe4bIGlnruuVzFv8Q7Fmlsk5l74H/Zcx/ J+7403Qrt2ffs5a0jmO/V5w0P9Nl+uqpG99B0dyTHWESF37nf+mvvrXp0+fuPYt8LfrPzf64U rH7QdHWxRWWCdYmQum9OiuvlOf5Nkn0un8wrD+lq+4gccdi85pty5su3dipUXdViaU4I9FQi7 moOBEA/6hmdtcCAAA= X-Env-Sender: al1img@gmail.com X-Msg-Ref: server-11.tower-206.messagelabs.com!1507195857!93548148!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.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 43524 invoked from network); 5 Oct 2017 09:30:57 -0000 Received: from mail-lf0-f67.google.com (HELO mail-lf0-f67.google.com) (209.85.215.67) by server-11.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 5 Oct 2017 09:30:57 -0000 Received: by mail-lf0-f67.google.com with SMTP id o125so11657148lfe.0 for ; Thu, 05 Oct 2017 02:30:57 -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=A+wfRxEUDywKb2QHigZpBcnFaLzimdrXvVTR/1Ljm5U=; b=EUXWPmFrN4VEZsMuGH3PaZ/UidTsdGNPhgPWKIk58e2SFNVhhHJifgKPKES5Wgatht P2umGZrai0CV/xEO4W62OHK/lQE0MMLlyQkVfVjuHWwr0RlQlidhQxEesw3jGMNUkhZj Yv/rrdVCuu/NEBeMUB8LLee6HQ+WrbE7eex5XfvYfM3lDWN6oqk6i91XTeqE6MOD+kEJ 2Q5yzTF3suJlfxcoYuMvpCG6qKSSA/Vw05E1z5eZY5GAPS9QO2TWvFqhEythjji4uLrW GE42638NPP00LHdFrX7rGKszrMEbEbjRWKGDIsBMgn64Qx7ApXoe9e3NoFK03Kw+nC8w XwKQ== 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=A+wfRxEUDywKb2QHigZpBcnFaLzimdrXvVTR/1Ljm5U=; b=WcOgrEMPgkIKslb1yyqr1Fvx14JxvpRlJCYm+Ed/JgfH4WNeDobfhndf5For8ewSS9 1p1zGXEYAo4bCkffrhvzXtD6YCU5vWsGBMbtTFd2t89uI1CpKOB1iDXQJw1jS95EdzXX UXS4gOsDXvT5ALrAyYBJXPdWT999u02pPmlgVykcmMcG2Sm0E42b/Q9WbSG/UQme1+K/ oxgXLQ5levyreDrujJ4Wk3Z4N7KKAbdgS+vwX8Tvel8jSbWOjg0gqw837c+3/R1784Bl C71uxYQIQJxRDVKWiMXgdLTu6cqRiArT6H3mOmljOTzfA7wmeOiqZXkpORiaGE+VCEzt 2jJA== X-Gm-Message-State: AMCzsaUfi1YkrBqPkP0LoDBpCmfEbAycANkSz4wr50FjLMXNgO7v8h0Z WRac+tVBEfwUCaHgBswHn9JbCA== X-Google-Smtp-Source: AOwi7QAIqjftDGcMdp+UmCT+Kw8FyCiEaTBQjkG2ojaQebJX6eeK53u+Bba8qYn+DH1FGY5ivoLn4w== X-Received: by 10.25.212.7 with SMTP id l7mr263013lfg.13.1507195856433; Thu, 05 Oct 2017 02:30:56 -0700 (PDT) Received: from al1-pc.kyiv.epam.com (ll-52.209.223.85.sovam.net.ua. [85.223.209.52]) by smtp.gmail.com with ESMTPSA id z1sm868340lja.42.2017.10.05.02.30.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Oct 2017 02:30:55 -0700 (PDT) From: Oleksandr Grytsov To: xen-devel@lists.xenproject.org Date: Thu, 5 Oct 2017 12:30:46 +0300 Message-Id: <1507195848-18346-3-git-send-email-al1img@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507195848-18346-1-git-send-email-al1img@gmail.com> References: <1507195848-18346-1-git-send-email-al1img@gmail.com> Cc: ian.jackson@eu.citrix.com, wei.liu2@citrix.com, Oleksandr Grytsov Subject: [Xen-devel] [PATCH 2/4] libxl: use libxl__device_kind in LIBXL_DEFINE_UPDATE_DEVID 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 Use libxl__..._devtype.type to update device id. Signed-off-by: Oleksandr Grytsov Acked-by: Wei Liu --- tools/libxl/libxl_9pfs.c | 2 +- tools/libxl/libxl_console.c | 2 +- tools/libxl/libxl_device.c | 7 ++++--- tools/libxl/libxl_internal.h | 12 +++++++----- tools/libxl/libxl_nic.c | 2 +- tools/libxl/libxl_usb.c | 2 +- tools/libxl/libxl_vdispl.c | 2 +- tools/libxl/libxl_vkb.c | 2 +- tools/libxl/libxl_vsnd.c | 2 +- tools/libxl/libxl_vtpm.c | 2 +- 10 files changed, 19 insertions(+), 16 deletions(-) diff --git a/tools/libxl/libxl_9pfs.c b/tools/libxl/libxl_9pfs.c index c3dd786..1298db1 100644 --- a/tools/libxl/libxl_9pfs.c +++ b/tools/libxl/libxl_9pfs.c @@ -37,7 +37,7 @@ static int libxl__device_from_p9(libxl__gc *gc, uint32_t domid, return 0; } -static LIBXL_DEFINE_UPDATE_DEVID(p9, "9pfs") +static LIBXL_DEFINE_UPDATE_DEVID(p9) static int libxl__set_xenstore_p9(libxl__gc *gc, uint32_t domid, libxl_device_p9 *p9, diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c index b7c0d34..002bcae 100644 --- a/tools/libxl/libxl_console.c +++ b/tools/libxl/libxl_console.c @@ -643,7 +643,7 @@ out: return AO_INPROGRESS; } -static LIBXL_DEFINE_UPDATE_DEVID(vfb, "vfb") +static LIBXL_DEFINE_UPDATE_DEVID(vfb) static int libxl__set_xenstore_vfb(libxl__gc *gc, uint32_t domid, libxl_device_vfb *vfb, diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c index 7aaf493..f84422e 100644 --- a/tools/libxl/libxl_device.c +++ b/tools/libxl/libxl_device.c @@ -1386,7 +1386,8 @@ out: } /* common function to get next device id */ -int libxl__device_nextid(libxl__gc *gc, uint32_t domid, char *device) +int libxl__device_nextid(libxl__gc *gc, uint32_t domid, + libxl__device_kind device) { char *libxl_dom_path, **l; unsigned int nb; @@ -1396,8 +1397,8 @@ int libxl__device_nextid(libxl__gc *gc, uint32_t domid, char *device) return nextid; l = libxl__xs_directory(gc, XBT_NULL, - GCSPRINTF("%s/device/%s", libxl_dom_path, device), - &nb); + GCSPRINTF("%s/device/%s", libxl_dom_path, + libxl__device_kind_to_string(device)), &nb); if (l == NULL || nb == 0) nextid = 0; else diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 10ad52f..ef9e781 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1222,7 +1222,8 @@ _hidden int libxl__init_console_from_channel(libxl__gc *gc, libxl__device_console *console, int dev_num, libxl_device_channel *channel); -_hidden int libxl__device_nextid(libxl__gc *gc, uint32_t domid, char *device); +_hidden int libxl__device_nextid(libxl__gc *gc, uint32_t domid, + libxl__device_kind device); _hidden int libxl__resolve_domid(libxl__gc *gc, const char *name, uint32_t *domid); @@ -3441,13 +3442,14 @@ _hidden void libxl__bootloader_run(libxl__egc*, libxl__bootloader_state *st); return AO_INPROGRESS; \ } -#define LIBXL_DEFINE_UPDATE_DEVID(type, name) \ - int libxl__device_##type##_update_devid(libxl__gc *gc, \ +#define LIBXL_DEFINE_UPDATE_DEVID(name) \ + int libxl__device_##name##_update_devid(libxl__gc *gc, \ uint32_t domid, \ - libxl_device_##type *type) \ + libxl_device_##name *type) \ { \ if (type->devid == -1) \ - type->devid = libxl__device_nextid(gc, domid, name); \ + type->devid = libxl__device_nextid(gc, domid, \ + libxl__##name##_devtype.type); \ if (type->devid < 0) \ return ERROR_FAIL; \ return 0; \ diff --git a/tools/libxl/libxl_nic.c b/tools/libxl/libxl_nic.c index 44d0fa7..fb5ae44 100644 --- a/tools/libxl/libxl_nic.c +++ b/tools/libxl/libxl_nic.c @@ -139,7 +139,7 @@ static void libxl__update_config_nic(libxl__gc *gc, libxl_device_nic *dst, libxl_mac_copy(CTX, &dst->mac, &src->mac); } -static LIBXL_DEFINE_UPDATE_DEVID(nic, "vif") +static LIBXL_DEFINE_UPDATE_DEVID(nic) static int libxl__set_xenstore_nic(libxl__gc *gc, uint32_t domid, libxl_device_nic *nic, diff --git a/tools/libxl/libxl_usb.c b/tools/libxl/libxl_usb.c index 6ce6957..045b50a 100644 --- a/tools/libxl/libxl_usb.c +++ b/tools/libxl/libxl_usb.c @@ -432,7 +432,7 @@ static int libxl__device_usbdev_del_hvm(libxl__gc *gc, uint32_t domid, return libxl__qmp_run_command_flexarray(gc, domid, "device_del", qmp_args); } -static LIBXL_DEFINE_UPDATE_DEVID(usbctrl, "vusb") +static LIBXL_DEFINE_UPDATE_DEVID(usbctrl) /* AO operation to add a usb controller. * diff --git a/tools/libxl/libxl_vdispl.c b/tools/libxl/libxl_vdispl.c index 31409a4..f2d1444 100644 --- a/tools/libxl/libxl_vdispl.c +++ b/tools/libxl/libxl_vdispl.c @@ -249,7 +249,7 @@ out: LIBXL_DEFINE_DEVICE_ADD(vdispl) static LIBXL_DEFINE_DEVICES_ADD(vdispl) LIBXL_DEFINE_DEVICE_REMOVE(vdispl) -static LIBXL_DEFINE_UPDATE_DEVID(vdispl, "vdispl") +static LIBXL_DEFINE_UPDATE_DEVID(vdispl) LIBXL_DEFINE_DEVICE_LIST(vdispl) DEFINE_DEVICE_TYPE_STRUCT(vdispl, VDISPL, diff --git a/tools/libxl/libxl_vkb.c b/tools/libxl/libxl_vkb.c index 1cd7feb..13aa01f 100644 --- a/tools/libxl/libxl_vkb.c +++ b/tools/libxl/libxl_vkb.c @@ -160,7 +160,7 @@ out: return rc; } -static LIBXL_DEFINE_UPDATE_DEVID(vkb, "vkbd") +static LIBXL_DEFINE_UPDATE_DEVID(vkb) #define libxl__add_vkbs NULL #define libxl_device_vkb_compare NULL diff --git a/tools/libxl/libxl_vsnd.c b/tools/libxl/libxl_vsnd.c index f81a9e2..8dfda46 100644 --- a/tools/libxl/libxl_vsnd.c +++ b/tools/libxl/libxl_vsnd.c @@ -644,7 +644,7 @@ out: LIBXL_DEFINE_DEVICE_ADD(vsnd) static LIBXL_DEFINE_DEVICES_ADD(vsnd) LIBXL_DEFINE_DEVICE_REMOVE(vsnd) -static LIBXL_DEFINE_UPDATE_DEVID(vsnd, "vsnd") +static LIBXL_DEFINE_UPDATE_DEVID(vsnd) LIBXL_DEFINE_DEVICE_LIST(vsnd) DEFINE_DEVICE_TYPE_STRUCT(vsnd, VSND, diff --git a/tools/libxl/libxl_vtpm.c b/tools/libxl/libxl_vtpm.c index c645074..f9ba481 100644 --- a/tools/libxl/libxl_vtpm.c +++ b/tools/libxl/libxl_vtpm.c @@ -49,7 +49,7 @@ static void libxl__update_config_vtpm(libxl__gc *gc, libxl_device_vtpm *dst, libxl_uuid_copy(CTX, &dst->uuid, &src->uuid); } -static LIBXL_DEFINE_UPDATE_DEVID(vtpm, "vtpm") +static LIBXL_DEFINE_UPDATE_DEVID(vtpm) static int libxl__set_xenstore_vtpm(libxl__gc *gc, uint32_t domid, libxl_device_vtpm *vtpm,