From patchwork Thu Oct 5 09:30:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Grytsov X-Patchwork-Id: 9986671 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 4766C60247 for ; Thu, 5 Oct 2017 09:33:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38BA228BE1 for ; Thu, 5 Oct 2017 09:33:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2DA2128C0A; Thu, 5 Oct 2017 09:33: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 72B2128BE1 for ; Thu, 5 Oct 2017 09:33: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 1e02Ug-0005kr-55; Thu, 05 Oct 2017 09:31:02 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e02Ue-0005il-BT for xen-devel@lists.xenproject.org; Thu, 05 Oct 2017 09:31:00 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id 2A/F4-03093-3DBF5D95; Thu, 05 Oct 2017 09:30:59 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrMIsWRWlGSWpSXmKPExsVyMfS6s+6l31c jDV4e0LT4vmUykwOjx+EPV1gCGKNYM/OS8isSWDNaJlxgLtgbX/Fh3mmmBsanbl2MXBxCAjMZ JfZ3djKBOCwCL1kk5jX1s4M4EgL9rBItT9cydjFyADlZEm8WBXQxcgKZaRLntl9hg7DLJY5NW 88MYgsJyEscbLnMDjF1CpPE0229YEVsAloS92+vALNFBJQk7q2azARiMwukSOxd18YIYgsLhE rcmrsNbBCLgKrEt13/mED28go4SLztsYDYJSdx81wnWAmngKPEl2+H2SD2Okj099xkmsAouIC RYRWjRnFqUVlqka6hoV5SUWZ6RkluYmaOrqGBmV5uanFxYnpqTmJSsV5yfu4mRmDAMQDBDsZP ywIOMUpyMCmJ8mp9vRopxJeUn1KZkVicEV9UmpNafIhRg4ND4OfTvy2MUix5+XmpShK8XB+A6 gSLUtNTK9Iyc4AxAVMqwcGjJML7+yNQmre4IDG3ODMdInWK0ZLjwp1Lf5g4Duy5BSQ7bt79wy QENk9KnJcXZJ4ASENGaR7cOFjcXmKUlRLmZQQ6VoinILUoN7MEVf4VozgHo5Iw7w2QKTyZeSV wW18BHcQEdNCcpisgB5UkIqSkGhhb8+vKp4tOXLrmtfrmqSu/FeXpPVEN3p3V+2R3vb6GxKwF B58f3Hv66qvZK5jddX6q9P6WSTizUXXT4pA9p3xYfDdm/9/25UFs+4rfQVqznqzQ63WeaSFea /PjuQSznjh3TVDZEwVpQyPhnNoXK37n2ukkCVpbf5wRGca4wWuO0Przl2VOz4hTYinOSDTUYi 4qTgQAN5v0xdYCAAA= X-Env-Sender: al1img@gmail.com X-Msg-Ref: server-7.tower-21.messagelabs.com!1507195858!76499072!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 3731 invoked from network); 5 Oct 2017 09:30:58 -0000 Received: from mail-lf0-f67.google.com (HELO mail-lf0-f67.google.com) (209.85.215.67) by server-7.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 5 Oct 2017 09:30:58 -0000 Received: by mail-lf0-f67.google.com with SMTP id d10so13939032lfg.11 for ; Thu, 05 Oct 2017 02:30:58 -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=p4Ob5QAvpxRUKTbruvkLOKy/lzP6o0z4z7cvPvm8bDU=; b=KERR0jutU572oHlZh/Mr4kbrmDRgN9C/TH6O4ZeiJeI8i3pmHhWICGgrei2MetLO6j yP1TW8J5Oa42McYe0lx9rFP+cFCGWOmuxlLgsmIUCRDWWIPIZWh8uwab5JWOX+Z45l/l +/Xl1Zvmh1YwzYNpYxYgmk5xlG8HJkrEFVCjguPrFMYCauFKl+MFxptjRhYdGE46zvD0 uc5CNYk/o16QCnf+KPeAKUXIsVnS79dlVRPf0aB/NvqkUzudKNTqOoc1jap2JCoali+X NFhIUzMDqAERMWAJ59Gm8UeJYIMpR/+V6nLis8jlGpLGLQuOHgNTJuL0NeBvRDWKtZg2 84Fg== 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=p4Ob5QAvpxRUKTbruvkLOKy/lzP6o0z4z7cvPvm8bDU=; b=ZrJZ6mKWtjRX7xUnuZa1p4m6iwABA5WHY2Nt/TXRT1WC6iEuN0DyCGiKdvGgze6YVe P4G1/MB9mRz9CM1K7E9PfAtVIt1MX/QC9oZ5Pts0MlEuJI79ZAQcXqoPY0Xa85KLtyZg VBpmi9+L1k5frTPsbfRzDF90byXCY5Xcw4IA4UD0I1d2tCii1+B+Oq48cIfEt5cQRTiB 3AcEfHZsy4s2Gg6XCeIIq3lDo3SX3Yw2+AmOJimrmBwfJ1DbeJ1sglYMRELjVoo9xMoV nznVyzFQU1kjR7N0gWJnawxvtwFJ3KoQ1slwgBFLF5zZ+IRoR/R2NxI1drkpyymmKC2v uriA== X-Gm-Message-State: AMCzsaXzFVPJ01Qz3BXRZBWWPQj74TXVNq3uXkgYs6Lgannnyde4Ptma FIn6wVrmeRaZVHjX9WyeYxOeGA== X-Google-Smtp-Source: AOwi7QCcloYaRW4YJvncwciYlaX+hJaTHbyROA+aclC0x+YPQlZtPu5EKrws3JOmiy+TBTskcIgYiw== X-Received: by 10.25.87.74 with SMTP id l71mr6989158lfb.26.1507195857661; Thu, 05 Oct 2017 02:30:57 -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.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Oct 2017 02:30:56 -0700 (PDT) From: Oleksandr Grytsov To: xen-devel@lists.xenproject.org Date: Thu, 5 Oct 2017 12:30:47 +0300 Message-Id: <1507195848-18346-4-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 3/4] libxl: move libxl__device_from_ to LIBXL_DEFINE_DEVICE_FROM_TYPE 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 LIBXL_DEFINE_DEVICE_FROM_TYPE uses libxl__..._devtype.type to be assigned as device and backend type. Signed-off-by: Oleksandr Grytsov Acked-by: Wei Liu --- tools/libxl/libxl_9pfs.c | 19 +++---------------- tools/libxl/libxl_console.c | 18 +++--------------- tools/libxl/libxl_internal.h | 15 +++++++++++++++ tools/libxl/libxl_nic.c | 19 +++---------------- tools/libxl/libxl_vdispl.c | 20 ++++---------------- tools/libxl/libxl_vkb.c | 15 +-------------- tools/libxl/libxl_vsnd.c | 21 +++++---------------- tools/libxl/libxl_vtpm.c | 21 ++++----------------- 8 files changed, 38 insertions(+), 110 deletions(-) diff --git a/tools/libxl/libxl_9pfs.c b/tools/libxl/libxl_9pfs.c index 1298db1..e5c41e9 100644 --- a/tools/libxl/libxl_9pfs.c +++ b/tools/libxl/libxl_9pfs.c @@ -23,22 +23,6 @@ static int libxl__device_p9_setdefault(libxl__gc *gc, uint32_t domid, return libxl__resolve_domid(gc, p9->backend_domname, &p9->backend_domid); } -static int libxl__device_from_p9(libxl__gc *gc, uint32_t domid, - libxl_device_p9 *p9, - libxl__device *device) -{ - device->backend_devid = p9->devid; - device->backend_domid = p9->backend_domid; - device->backend_kind = LIBXL__DEVICE_KIND_9PFS; - device->devid = p9->devid; - device->domid = domid; - device->kind = LIBXL__DEVICE_KIND_9PFS; - - return 0; -} - -static LIBXL_DEFINE_UPDATE_DEVID(p9) - static int libxl__set_xenstore_p9(libxl__gc *gc, uint32_t domid, libxl_device_p9 *p9, flexarray_t *back, flexarray_t *front, @@ -56,6 +40,9 @@ static int libxl__set_xenstore_p9(libxl__gc *gc, uint32_t domid, #define libxl_device_p9_list NULL #define libxl_device_p9_compare NULL +static LIBXL_DEFINE_UPDATE_DEVID(p9) +static LIBXL_DEFINE_DEVICE_FROM_TYPE(p9) + LIBXL_DEFINE_DEVICE_REMOVE(p9) DEFINE_DEVICE_TYPE_STRUCT(p9, 9PFS, diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c index 002bcae..329db6c 100644 --- a/tools/libxl/libxl_console.c +++ b/tools/libxl/libxl_console.c @@ -613,19 +613,6 @@ static int libxl__device_vfb_setdefault(libxl__gc *gc, uint32_t domid, return rc; } -static int libxl__device_from_vfb(libxl__gc *gc, uint32_t domid, - libxl_device_vfb *vfb, - libxl__device *device) -{ - device->backend_devid = vfb->devid; - device->backend_domid = vfb->backend_domid; - device->backend_kind = LIBXL__DEVICE_KIND_VFB; - device->devid = vfb->devid; - device->domid = domid; - device->kind = LIBXL__DEVICE_KIND_VFB; - return 0; -} - int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb, const libxl_asyncop_how *ao_how) { @@ -643,8 +630,6 @@ out: return AO_INPROGRESS; } -static LIBXL_DEFINE_UPDATE_DEVID(vfb) - static int libxl__set_xenstore_vfb(libxl__gc *gc, uint32_t domid, libxl_device_vfb *vfb, flexarray_t *back, flexarray_t *front, @@ -685,6 +670,9 @@ static int libxl__set_xenstore_vfb(libxl__gc *gc, uint32_t domid, #define libxl_device_vfb_list NULL #define libxl_device_vfb_compare NULL +static LIBXL_DEFINE_UPDATE_DEVID(vfb) +static LIBXL_DEFINE_DEVICE_FROM_TYPE(vfb) + /* vfb */ LIBXL_DEFINE_DEVICE_REMOVE(vfb) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index ef9e781..d1a8d8e 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -3455,6 +3455,21 @@ _hidden void libxl__bootloader_run(libxl__egc*, libxl__bootloader_state *st); return 0; \ } +#define LIBXL_DEFINE_DEVICE_FROM_TYPE(name) \ + int libxl__device_from_##name(libxl__gc *gc, uint32_t domid, \ + libxl_device_##name *type, \ + libxl__device *device) \ + { \ + device->backend_devid = type->devid; \ + device->backend_domid = type->backend_domid; \ + device->backend_kind = libxl__##name##_devtype.type; \ + device->devid = type->devid; \ + device->domid = domid; \ + device->kind = libxl__##name##_devtype.type; \ + \ + return 0; \ + } + #define LIBXL_DEFINE_DEVICE_REMOVE(type) \ LIBXL_DEFINE_DEVICE_REMOVE_EXT(type, generic, remove, 0) \ LIBXL_DEFINE_DEVICE_REMOVE_EXT(type, generic, destroy, 1) diff --git a/tools/libxl/libxl_nic.c b/tools/libxl/libxl_nic.c index fb5ae44..2d01803 100644 --- a/tools/libxl/libxl_nic.c +++ b/tools/libxl/libxl_nic.c @@ -117,20 +117,6 @@ static int libxl__device_nic_setdefault(libxl__gc *gc, uint32_t domid, return rc; } -static int libxl__device_from_nic(libxl__gc *gc, uint32_t domid, - libxl_device_nic *nic, - libxl__device *device) -{ - device->backend_devid = nic->devid; - device->backend_domid = nic->backend_domid; - device->backend_kind = LIBXL__DEVICE_KIND_VIF; - device->devid = nic->devid; - device->domid = domid; - device->kind = LIBXL__DEVICE_KIND_VIF; - - return 0; -} - static void libxl__update_config_nic(libxl__gc *gc, libxl_device_nic *dst, const libxl_device_nic *src) { @@ -139,8 +125,6 @@ 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) - static int libxl__set_xenstore_nic(libxl__gc *gc, uint32_t domid, libxl_device_nic *nic, flexarray_t *back, flexarray_t *front, @@ -542,6 +526,9 @@ out: return ret; } +static LIBXL_DEFINE_UPDATE_DEVID(nic) +static LIBXL_DEFINE_DEVICE_FROM_TYPE(nic) + LIBXL_DEFINE_DEVICE_ADD(nic) LIBXL_DEFINE_DEVICES_ADD(nic) LIBXL_DEFINE_DEVICE_REMOVE(nic) diff --git a/tools/libxl/libxl_vdispl.c b/tools/libxl/libxl_vdispl.c index f2d1444..0d87500 100644 --- a/tools/libxl/libxl_vdispl.c +++ b/tools/libxl/libxl_vdispl.c @@ -22,20 +22,6 @@ static int libxl__device_vdispl_setdefault(libxl__gc *gc, uint32_t domid, &vdispl->backend_domid); } -static int libxl__device_from_vdispl(libxl__gc *gc, uint32_t domid, - libxl_device_vdispl *vdispl, - libxl__device *device) -{ - device->backend_devid = vdispl->devid; - device->backend_domid = vdispl->backend_domid; - device->backend_kind = LIBXL__DEVICE_KIND_VDISPL; - device->devid = vdispl->devid; - device->domid = domid; - device->kind = LIBXL__DEVICE_KIND_VDISPL; - - return 0; -} - static int libxl__vdispl_from_xenstore(libxl__gc *gc, const char *libxl_path, libxl_devid devid, libxl_device_vdispl *vdispl) @@ -246,10 +232,12 @@ out: return rc; } -LIBXL_DEFINE_DEVICE_ADD(vdispl) +static LIBXL_DEFINE_DEVICE_FROM_TYPE(vdispl) +static LIBXL_DEFINE_UPDATE_DEVID(vdispl) static LIBXL_DEFINE_DEVICES_ADD(vdispl) + +LIBXL_DEFINE_DEVICE_ADD(vdispl) LIBXL_DEFINE_DEVICE_REMOVE(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 13aa01f..6ee0a7e 100644 --- a/tools/libxl/libxl_vkb.c +++ b/tools/libxl/libxl_vkb.c @@ -21,20 +21,6 @@ static int libxl__device_vkb_setdefault(libxl__gc *gc, uint32_t domid, return libxl__resolve_domid(gc, vkb->backend_domname, &vkb->backend_domid); } -static int libxl__device_from_vkb(libxl__gc *gc, uint32_t domid, - libxl_device_vkb *vkb, - libxl__device *device) -{ - device->backend_devid = vkb->devid; - device->backend_domid = vkb->backend_domid; - device->backend_kind = LIBXL__DEVICE_KIND_VKBD; - device->devid = vkb->devid; - device->domid = domid; - device->kind = LIBXL__DEVICE_KIND_VKBD; - - return 0; -} - static int libxl__device_vkb_dm_needed(libxl_device_vkb *vkb, uint32_t domid) { if (vkb->backend_type == LIBXL_VKB_BACKEND_QEMU) @@ -161,6 +147,7 @@ out: } static LIBXL_DEFINE_UPDATE_DEVID(vkb) +static LIBXL_DEFINE_DEVICE_FROM_TYPE(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 8dfda46..8cc3a4b 100644 --- a/tools/libxl/libxl_vsnd.c +++ b/tools/libxl/libxl_vsnd.c @@ -23,20 +23,6 @@ static int libxl__device_vsnd_setdefault(libxl__gc *gc, uint32_t domid, &vsnd->backend_domid); } -static int libxl__device_from_vsnd(libxl__gc *gc, uint32_t domid, - libxl_device_vsnd *vsnd, - libxl__device *device) -{ - device->backend_devid = vsnd->devid; - device->backend_domid = vsnd->backend_domid; - device->backend_kind = LIBXL__DEVICE_KIND_VSND; - device->devid = vsnd->devid; - device->domid = domid; - device->kind = LIBXL__DEVICE_KIND_VSND; - - return 0; -} - static int libxl__sample_rates_from_string(libxl__gc *gc, const char *str, libxl_vsnd_params *params) { @@ -641,10 +627,13 @@ out: return rc; } -LIBXL_DEFINE_DEVICE_ADD(vsnd) + +static LIBXL_DEFINE_UPDATE_DEVID(vsnd) +static LIBXL_DEFINE_DEVICE_FROM_TYPE(vsnd) static LIBXL_DEFINE_DEVICES_ADD(vsnd) + +LIBXL_DEFINE_DEVICE_ADD(vsnd) LIBXL_DEFINE_DEVICE_REMOVE(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 f9ba481..3a9e972 100644 --- a/tools/libxl/libxl_vtpm.c +++ b/tools/libxl/libxl_vtpm.c @@ -28,20 +28,6 @@ static int libxl__device_vtpm_setdefault(libxl__gc *gc, uint32_t domid, return rc; } -static int libxl__device_from_vtpm(libxl__gc *gc, uint32_t domid, - libxl_device_vtpm *vtpm, - libxl__device *device) -{ - device->backend_devid = vtpm->devid; - device->backend_domid = vtpm->backend_domid; - device->backend_kind = LIBXL__DEVICE_KIND_VTPM; - device->devid = vtpm->devid; - device->domid = domid; - device->kind = LIBXL__DEVICE_KIND_VTPM; - - return 0; -} - static void libxl__update_config_vtpm(libxl__gc *gc, libxl_device_vtpm *dst, libxl_device_vtpm *src) { @@ -49,8 +35,6 @@ 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) - static int libxl__set_xenstore_vtpm(libxl__gc *gc, uint32_t domid, libxl_device_vtpm *vtpm, flexarray_t *back, flexarray_t *front, @@ -243,8 +227,11 @@ static void libxl_device_vtpm_update_config(libxl__gc *gc, void *d, void *s) libxl__update_config_vtpm(gc, d, s); } -LIBXL_DEFINE_DEVICE_ADD(vtpm) +static LIBXL_DEFINE_UPDATE_DEVID(vtpm) +static LIBXL_DEFINE_DEVICE_FROM_TYPE(vtpm) static LIBXL_DEFINE_DEVICES_ADD(vtpm) + +LIBXL_DEFINE_DEVICE_ADD(vtpm) LIBXL_DEFINE_DEVICE_REMOVE(vtpm) LIBXL_DEFINE_DEVICE_LIST(vtpm)