From nobody Mon Feb 9 19:52:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1607455875; cv=none; d=zohomail.com; s=zohoarc; b=jfLv6EVVejpFQ3ZERMfN3JknwDHQR02wkHeRK781IGdOTJc6sgwoA0twJQAZnPz+v3/MvfRAmn6qNSHBpnqJSVIWhMTxV3FukVQDbjG7Vs7qodKbXc6/KZmmOoySi7N2u4n0BbmYPFZ1Mo8DARvaxVVqbLG/brHxZ9puit7BFBk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607455875; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cBR0cFUJiqGdqAnzx98TGoc+XReo3bFMnFXG44K2vPM=; b=ZC5RprnaYTMowm7qe5Zhbf0/k2r+EaGu1A5TyG7wru3qJDiov+Yq9h0kUE5wUsgWRZ9owbfNhx4ou8gjs0uYjwkyiPdSEvtU/WZDqGJ6OZ4UDKY74TlACPZq2dj1qQEBfIrVuDY0aotC85ZP/no8wrr4rlRwd6aeEmYTw+Pvwn8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1607455875566460.86219530763526; Tue, 8 Dec 2020 11:31:15 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.47684.84392 (Exim 4.92) (envelope-from ) id 1kmihA-0000fS-BV; Tue, 08 Dec 2020 19:30:44 +0000 Received: by outflank-mailman (output) from mailman id 47684.84392; Tue, 08 Dec 2020 19:30:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kmihA-0000fJ-89; Tue, 08 Dec 2020 19:30:44 +0000 Received: by outflank-mailman (input) for mailman id 47684; Tue, 08 Dec 2020 19:30:42 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kmih8-0000eq-OR for xen-devel@lists.xenproject.org; Tue, 08 Dec 2020 19:30:42 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kmih7-0007L7-Ex; Tue, 08 Dec 2020 19:30:41 +0000 Received: from host86-183-162-145.range86-183.btcentralplus.com ([86.183.162.145] helo=desktop.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kmih6-0001p0-Ux; Tue, 08 Dec 2020 19:30:41 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=cBR0cFUJiqGdqAnzx98TGoc+XReo3bFMnFXG44K2vPM=; b=tuoNXXfrttWvfUtiK4TwNMNvrE LLLNzG1ChqgqU8TPEZNhkVHVjDPII1xPjeR8fXVnbsxEU9P7rZOvgQ2FD7sJ/sSfmaquMYNF3ZnPY OW3jBIYJo8PO6vA/RjCA/xmLi5alI85hs1QWQOC82GR5wF72FYwOofHyUZY6d0P3i81c=; From: Paul Durrant To: xen-devel@lists.xenproject.org Cc: Paul Durrant , Ian Jackson , Wei Liu , Anthony PERARD Subject: [PATCH v6 01/25] libxl: s/pcidev/pci and remove DEFINE_DEVICE_TYPE_STRUCT_X Date: Tue, 8 Dec 2020 19:30:09 +0000 Message-Id: <20201208193033.11306-2-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201208193033.11306-1-paul@xen.org> References: <20201208193033.11306-1-paul@xen.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) Content-Type: text/plain; charset="utf-8" From: Paul Durrant The seemingly arbitrary use of 'pci' and 'pcidev' in the code in libxl_pci.c is confusing and also compromises use of some macros used for other device types. Indeed it seems that DEFINE_DEVICE_TYPE_STRUCT_X exists solely becau= se of this duality. This patch purges use of 'pcidev' from the libxl internal code, but unfortunately the 'pcidevs' and 'num_pcidevs' fields in 'libxl_domain_confi= g' are part of the API and need to be retained to avoid breaking callers, particularly libvirt. DEFINE_DEVICE_TYPE_STRUCT_X is still removed to avoid the special case in libxl_pci.c but DEFINE_DEVICE_TYPE_STRUCT is given an extra 'array' argument which is used to identify the fields in 'libxl_domain_config' relating to the device type. NOTE: Some of the more gross formatting errors (such as lack of spaces after keywords) that came into context have been fixed in libxl_pci.c. Signed-off-by: Paul Durrant Acked-by: Wei Liu --- Cc: Ian Jackson Cc: Wei Liu Cc: Anthony PERARD v6: - Avoid name changes in 'libxl_domain_config' - Defer xl changes to a subsequent patch v5: - Minor cosmetic fix --- tools/include/libxl.h | 10 +- tools/libs/light/libxl_9pfs.c | 2 +- tools/libs/light/libxl_console.c | 2 +- tools/libs/light/libxl_create.c | 4 +- tools/libs/light/libxl_disk.c | 2 +- tools/libs/light/libxl_internal.h | 29 +- tools/libs/light/libxl_nic.c | 2 +- tools/libs/light/libxl_pci.c | 570 +++++++++++++++--------------- tools/libs/light/libxl_pvcalls.c | 2 +- tools/libs/light/libxl_usb.c | 4 +- tools/libs/light/libxl_vdispl.c | 2 +- tools/libs/light/libxl_vkb.c | 2 +- tools/libs/light/libxl_vsnd.c | 2 +- tools/libs/light/libxl_vtpm.c | 2 +- tools/libs/util/libxlu_pci.c | 36 +- 15 files changed, 334 insertions(+), 337 deletions(-) diff --git a/tools/include/libxl.h b/tools/include/libxl.h index eaffccb30f37..733263522bd9 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -2307,15 +2307,15 @@ int libxl_device_pvcallsif_destroy(libxl_ctx *ctx, = uint32_t domid, =20 /* PCI Passthrough */ int libxl_device_pci_add(libxl_ctx *ctx, uint32_t domid, - libxl_device_pci *pcidev, + libxl_device_pci *pci, const libxl_asyncop_how *ao_how) LIBXL_EXTERNAL_CALLERS_ONLY; int libxl_device_pci_remove(libxl_ctx *ctx, uint32_t domid, - libxl_device_pci *pcidev, + libxl_device_pci *pci, const libxl_asyncop_how *ao_how) LIBXL_EXTERNAL_CALLERS_ONLY; int libxl_device_pci_destroy(libxl_ctx *ctx, uint32_t domid, - libxl_device_pci *pcidev, + libxl_device_pci *pci, const libxl_asyncop_how *ao_how) LIBXL_EXTERNAL_CALLERS_ONLY; =20 @@ -2359,8 +2359,8 @@ int libxl_device_events_handler(libxl_ctx *ctx, * added or is not bound, the functions will emit a warning but return * SUCCESS. */ -int libxl_device_pci_assignable_add(libxl_ctx *ctx, libxl_device_pci *pcid= ev, int rebind); -int libxl_device_pci_assignable_remove(libxl_ctx *ctx, libxl_device_pci *p= cidev, int rebind); +int libxl_device_pci_assignable_add(libxl_ctx *ctx, libxl_device_pci *pci,= int rebind); +int libxl_device_pci_assignable_remove(libxl_ctx *ctx, libxl_device_pci *p= ci, int rebind); libxl_device_pci *libxl_device_pci_assignable_list(libxl_ctx *ctx, int *nu= m); =20 /* CPUID handling */ diff --git a/tools/libs/light/libxl_9pfs.c b/tools/libs/light/libxl_9pfs.c index e5c41e9a2524..5ab0d3aa21b0 100644 --- a/tools/libs/light/libxl_9pfs.c +++ b/tools/libs/light/libxl_9pfs.c @@ -45,7 +45,7 @@ static LIBXL_DEFINE_DEVICE_FROM_TYPE(p9) =20 LIBXL_DEFINE_DEVICE_REMOVE(p9) =20 -DEFINE_DEVICE_TYPE_STRUCT(p9, 9PFS, +DEFINE_DEVICE_TYPE_STRUCT(p9, 9PFS, p9s, .skip_attach =3D 1, .set_xenstore_config =3D (device_set_xenstore_config_fn_t) libxl__set_xenstore_p9, diff --git a/tools/libs/light/libxl_console.c b/tools/libs/light/libxl_cons= ole.c index 047d23d7ae78..d8b2bc546582 100644 --- a/tools/libs/light/libxl_console.c +++ b/tools/libs/light/libxl_console.c @@ -725,7 +725,7 @@ static LIBXL_DEFINE_DEVICE_FROM_TYPE(vfb) /* vfb */ LIBXL_DEFINE_DEVICE_REMOVE(vfb) =20 -DEFINE_DEVICE_TYPE_STRUCT(vfb, VFB, +DEFINE_DEVICE_TYPE_STRUCT(vfb, VFB, vfbs, .skip_attach =3D 1, .set_xenstore_config =3D (device_set_xenstore_config_fn_t) libxl__set_xenstore_vfb, diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_creat= e.c index 321a13e519b5..86f4a8369d35 100644 --- a/tools/libs/light/libxl_create.c +++ b/tools/libs/light/libxl_create.c @@ -1809,7 +1809,7 @@ out: #define libxl__device_from_dtdev NULL #define libxl__device_dtdev_setdefault NULL #define libxl__device_dtdev_update_devid NULL -static DEFINE_DEVICE_TYPE_STRUCT(dtdev, NONE); +static DEFINE_DEVICE_TYPE_STRUCT(dtdev, NONE, dtdevs); =20 const libxl__device_type *device_type_tbl[] =3D { &libxl__disk_devtype, @@ -1817,7 +1817,7 @@ const libxl__device_type *device_type_tbl[] =3D { &libxl__vtpm_devtype, &libxl__usbctrl_devtype, &libxl__usbdev_devtype, - &libxl__pcidev_devtype, + &libxl__pci_devtype, &libxl__dtdev_devtype, &libxl__vdispl_devtype, &libxl__vsnd_devtype, diff --git a/tools/libs/light/libxl_disk.c b/tools/libs/light/libxl_disk.c index de183e0fb082..411ffeaca6ce 100644 --- a/tools/libs/light/libxl_disk.c +++ b/tools/libs/light/libxl_disk.c @@ -1374,7 +1374,7 @@ LIBXL_DEFINE_DEVICE_LIST(disk) =20 #define libxl__device_disk_update_devid NULL =20 -DEFINE_DEVICE_TYPE_STRUCT(disk, VBD, +DEFINE_DEVICE_TYPE_STRUCT(disk, VBD, disks, .merge =3D libxl_device_disk_merge, .dm_needed =3D libxl_device_disk_dm_needed, .from_xenstore =3D (device_from_xenstore_fn_t)libxl__disk_from_xenstor= e, diff --git a/tools/libs/light/libxl_internal.h b/tools/libs/light/libxl_int= ernal.h index e26cda9b5045..c2c5a9b92673 100644 --- a/tools/libs/light/libxl_internal.h +++ b/tools/libs/light/libxl_internal.h @@ -1709,7 +1709,7 @@ _hidden int libxl__pci_topology_init(libxl__gc *gc, /* from libxl_pci */ =20 _hidden void libxl__device_pci_add(libxl__egc *egc, uint32_t domid, - libxl_device_pci *pcidev, bool starting, + libxl_device_pci *pci, bool starting, libxl__ao_device *aodev); _hidden void libxl__device_pci_destroy_all(libxl__egc *egc, uint32_t domid, libxl__multidev *); @@ -3945,30 +3945,27 @@ struct libxl__device_type { device_set_xenstore_config_fn_t set_xenstore_config; }; =20 -#define DEFINE_DEVICE_TYPE_STRUCT_X(name, sname, kind, ...) = \ +#define DEFINE_DEVICE_TYPE_STRUCT(name, kind, array, ...) = \ const libxl__device_type libxl__ ## name ## _devtype =3D { = \ - .type =3D LIBXL__DEVICE_KIND_ ## kind, = \ - .ptr_offset =3D offsetof(libxl_domain_config, name ## s), = \ - .num_offset =3D offsetof(libxl_domain_config, num_ ## name ## s= ), \ - .dev_elem_size =3D sizeof(libxl_device_ ## sname), = \ + .type =3D LIBXL__DEVICE_KIND_ ## kind, = \ + .ptr_offset =3D offsetof(libxl_domain_config, array), = \ + .num_offset =3D offsetof(libxl_domain_config, num_ ## array), = \ + .dev_elem_size =3D sizeof(libxl_device_ ## name), = \ .add =3D libxl__add_ ## name ## s, = \ .set_default =3D (device_set_default_fn_t) = \ - libxl__device_ ## sname ## _setdefault, = \ + libxl__device_ ## name ## _setdefault, = \ .to_device =3D (device_to_device_fn_t)libxl__device_from_ ## n= ame, \ - .init =3D (device_init_fn_t)libxl_device_ ## sname ## _in= it, \ - .copy =3D (device_copy_fn_t)libxl_device_ ## sname ## _co= py, \ + .init =3D (device_init_fn_t)libxl_device_ ## name ## _ini= t, \ + .copy =3D (device_copy_fn_t)libxl_device_ ## name ## _cop= y, \ .dispose =3D (device_dispose_fn_t) = \ - libxl_device_ ## sname ## _dispose, = \ + libxl_device_ ## name ## _dispose, = \ .compare =3D (device_compare_fn_t) = \ - libxl_device_ ## sname ## _compare, = \ + libxl_device_ ## name ## _compare, = \ .update_devid =3D (device_update_devid_fn_t) = \ - libxl__device_ ## sname ## _update_devid, = \ + libxl__device_ ## name ## _update_devid, = \ __VA_ARGS__ = \ } =20 -#define DEFINE_DEVICE_TYPE_STRUCT(name, kind, ...) = \ - DEFINE_DEVICE_TYPE_STRUCT_X(name, name, kind, __VA_ARGS__) - static inline void **libxl__device_type_get_ptr( const libxl__device_type *dt, const libxl_domain_config *d_config) { @@ -3995,7 +3992,7 @@ extern const libxl__device_type libxl__nic_devtype; extern const libxl__device_type libxl__vtpm_devtype; extern const libxl__device_type libxl__usbctrl_devtype; extern const libxl__device_type libxl__usbdev_devtype; -extern const libxl__device_type libxl__pcidev_devtype; +extern const libxl__device_type libxl__pci_devtype; extern const libxl__device_type libxl__vdispl_devtype; extern const libxl__device_type libxl__p9_devtype; extern const libxl__device_type libxl__pvcallsif_devtype; diff --git a/tools/libs/light/libxl_nic.c b/tools/libs/light/libxl_nic.c index 0e5d120ae9a4..144e9e23e198 100644 --- a/tools/libs/light/libxl_nic.c +++ b/tools/libs/light/libxl_nic.c @@ -528,7 +528,7 @@ LIBXL_DEFINE_DEVICE_ADD(nic) LIBXL_DEFINE_DEVICES_ADD(nic) LIBXL_DEFINE_DEVICE_REMOVE(nic) =20 -DEFINE_DEVICE_TYPE_STRUCT(nic, VIF, +DEFINE_DEVICE_TYPE_STRUCT(nic, VIF, nics, .update_config =3D libxl_device_nic_update_config, .from_xenstore =3D (device_from_xenstore_fn_t)libxl__nic_from_xenstore, .set_xenstore_config =3D (device_set_xenstore_config_fn_t) diff --git a/tools/libs/light/libxl_pci.c b/tools/libs/light/libxl_pci.c index bc5843b13701..3340076d2cb3 100644 --- a/tools/libs/light/libxl_pci.c +++ b/tools/libs/light/libxl_pci.c @@ -25,51 +25,51 @@ #define PCI_BDF_XSPATH "%04x-%02x-%02x-%01x" #define PCI_PT_QDEV_ID "pci-pt-%02x_%02x.%01x" =20 -static unsigned int pcidev_encode_bdf(libxl_device_pci *pcidev) +static unsigned int pci_encode_bdf(libxl_device_pci *pci) { unsigned int value; =20 - value =3D pcidev->domain << 16; - value |=3D (pcidev->bus & 0xff) << 8; - value |=3D (pcidev->dev & 0x1f) << 3; - value |=3D (pcidev->func & 0x7); + value =3D pci->domain << 16; + value |=3D (pci->bus & 0xff) << 8; + value |=3D (pci->dev & 0x1f) << 3; + value |=3D (pci->func & 0x7); =20 return value; } =20 -static void pcidev_struct_fill(libxl_device_pci *pcidev, unsigned int doma= in, - unsigned int bus, unsigned int dev, - unsigned int func, unsigned int vdevfn) +static void pci_struct_fill(libxl_device_pci *pci, unsigned int domain, + unsigned int bus, unsigned int dev, + unsigned int func, unsigned int vdevfn) { - pcidev->domain =3D domain; - pcidev->bus =3D bus; - pcidev->dev =3D dev; - pcidev->func =3D func; - pcidev->vdevfn =3D vdevfn; + pci->domain =3D domain; + pci->bus =3D bus; + pci->dev =3D dev; + pci->func =3D func; + pci->vdevfn =3D vdevfn; } =20 static void libxl_create_pci_backend_device(libxl__gc *gc, flexarray_t *back, int num, - const libxl_device_pci *pcidev) + const libxl_device_pci *pci) { flexarray_append(back, GCSPRINTF("key-%d", num)); - flexarray_append(back, GCSPRINTF(PCI_BDF, pcidev->domain, pcidev->bus,= pcidev->dev, pcidev->func)); + flexarray_append(back, GCSPRINTF(PCI_BDF, pci->domain, pci->bus, pci->= dev, pci->func)); flexarray_append(back, GCSPRINTF("dev-%d", num)); - flexarray_append(back, GCSPRINTF(PCI_BDF, pcidev->domain, pcidev->bus,= pcidev->dev, pcidev->func)); - if (pcidev->vdevfn) - flexarray_append_pair(back, GCSPRINTF("vdevfn-%d", num), GCSPRINTF= ("%x", pcidev->vdevfn)); + flexarray_append(back, GCSPRINTF(PCI_BDF, pci->domain, pci->bus, pci->= dev, pci->func)); + if (pci->vdevfn) + flexarray_append_pair(back, GCSPRINTF("vdevfn-%d", num), GCSPRINTF= ("%x", pci->vdevfn)); flexarray_append(back, GCSPRINTF("opts-%d", num)); flexarray_append(back, GCSPRINTF("msitranslate=3D%d,power_mgmt=3D%d,permissive=3D%d= ", - pcidev->msitranslate, pcidev->power_mgmt, - pcidev->permissive)); + pci->msitranslate, pci->power_mgmt, + pci->permissive)); flexarray_append_pair(back, GCSPRINTF("state-%d", num), GCSPRINTF("%d"= , XenbusStateInitialising)); } =20 -static void libxl__device_from_pcidev(libxl__gc *gc, uint32_t domid, - const libxl_device_pci *pcidev, - libxl__device *device) +static void libxl__device_from_pci(libxl__gc *gc, uint32_t domid, + const libxl_device_pci *pci, + libxl__device *device) { device->backend_devid =3D 0; device->backend_domid =3D 0; @@ -80,7 +80,7 @@ static void libxl__device_from_pcidev(libxl__gc *gc, uint= 32_t domid, } =20 static int libxl__create_pci_backend(libxl__gc *gc, uint32_t domid, - const libxl_device_pci *pcidev, + const libxl_device_pci *pci, int num) { flexarray_t *front =3D NULL; @@ -94,15 +94,15 @@ static int libxl__create_pci_backend(libxl__gc *gc, uin= t32_t domid, LOGD(DEBUG, domid, "Creating pci backend"); =20 /* add pci device */ - libxl__device_from_pcidev(gc, domid, pcidev, &device); + libxl__device_from_pci(gc, domid, pci, &device); =20 flexarray_append_pair(back, "frontend-id", GCSPRINTF("%d", domid)); flexarray_append_pair(back, "online", "1"); flexarray_append_pair(back, "state", GCSPRINTF("%d", XenbusStateInitia= lising)); flexarray_append_pair(back, "domain", libxl__domid_to_name(gc, domid)); =20 - for (i =3D 0; i < num; i++, pcidev++) - libxl_create_pci_backend_device(gc, back, i, pcidev); + for (i =3D 0; i < num; i++, pci++) + libxl_create_pci_backend_device(gc, back, i, pci); =20 flexarray_append_pair(back, "num_devs", GCSPRINTF("%d", num)); flexarray_append_pair(front, "backend-id", GCSPRINTF("%d", 0)); @@ -116,7 +116,7 @@ static int libxl__create_pci_backend(libxl__gc *gc, uin= t32_t domid, =20 static int libxl__device_pci_add_xenstore(libxl__gc *gc, uint32_t domid, - const libxl_device_pci *pcidev, + const libxl_device_pci *pci, bool starting) { flexarray_t *back; @@ -136,7 +136,7 @@ static int libxl__device_pci_add_xenstore(libxl__gc *gc, LIBXL__DEVICE_KIND_PCI); num_devs =3D libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/num_devs", be_= path)); if (!num_devs) - return libxl__create_pci_backend(gc, domid, pcidev, 1); + return libxl__create_pci_backend(gc, domid, pci, 1); =20 libxl_domain_type domtype =3D libxl__domain_type(gc, domid); if (domtype =3D=3D LIBXL_DOMAIN_TYPE_INVALID) @@ -151,7 +151,7 @@ static int libxl__device_pci_add_xenstore(libxl__gc *gc, =20 LOGD(DEBUG, domid, "Adding new pci device to xenstore"); num =3D atoi(num_devs); - libxl_create_pci_backend_device(gc, back, num, pcidev); + libxl_create_pci_backend_device(gc, back, num, pci); flexarray_append_pair(back, "num_devs", GCSPRINTF("%d", num + 1)); if (!starting) flexarray_append_pair(back, "state", GCSPRINTF("%d", XenbusStateRe= configuring)); @@ -170,8 +170,8 @@ static int libxl__device_pci_add_xenstore(libxl__gc *gc, rc =3D libxl__get_domain_configuration(gc, domid, &d_config); if (rc) goto out; =20 - device_add_domain_config(gc, &d_config, &libxl__pcidev_devtype, - pcidev); + device_add_domain_config(gc, &d_config, &libxl__pci_devtype, + pci); =20 rc =3D libxl__dm_check_start(gc, &d_config, domid); if (rc) goto out; @@ -201,7 +201,7 @@ out: return rc; } =20 -static int libxl__device_pci_remove_xenstore(libxl__gc *gc, uint32_t domid= , libxl_device_pci *pcidev) +static int libxl__device_pci_remove_xenstore(libxl__gc *gc, uint32_t domid= , libxl_device_pci *pci) { libxl_ctx *ctx =3D libxl__gc_owner(gc); char *be_path, *num_devs_path, *num_devs, *xsdev, *tmp, *tmppath; @@ -231,8 +231,8 @@ static int libxl__device_pci_remove_xenstore(libxl__gc = *gc, uint32_t domid, libx unsigned int domain =3D 0, bus =3D 0, dev =3D 0, func =3D 0; xsdev =3D libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/dev-%d", be_p= ath, i)); sscanf(xsdev, PCI_BDF, &domain, &bus, &dev, &func); - if (domain =3D=3D pcidev->domain && bus =3D=3D pcidev->bus && - pcidev->dev =3D=3D dev && pcidev->func =3D=3D func) { + if (domain =3D=3D pci->domain && bus =3D=3D pci->bus && + pci->dev =3D=3D dev && pci->func =3D=3D func) { break; } } @@ -350,7 +350,7 @@ static int get_all_assigned_devices(libxl__gc *gc, libx= l_device_pci **list, int *list =3D realloc(*list, sizeof(libxl_device_pci) * ((= *num) + 1)); if (*list =3D=3D NULL) return ERROR_NOMEM; - pcidev_struct_fill(*list + *num, dom, bus, dev, func, = 0); + pci_struct_fill(*list + *num, dom, bus, dev, func, 0); (*num)++; } } @@ -361,8 +361,8 @@ static int get_all_assigned_devices(libxl__gc *gc, libx= l_device_pci **list, int return 0; } =20 -static int is_pcidev_in_array(libxl_device_pci *assigned, int num_assigned, - int dom, int bus, int dev, int func) +static int is_pci_in_array(libxl_device_pci *assigned, int num_assigned, + int dom, int bus, int dev, int func) { int i; =20 @@ -383,7 +383,7 @@ static int is_pcidev_in_array(libxl_device_pci *assigne= d, int num_assigned, =20 /* Write the standard BDF into the sysfs path given by sysfs_path. */ static int sysfs_write_bdf(libxl__gc *gc, const char * sysfs_path, - libxl_device_pci *pcidev) + libxl_device_pci *pci) { int rc, fd; char *buf; @@ -394,8 +394,8 @@ static int sysfs_write_bdf(libxl__gc *gc, const char * = sysfs_path, return ERROR_FAIL; } =20 - buf =3D GCSPRINTF(PCI_BDF, pcidev->domain, pcidev->bus, - pcidev->dev, pcidev->func); + buf =3D GCSPRINTF(PCI_BDF, pci->domain, pci->bus, + pci->dev, pci->func); rc =3D write(fd, buf, strlen(buf)); /* Annoying to have two if's, but we need the errno */ if (rc < 0) @@ -411,7 +411,7 @@ static int sysfs_write_bdf(libxl__gc *gc, const char * = sysfs_path, libxl_device_pci *libxl_device_pci_assignable_list(libxl_ctx *ctx, int *nu= m) { GC_INIT(ctx); - libxl_device_pci *pcidevs =3D NULL, *new, *assigned; + libxl_device_pci *pcis =3D NULL, *new, *assigned; struct dirent *de; DIR *dir; int r, num_assigned; @@ -436,40 +436,40 @@ libxl_device_pci *libxl_device_pci_assignable_list(li= bxl_ctx *ctx, int *num) if (sscanf(de->d_name, PCI_BDF, &dom, &bus, &dev, &func) !=3D 4) continue; =20 - if (is_pcidev_in_array(assigned, num_assigned, dom, bus, dev, func= )) + if (is_pci_in_array(assigned, num_assigned, dom, bus, dev, func)) continue; =20 - new =3D realloc(pcidevs, ((*num) + 1) * sizeof(*new)); + new =3D realloc(pcis, ((*num) + 1) * sizeof(*new)); if (NULL =3D=3D new) continue; =20 - pcidevs =3D new; - new =3D pcidevs + *num; + pcis =3D new; + new =3D pcis + *num; =20 memset(new, 0, sizeof(*new)); - pcidev_struct_fill(new, dom, bus, dev, func, 0); + pci_struct_fill(new, dom, bus, dev, func, 0); (*num)++; } =20 closedir(dir); out: GC_FREE; - return pcidevs; + return pcis; } =20 /* Unbind device from its current driver, if any. If driver_path is non-N= ULL, * store the path to the original driver in it. */ -static int sysfs_dev_unbind(libxl__gc *gc, libxl_device_pci *pcidev, +static int sysfs_dev_unbind(libxl__gc *gc, libxl_device_pci *pci, char **driver_path) { char * spath, *dp =3D NULL; struct stat st; =20 spath =3D GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/driver", - pcidev->domain, - pcidev->bus, - pcidev->dev, - pcidev->func); + pci->domain, + pci->bus, + pci->dev, + pci->func); if ( !lstat(spath, &st) ) { /* Find the canonical path to the driver. */ dp =3D libxl__zalloc(gc, PATH_MAX); @@ -483,7 +483,7 @@ static int sysfs_dev_unbind(libxl__gc *gc, libxl_device= _pci *pcidev, =20 /* Unbind from the old driver */ spath =3D GCSPRINTF("%s/unbind", dp); - if ( sysfs_write_bdf(gc, spath, pcidev) < 0 ) { + if ( sysfs_write_bdf(gc, spath, pci) < 0 ) { LOGE(ERROR, "Couldn't unbind device"); return -1; } @@ -495,11 +495,11 @@ static int sysfs_dev_unbind(libxl__gc *gc, libxl_devi= ce_pci *pcidev, return 0; } =20 -static uint16_t sysfs_dev_get_vendor(libxl__gc *gc, libxl_device_pci *pcid= ev) +static uint16_t sysfs_dev_get_vendor(libxl__gc *gc, libxl_device_pci *pci) { char *pci_device_vendor_path =3D GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/vendor", - pcidev->domain, pcidev->bus, pcidev->dev, pcidev->fu= nc); + pci->domain, pci->bus, pci->dev, pci->func); uint16_t read_items; uint16_t pci_device_vendor; =20 @@ -507,7 +507,7 @@ static uint16_t sysfs_dev_get_vendor(libxl__gc *gc, lib= xl_device_pci *pcidev) if (!f) { LOGE(ERROR, "pci device "PCI_BDF" does not have vendor attribute", - pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func); + pci->domain, pci->bus, pci->dev, pci->func); return 0xffff; } read_items =3D fscanf(f, "0x%hx\n", &pci_device_vendor); @@ -515,18 +515,18 @@ static uint16_t sysfs_dev_get_vendor(libxl__gc *gc, l= ibxl_device_pci *pcidev) if (read_items !=3D 1) { LOGE(ERROR, "cannot read vendor of pci device "PCI_BDF, - pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func); + pci->domain, pci->bus, pci->dev, pci->func); return 0xffff; } =20 return pci_device_vendor; } =20 -static uint16_t sysfs_dev_get_device(libxl__gc *gc, libxl_device_pci *pcid= ev) +static uint16_t sysfs_dev_get_device(libxl__gc *gc, libxl_device_pci *pci) { char *pci_device_device_path =3D GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/device", - pcidev->domain, pcidev->bus, pcidev->dev, pcidev->fu= nc); + pci->domain, pci->bus, pci->dev, pci->func); uint16_t read_items; uint16_t pci_device_device; =20 @@ -534,7 +534,7 @@ static uint16_t sysfs_dev_get_device(libxl__gc *gc, lib= xl_device_pci *pcidev) if (!f) { LOGE(ERROR, "pci device "PCI_BDF" does not have device attribute", - pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func); + pci->domain, pci->bus, pci->dev, pci->func); return 0xffff; } read_items =3D fscanf(f, "0x%hx\n", &pci_device_device); @@ -542,25 +542,25 @@ static uint16_t sysfs_dev_get_device(libxl__gc *gc, l= ibxl_device_pci *pcidev) if (read_items !=3D 1) { LOGE(ERROR, "cannot read device of pci device "PCI_BDF, - pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func); + pci->domain, pci->bus, pci->dev, pci->func); return 0xffff; } =20 return pci_device_device; } =20 -static int sysfs_dev_get_class(libxl__gc *gc, libxl_device_pci *pcidev, +static int sysfs_dev_get_class(libxl__gc *gc, libxl_device_pci *pci, unsigned long *class) { char *pci_device_class_path =3D GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/cla= ss", - pcidev->domain, pcidev->bus, pcidev->dev, pcidev->fun= c); + pci->domain, pci->bus, pci->dev, pci->func); int read_items, ret =3D 0; =20 FILE *f =3D fopen(pci_device_class_path, "r"); if (!f) { LOGE(ERROR, "pci device "PCI_BDF" does not have class attribute", - pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func); + pci->domain, pci->bus, pci->dev, pci->func); ret =3D ERROR_FAIL; goto out; } @@ -569,7 +569,7 @@ static int sysfs_dev_get_class(libxl__gc *gc, libxl_dev= ice_pci *pcidev, if (read_items !=3D 1) { LOGE(ERROR, "cannot read class of pci device "PCI_BDF, - pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func); + pci->domain, pci->bus, pci->dev, pci->func); ret =3D ERROR_FAIL; } =20 @@ -589,15 +589,15 @@ bool libxl__is_igd_vga_passthru(libxl__gc *gc, unsigned long class; =20 for (i =3D 0 ; i < d_config->num_pcidevs ; i++) { - libxl_device_pci *pcidev =3D &d_config->pcidevs[i]; - pt_vendor =3D sysfs_dev_get_vendor(gc, pcidev); - pt_device =3D sysfs_dev_get_device(gc, pcidev); + libxl_device_pci *pci =3D &d_config->pcidevs[i]; + pt_vendor =3D sysfs_dev_get_vendor(gc, pci); + pt_device =3D sysfs_dev_get_device(gc, pci); =20 if (pt_vendor =3D=3D 0xffff || pt_device =3D=3D 0xffff || pt_vendor !=3D 0x8086) continue; =20 - if (sysfs_dev_get_class(gc, pcidev, &class)) + if (sysfs_dev_get_class(gc, pci, &class)) continue; if (class =3D=3D 0x030000) return true; @@ -621,8 +621,8 @@ bool libxl__is_igd_vga_passthru(libxl__gc *gc, * already exist. */ =20 -/* Scan through /sys/.../pciback/slots looking for pcidev's BDF */ -static int pciback_dev_has_slot(libxl__gc *gc, libxl_device_pci *pcidev) +/* Scan through /sys/.../pciback/slots looking for pci's BDF */ +static int pciback_dev_has_slot(libxl__gc *gc, libxl_device_pci *pci) { FILE *f; int rc =3D 0; @@ -635,11 +635,11 @@ static int pciback_dev_has_slot(libxl__gc *gc, libxl_= device_pci *pcidev) return ERROR_FAIL; } =20 - while(fscanf(f, "%x:%x:%x.%d\n", &dom, &bus, &dev, &func)=3D=3D4) { - if(dom =3D=3D pcidev->domain - && bus =3D=3D pcidev->bus - && dev =3D=3D pcidev->dev - && func =3D=3D pcidev->func) { + while (fscanf(f, "%x:%x:%x.%d\n", &dom, &bus, &dev, &func) =3D=3D 4) { + if (dom =3D=3D pci->domain + && bus =3D=3D pci->bus + && dev =3D=3D pci->dev + && func =3D=3D pci->func) { rc =3D 1; goto out; } @@ -649,7 +649,7 @@ out: return rc; } =20 -static int pciback_dev_is_assigned(libxl__gc *gc, libxl_device_pci *pcidev) +static int pciback_dev_is_assigned(libxl__gc *gc, libxl_device_pci *pci) { char * spath; int rc; @@ -665,8 +665,8 @@ static int pciback_dev_is_assigned(libxl__gc *gc, libxl= _device_pci *pcidev) } =20 spath =3D GCSPRINTF(SYSFS_PCIBACK_DRIVER"/"PCI_BDF, - pcidev->domain, pcidev->bus, - pcidev->dev, pcidev->func); + pci->domain, pci->bus, + pci->dev, pci->func); rc =3D lstat(spath, &st); =20 if( rc =3D=3D 0 ) @@ -677,40 +677,40 @@ static int pciback_dev_is_assigned(libxl__gc *gc, lib= xl_device_pci *pcidev) return -1; } =20 -static int pciback_dev_assign(libxl__gc *gc, libxl_device_pci *pcidev) +static int pciback_dev_assign(libxl__gc *gc, libxl_device_pci *pci) { int rc; =20 - if ( (rc=3Dpciback_dev_has_slot(gc, pcidev)) < 0 ) { + if ( (rc =3D pciback_dev_has_slot(gc, pci)) < 0 ) { LOGE(ERROR, "Error checking for pciback slot"); return ERROR_FAIL; } else if (rc =3D=3D 0) { if ( sysfs_write_bdf(gc, SYSFS_PCIBACK_DRIVER"/new_slot", - pcidev) < 0 ) { + pci) < 0 ) { LOGE(ERROR, "Couldn't bind device to pciback!"); return ERROR_FAIL; } } =20 - if ( sysfs_write_bdf(gc, SYSFS_PCIBACK_DRIVER"/bind", pcidev) < 0 ) { + if ( sysfs_write_bdf(gc, SYSFS_PCIBACK_DRIVER"/bind", pci) < 0 ) { LOGE(ERROR, "Couldn't bind device to pciback!"); return ERROR_FAIL; } return 0; } =20 -static int pciback_dev_unassign(libxl__gc *gc, libxl_device_pci *pcidev) +static int pciback_dev_unassign(libxl__gc *gc, libxl_device_pci *pci) { /* Remove from pciback */ - if ( sysfs_dev_unbind(gc, pcidev, NULL) < 0 ) { + if ( sysfs_dev_unbind(gc, pci, NULL) < 0 ) { LOG(ERROR, "Couldn't unbind device!"); return ERROR_FAIL; } =20 /* Remove slot if necessary */ - if ( pciback_dev_has_slot(gc, pcidev) > 0 ) { + if ( pciback_dev_has_slot(gc, pci) > 0 ) { if ( sysfs_write_bdf(gc, SYSFS_PCIBACK_DRIVER"/remove_slot", - pcidev) < 0 ) { + pci) < 0 ) { LOGE(ERROR, "Couldn't remove pciback slot"); return ERROR_FAIL; } @@ -721,49 +721,49 @@ static int pciback_dev_unassign(libxl__gc *gc, libxl_= device_pci *pcidev) #define PCIBACK_INFO_PATH "/libxl/pciback" =20 static void pci_assignable_driver_path_write(libxl__gc *gc, - libxl_device_pci *pcidev, + libxl_device_pci *pci, char *driver_path) { char *path; =20 path =3D GCSPRINTF(PCIBACK_INFO_PATH"/"PCI_BDF_XSPATH"/driver_path", - pcidev->domain, - pcidev->bus, - pcidev->dev, - pcidev->func); + pci->domain, + pci->bus, + pci->dev, + pci->func); if ( libxl__xs_printf(gc, XBT_NULL, path, "%s", driver_path) < 0 ) { LOGE(WARN, "Write of %s to node %s failed.", driver_path, path); } } =20 static char * pci_assignable_driver_path_read(libxl__gc *gc, - libxl_device_pci *pcidev) + libxl_device_pci *pci) { return libxl__xs_read(gc, XBT_NULL, GCSPRINTF( PCIBACK_INFO_PATH "/" PCI_BDF_XSPATH "/driver_p= ath", - pcidev->domain, - pcidev->bus, - pcidev->dev, - pcidev->func)); + pci->domain, + pci->bus, + pci->dev, + pci->func)); } =20 static void pci_assignable_driver_path_remove(libxl__gc *gc, - libxl_device_pci *pcidev) + libxl_device_pci *pci) { libxl_ctx *ctx =3D libxl__gc_owner(gc); =20 /* Remove the xenstore entry */ xs_rm(ctx->xsh, XBT_NULL, GCSPRINTF(PCIBACK_INFO_PATH "/" PCI_BDF_XSPATH, - pcidev->domain, - pcidev->bus, - pcidev->dev, - pcidev->func) ); + pci->domain, + pci->bus, + pci->dev, + pci->func) ); } =20 static int libxl__device_pci_assignable_add(libxl__gc *gc, - libxl_device_pci *pcidev, + libxl_device_pci *pci, int rebind) { libxl_ctx *ctx =3D libxl__gc_owner(gc); @@ -773,10 +773,10 @@ static int libxl__device_pci_assignable_add(libxl__gc= *gc, struct stat st; =20 /* Local copy for convenience */ - dom =3D pcidev->domain; - bus =3D pcidev->bus; - dev =3D pcidev->dev; - func =3D pcidev->func; + dom =3D pci->domain; + bus =3D pci->bus; + dev =3D pci->dev; + func =3D pci->func; =20 /* See if the device exists */ spath =3D GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF, dom, bus, dev, func); @@ -786,7 +786,7 @@ static int libxl__device_pci_assignable_add(libxl__gc *= gc, } =20 /* Check to see if it's already assigned to pciback */ - rc =3D pciback_dev_is_assigned(gc, pcidev); + rc =3D pciback_dev_is_assigned(gc, pci); if ( rc < 0 ) { return ERROR_FAIL; } @@ -796,7 +796,7 @@ static int libxl__device_pci_assignable_add(libxl__gc *= gc, } =20 /* Check to see if there's already a driver that we need to unbind fro= m */ - if ( sysfs_dev_unbind(gc, pcidev, &driver_path ) ) { + if ( sysfs_dev_unbind(gc, pci, &driver_path ) ) { LOG(ERROR, "Couldn't unbind "PCI_BDF" from driver", dom, bus, dev, func); return ERROR_FAIL; @@ -805,9 +805,9 @@ static int libxl__device_pci_assignable_add(libxl__gc *= gc, /* Store driver_path for rebinding to dom0 */ if ( rebind ) { if ( driver_path ) { - pci_assignable_driver_path_write(gc, pcidev, driver_path); + pci_assignable_driver_path_write(gc, pci, driver_path); } else if ( (driver_path =3D - pci_assignable_driver_path_read(gc, pcidev)) !=3D NUL= L ) { + pci_assignable_driver_path_read(gc, pci)) !=3D NULL )= { LOG(INFO, PCI_BDF" not bound to a driver, will be rebound to %= s", dom, bus, dev, func, driver_path); } else { @@ -815,10 +815,10 @@ static int libxl__device_pci_assignable_add(libxl__gc= *gc, dom, bus, dev, func); } } else { - pci_assignable_driver_path_remove(gc, pcidev); + pci_assignable_driver_path_remove(gc, pci); } =20 - if ( pciback_dev_assign(gc, pcidev) ) { + if ( pciback_dev_assign(gc, pci) ) { LOG(ERROR, "Couldn't bind device to pciback!"); return ERROR_FAIL; } @@ -829,7 +829,7 @@ quarantine: * so always pass XEN_DOMCTL_DEV_RDM_RELAXED to avoid assignment being * unnecessarily denied. */ - rc =3D xc_assign_device(ctx->xch, DOMID_IO, pcidev_encode_bdf(pcidev), + rc =3D xc_assign_device(ctx->xch, DOMID_IO, pci_encode_bdf(pci), XEN_DOMCTL_DEV_RDM_RELAXED); if ( rc < 0 ) { LOG(ERROR, "failed to quarantine "PCI_BDF, dom, bus, dev, func); @@ -840,7 +840,7 @@ quarantine: } =20 static int libxl__device_pci_assignable_remove(libxl__gc *gc, - libxl_device_pci *pcidev, + libxl_device_pci *pci, int rebind) { libxl_ctx *ctx =3D libxl__gc_owner(gc); @@ -848,24 +848,24 @@ static int libxl__device_pci_assignable_remove(libxl_= _gc *gc, char *driver_path; =20 /* De-quarantine */ - rc =3D xc_deassign_device(ctx->xch, DOMID_IO, pcidev_encode_bdf(pcidev= )); + rc =3D xc_deassign_device(ctx->xch, DOMID_IO, pci_encode_bdf(pci)); if ( rc < 0 ) { - LOG(ERROR, "failed to de-quarantine "PCI_BDF, pcidev->domain, pcid= ev->bus, - pcidev->dev, pcidev->func); + LOG(ERROR, "failed to de-quarantine "PCI_BDF, pci->domain, pci->bu= s, + pci->dev, pci->func); return ERROR_FAIL; } =20 /* Unbind from pciback */ - if ( (rc=3Dpciback_dev_is_assigned(gc, pcidev)) < 0 ) { + if ( (rc =3D pciback_dev_is_assigned(gc, pci)) < 0 ) { return ERROR_FAIL; } else if ( rc ) { - pciback_dev_unassign(gc, pcidev); + pciback_dev_unassign(gc, pci); } else { LOG(WARN, "Not bound to pciback"); } =20 /* Rebind if necessary */ - driver_path =3D pci_assignable_driver_path_read(gc, pcidev); + driver_path =3D pci_assignable_driver_path_read(gc, pci); =20 if ( driver_path ) { if ( rebind ) { @@ -873,12 +873,12 @@ static int libxl__device_pci_assignable_remove(libxl_= _gc *gc, =20 if ( sysfs_write_bdf(gc, GCSPRINTF("%s/bind", driver_path), - pcidev) < 0 ) { + pci) < 0 ) { LOGE(ERROR, "Couldn't bind device to %s", driver_path); return -1; } =20 - pci_assignable_driver_path_remove(gc, pcidev); + pci_assignable_driver_path_remove(gc, pci); } } else { if ( rebind ) { @@ -890,26 +890,26 @@ static int libxl__device_pci_assignable_remove(libxl_= _gc *gc, return 0; } =20 -int libxl_device_pci_assignable_add(libxl_ctx *ctx, libxl_device_pci *pcid= ev, +int libxl_device_pci_assignable_add(libxl_ctx *ctx, libxl_device_pci *pci, int rebind) { GC_INIT(ctx); int rc; =20 - rc =3D libxl__device_pci_assignable_add(gc, pcidev, rebind); + rc =3D libxl__device_pci_assignable_add(gc, pci, rebind); =20 GC_FREE; return rc; } =20 =20 -int libxl_device_pci_assignable_remove(libxl_ctx *ctx, libxl_device_pci *p= cidev, +int libxl_device_pci_assignable_remove(libxl_ctx *ctx, libxl_device_pci *p= ci, int rebind) { GC_INIT(ctx); int rc; =20 - rc =3D libxl__device_pci_assignable_remove(gc, pcidev, rebind); + rc =3D libxl__device_pci_assignable_remove(gc, pci, rebind); =20 GC_FREE; return rc; @@ -920,7 +920,7 @@ int libxl_device_pci_assignable_remove(libxl_ctx *ctx, = libxl_device_pci *pcidev, * driver. It also initialises a bit-mask of which function numbers are pr= esent * on that device. */ -static int pci_multifunction_check(libxl__gc *gc, libxl_device_pci *pcidev= , unsigned int *func_mask) +static int pci_multifunction_check(libxl__gc *gc, libxl_device_pci *pci, u= nsigned int *func_mask) { struct dirent *de; DIR *dir; @@ -940,11 +940,11 @@ static int pci_multifunction_check(libxl__gc *gc, lib= xl_device_pci *pcidev, unsi =20 if ( sscanf(de->d_name, PCI_BDF, &dom, &bus, &dev, &func) !=3D 4 ) continue; - if ( pcidev->domain !=3D dom ) + if ( pci->domain !=3D dom ) continue; - if ( pcidev->bus !=3D bus ) + if ( pci->bus !=3D bus ) continue; - if ( pcidev->dev !=3D dev ) + if ( pci->dev !=3D dev ) continue; =20 path =3D GCSPRINTF("%s/" PCI_BDF, SYSFS_PCIBACK_DRIVER, dom, bus, = dev, func); @@ -979,7 +979,7 @@ static int pci_ins_check(libxl__gc *gc, uint32_t domid,= const char *state, void } =20 static int qemu_pci_add_xenstore(libxl__gc *gc, uint32_t domid, - libxl_device_pci *pcidev) + libxl_device_pci *pci) { libxl_ctx *ctx =3D libxl__gc_owner(gc); int rc =3D 0; @@ -991,15 +991,15 @@ static int qemu_pci_add_xenstore(libxl__gc *gc, uint3= 2_t domid, path =3D DEVICE_MODEL_XS_PATH(gc, dm_domid, domid, "/state"); state =3D libxl__xs_read(gc, XBT_NULL, path); path =3D DEVICE_MODEL_XS_PATH(gc, dm_domid, domid, "/parameter"); - if (pcidev->vdevfn) { + if (pci->vdevfn) { libxl__xs_printf(gc, XBT_NULL, path, PCI_BDF_VDEVFN","PCI_OPTIONS, - pcidev->domain, pcidev->bus, pcidev->dev, - pcidev->func, pcidev->vdevfn, pcidev->msitranslat= e, - pcidev->power_mgmt); + pci->domain, pci->bus, pci->dev, + pci->func, pci->vdevfn, pci->msitranslate, + pci->power_mgmt); } else { libxl__xs_printf(gc, XBT_NULL, path, PCI_BDF","PCI_OPTIONS, - pcidev->domain, pcidev->bus, pcidev->dev, - pcidev->func, pcidev->msitranslate, pcidev->power= _mgmt); + pci->domain, pci->bus, pci->dev, + pci->func, pci->msitranslate, pci->power_mgmt); } =20 libxl__qemu_traditional_cmd(gc, domid, "pci-ins"); @@ -1010,7 +1010,7 @@ static int qemu_pci_add_xenstore(libxl__gc *gc, uint3= 2_t domid, path =3D DEVICE_MODEL_XS_PATH(gc, dm_domid, domid, "/state"); if ( rc < 0 ) LOGD(ERROR, domid, "qemu refused to add device: %s", vdevfn); - else if ( sscanf(vdevfn, "0x%x", &pcidev->vdevfn) !=3D 1 ) { + else if ( sscanf(vdevfn, "0x%x", &pci->vdevfn) !=3D 1 ) { LOGD(ERROR, domid, "wrong format for the vdevfn: '%s'", vdevfn); rc =3D -1; } @@ -1054,7 +1054,7 @@ typedef struct pci_add_state { libxl__xswait_state xswait; libxl__ev_qmp qmp; libxl__ev_time timeout; - libxl_device_pci *pcidev; + libxl_device_pci *pci; int pci_domid; } pci_add_state; =20 @@ -1072,7 +1072,7 @@ static void pci_add_dm_done(libxl__egc *, =20 static void do_pci_add(libxl__egc *egc, libxl_domid domid, - libxl_device_pci *pcidev, + libxl_device_pci *pci, pci_add_state *pas) { STATE_AO_GC(pas->aodev->ao); @@ -1082,7 +1082,7 @@ static void do_pci_add(libxl__egc *egc, /* init pci_add_state */ libxl__xswait_init(&pas->xswait); libxl__ev_qmp_init(&pas->qmp); - pas->pcidev =3D pcidev; + pas->pci =3D pci; pas->pci_domid =3D domid; libxl__ev_time_init(&pas->timeout); =20 @@ -1128,7 +1128,7 @@ static void pci_add_qemu_trad_watch_state_cb(libxl__e= gc *egc, =20 /* Convenience aliases */ libxl_domid domid =3D pas->domid; - libxl_device_pci *pcidev =3D pas->pcidev; + libxl_device_pci *pci =3D pas->pci; =20 rc =3D check_qemu_running(gc, domid, xswa, rc, state); if (rc =3D=3D ERROR_NOT_READY) @@ -1136,7 +1136,7 @@ static void pci_add_qemu_trad_watch_state_cb(libxl__e= gc *egc, if (rc) goto out; =20 - rc =3D qemu_pci_add_xenstore(gc, domid, pcidev); + rc =3D qemu_pci_add_xenstore(gc, domid, pci); out: pci_add_dm_done(egc, pas, rc); /* must be last */ } @@ -1149,7 +1149,7 @@ static void pci_add_qmp_device_add(libxl__egc *egc, p= ci_add_state *pas) =20 /* Convenience aliases */ libxl_domid domid =3D pas->domid; - libxl_device_pci *pcidev =3D pas->pcidev; + libxl_device_pci *pci =3D pas->pci; libxl__ev_qmp *const qmp =3D &pas->qmp; =20 rc =3D libxl__ev_time_register_rel(ao, &pas->timeout, @@ -1160,14 +1160,14 @@ static void pci_add_qmp_device_add(libxl__egc *egc,= pci_add_state *pas) libxl__qmp_param_add_string(gc, &args, "driver", "xen-pci-passthrough"); QMP_PARAMETERS_SPRINTF(&args, "id", PCI_PT_QDEV_ID, - pcidev->bus, pcidev->dev, pcidev->func); + pci->bus, pci->dev, pci->func); QMP_PARAMETERS_SPRINTF(&args, "hostaddr", - "%04x:%02x:%02x.%01x", pcidev->domain, - pcidev->bus, pcidev->dev, pcidev->func); - if (pcidev->vdevfn) { + "%04x:%02x:%02x.%01x", pci->domain, + pci->bus, pci->dev, pci->func); + if (pci->vdevfn) { QMP_PARAMETERS_SPRINTF(&args, "addr", "%x.%x", - PCI_SLOT(pcidev->vdevfn), - PCI_FUNC(pcidev->vdevfn)); + PCI_SLOT(pci->vdevfn), + PCI_FUNC(pci->vdevfn)); } /* * Version of QEMU prior to the XSA-131 fix did not support @@ -1179,7 +1179,7 @@ static void pci_add_qmp_device_add(libxl__egc *egc, p= ci_add_state *pas) * set the permissive flag if it is true. Users of older QEMU * have no reason to set the flag so this is ok. */ - if (pcidev->permissive) + if (pci->permissive) libxl__qmp_param_add_bool(gc, &args, "permissive", true); =20 qmp->ao =3D pas->aodev->ao; @@ -1230,7 +1230,7 @@ static void pci_add_qmp_query_pci_cb(libxl__egc *egc, int dev_slot, dev_func; =20 /* Convenience aliases */ - libxl_device_pci *pcidev =3D pas->pcidev; + libxl_device_pci *pci =3D pas->pci; =20 if (rc) goto out; =20 @@ -1251,7 +1251,7 @@ static void pci_add_qmp_query_pci_cb(libxl__egc *egc, */ =20 asked_id =3D GCSPRINTF(PCI_PT_QDEV_ID, - pcidev->bus, pcidev->dev, pcidev->func); + pci->bus, pci->dev, pci->func); =20 for (i =3D 0; (bus =3D libxl__json_array_get(response, i)); i++) { devices =3D libxl__json_map_get("devices", bus, JSON_ARRAY); @@ -1283,7 +1283,7 @@ static void pci_add_qmp_query_pci_cb(libxl__egc *egc, } dev_func =3D libxl__json_object_get_integer(o); =20 - pcidev->vdevfn =3D PCI_DEVFN(dev_slot, dev_func); + pci->vdevfn =3D PCI_DEVFN(dev_slot, dev_func); =20 rc =3D 0; goto out; @@ -1331,7 +1331,7 @@ static void pci_add_dm_done(libxl__egc *egc, =20 /* Convenience aliases */ bool starting =3D pas->starting; - libxl_device_pci *pcidev =3D pas->pcidev; + libxl_device_pci *pci =3D pas->pci; bool hvm =3D libxl__domain_type(gc, domid) =3D=3D LIBXL_DOMAIN_TYPE_HV= M; =20 libxl__ev_qmp_dispose(gc, &pas->qmp); @@ -1342,8 +1342,8 @@ static void pci_add_dm_done(libxl__egc *egc, if (isstubdom) starting =3D false; =20 - sysfs_path =3D GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/resource", pcidev->d= omain, - pcidev->bus, pcidev->dev, pcidev->func); + sysfs_path =3D GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/resource", pci->doma= in, + pci->bus, pci->dev, pci->func); f =3D fopen(sysfs_path, "r"); start =3D end =3D flags =3D size =3D 0; irq =3D 0; @@ -1383,8 +1383,8 @@ static void pci_add_dm_done(libxl__egc *egc, } } fclose(f); - sysfs_path =3D GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/irq", pcidev->domain, - pcidev->bus, pcidev->dev, pcidev->func); + sysfs_path =3D GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/irq", pci->domain, + pci->bus, pci->dev, pci->func); f =3D fopen(sysfs_path, "r"); if (f =3D=3D NULL) { LOGED(ERROR, domainid, "Couldn't open %s", sysfs_path); @@ -1411,9 +1411,9 @@ static void pci_add_dm_done(libxl__egc *egc, fclose(f); =20 /* Don't restrict writes to the PCI config space from this VM */ - if (pcidev->permissive) { + if (pci->permissive) { if ( sysfs_write_bdf(gc, SYSFS_PCIBACK_DRIVER"/permissive", - pcidev) < 0 ) { + pci) < 0 ) { LOGD(ERROR, domainid, "Setting permissive for device"); rc =3D ERROR_FAIL; goto out; @@ -1422,14 +1422,14 @@ static void pci_add_dm_done(libxl__egc *egc, =20 out_no_irq: if (!isstubdom) { - if (pcidev->rdm_policy =3D=3D LIBXL_RDM_RESERVE_POLICY_STRICT) { + if (pci->rdm_policy =3D=3D LIBXL_RDM_RESERVE_POLICY_STRICT) { flag &=3D ~XEN_DOMCTL_DEV_RDM_RELAXED; - } else if (pcidev->rdm_policy !=3D LIBXL_RDM_RESERVE_POLICY_RELAXE= D) { + } else if (pci->rdm_policy !=3D LIBXL_RDM_RESERVE_POLICY_RELAXED) { LOGED(ERROR, domainid, "unknown rdm check flag."); rc =3D ERROR_FAIL; goto out; } - r =3D xc_assign_device(ctx->xch, domid, pcidev_encode_bdf(pcidev),= flag); + r =3D xc_assign_device(ctx->xch, domid, pci_encode_bdf(pci), flag); if (r < 0 && (hvm || errno !=3D ENOSYS)) { LOGED(ERROR, domainid, "xc_assign_device failed"); rc =3D ERROR_FAIL; @@ -1438,7 +1438,7 @@ out_no_irq: } =20 if (!starting && !libxl_get_stubdom_id(CTX, domid)) - rc =3D libxl__device_pci_add_xenstore(gc, domid, pcidev, starting); + rc =3D libxl__device_pci_add_xenstore(gc, domid, pci, starting); else rc =3D 0; out: @@ -1493,7 +1493,7 @@ int libxl__device_pci_setdefault(libxl__gc *gc, uint3= 2_t domid, } =20 int libxl_device_pci_add(libxl_ctx *ctx, uint32_t domid, - libxl_device_pci *pcidev, + libxl_device_pci *pci, const libxl_asyncop_how *ao_how) { AO_CREATE(ctx, domid, ao_how); @@ -1504,24 +1504,24 @@ int libxl_device_pci_add(libxl_ctx *ctx, uint32_t d= omid, aodev->action =3D LIBXL__DEVICE_ACTION_ADD; aodev->callback =3D device_addrm_aocomplete; aodev->update_json =3D true; - libxl__device_pci_add(egc, domid, pcidev, false, aodev); + libxl__device_pci_add(egc, domid, pci, false, aodev); return AO_INPROGRESS; } =20 -static int libxl_pcidev_assignable(libxl_ctx *ctx, libxl_device_pci *pcide= v) +static int libxl_pci_assignable(libxl_ctx *ctx, libxl_device_pci *pci) { - libxl_device_pci *pcidevs; + libxl_device_pci *pcis; int num, i; =20 - pcidevs =3D libxl_device_pci_assignable_list(ctx, &num); + pcis =3D libxl_device_pci_assignable_list(ctx, &num); for (i =3D 0; i < num; i++) { - if (pcidevs[i].domain =3D=3D pcidev->domain && - pcidevs[i].bus =3D=3D pcidev->bus && - pcidevs[i].dev =3D=3D pcidev->dev && - pcidevs[i].func =3D=3D pcidev->func) + if (pcis[i].domain =3D=3D pci->domain && + pcis[i].bus =3D=3D pci->bus && + pcis[i].dev =3D=3D pci->dev && + pcis[i].func =3D=3D pci->func) break; } - free(pcidevs); + free(pcis); return i !=3D num; } =20 @@ -1535,7 +1535,7 @@ static void device_pci_add_done(libxl__egc *egc, pci_add_state *, int rc); =20 void libxl__device_pci_add(libxl__egc *egc, uint32_t domid, - libxl_device_pci *pcidev, bool starting, + libxl_device_pci *pci, bool starting, libxl__ao_device *aodev) { STATE_AO_GC(aodev->ao); @@ -1545,9 +1545,9 @@ void libxl__device_pci_add(libxl__egc *egc, uint32_t = domid, int stubdomid =3D 0; pci_add_state *pas; =20 - /* Store *pcidev to be used by callbacks */ - aodev->device_config =3D pcidev; - aodev->device_type =3D &libxl__pcidev_devtype; + /* Store *pci to be used by callbacks */ + aodev->device_config =3D pci; + aodev->device_type =3D &libxl__pci_devtype; =20 GCNEW(pas); pas->aodev =3D aodev; @@ -1556,29 +1556,29 @@ void libxl__device_pci_add(libxl__egc *egc, uint32_= t domid, pas->callback =3D device_pci_add_stubdom_done; =20 if (libxl__domain_type(gc, domid) =3D=3D LIBXL_DOMAIN_TYPE_HVM) { - rc =3D xc_test_assign_device(ctx->xch, domid, pcidev_encode_bdf(pc= idev)); + rc =3D xc_test_assign_device(ctx->xch, domid, pci_encode_bdf(pci)); if (rc) { LOGD(ERROR, domid, "PCI device %04x:%02x:%02x.%u %s?", - pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func, + pci->domain, pci->bus, pci->dev, pci->func, errno =3D=3D EOPNOTSUPP ? "cannot be assigned - no IOMMU" : "already assigned to a different guest"); goto out; } } =20 - rc =3D libxl__device_pci_setdefault(gc, domid, pcidev, !starting); + rc =3D libxl__device_pci_setdefault(gc, domid, pci, !starting); if (rc) goto out; =20 - if (pcidev->seize && !pciback_dev_is_assigned(gc, pcidev)) { - rc =3D libxl__device_pci_assignable_add(gc, pcidev, 1); + if (pci->seize && !pciback_dev_is_assigned(gc, pci)) { + rc =3D libxl__device_pci_assignable_add(gc, pci, 1); if ( rc ) goto out; } =20 - if (!libxl_pcidev_assignable(ctx, pcidev)) { + if (!libxl_pci_assignable(ctx, pci)) { LOGD(ERROR, domid, "PCI device %x:%x:%x.%x is not assignable", - pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func); + pci->domain, pci->bus, pci->dev, pci->func); rc =3D ERROR_FAIL; goto out; } @@ -1589,25 +1589,25 @@ void libxl__device_pci_add(libxl__egc *egc, uint32_= t domid, "cannot determine if device is assigned, refusing to continue= "); goto out; } - if ( is_pcidev_in_array(assigned, num_assigned, pcidev->domain, - pcidev->bus, pcidev->dev, pcidev->func) ) { + if ( is_pci_in_array(assigned, num_assigned, pci->domain, + pci->bus, pci->dev, pci->func) ) { LOGD(ERROR, domid, "PCI device already attached to a domain"); rc =3D ERROR_FAIL; goto out; } =20 - libxl__device_pci_reset(gc, pcidev->domain, pcidev->bus, pcidev->dev, = pcidev->func); + libxl__device_pci_reset(gc, pci->domain, pci->bus, pci->dev, pci->func= ); =20 stubdomid =3D libxl_get_stubdom_id(ctx, domid); if (stubdomid !=3D 0) { - libxl_device_pci *pcidev_s; + libxl_device_pci *pci_s; =20 - GCNEW(pcidev_s); - libxl_device_pci_init(pcidev_s); - libxl_device_pci_copy(CTX, pcidev_s, pcidev); + GCNEW(pci_s); + libxl_device_pci_init(pci_s); + libxl_device_pci_copy(CTX, pci_s, pci); pas->callback =3D device_pci_add_stubdom_wait; =20 - do_pci_add(egc, stubdomid, pcidev_s, pas); /* must be last */ + do_pci_add(egc, stubdomid, pci_s, pas); /* must be last */ return; } =20 @@ -1664,42 +1664,42 @@ static void device_pci_add_stubdom_done(libxl__egc = *egc, /* Convenience aliases */ libxl__ao_device *aodev =3D pas->aodev; libxl_domid domid =3D pas->domid; - libxl_device_pci *pcidev =3D aodev->device_config; + libxl_device_pci *pci =3D aodev->device_config; =20 if (rc) goto out; =20 - orig_vdev =3D pcidev->vdevfn & ~7U; + orig_vdev =3D pci->vdevfn & ~7U; =20 - if ( pcidev->vfunc_mask =3D=3D LIBXL_PCI_FUNC_ALL ) { - if ( !(pcidev->vdevfn >> 3) ) { + if ( pci->vfunc_mask =3D=3D LIBXL_PCI_FUNC_ALL ) { + if ( !(pci->vdevfn >> 3) ) { LOGD(ERROR, domid, "Must specify a v-slot for multi-function d= evices"); rc =3D ERROR_INVAL; goto out; } - if ( pci_multifunction_check(gc, pcidev, &pfunc_mask) ) { + if ( pci_multifunction_check(gc, pci, &pfunc_mask) ) { rc =3D ERROR_FAIL; goto out; } - pcidev->vfunc_mask &=3D pfunc_mask; + pci->vfunc_mask &=3D pfunc_mask; /* so now vfunc_mask =3D=3D pfunc_mask */ }else{ - pfunc_mask =3D (1 << pcidev->func); + pfunc_mask =3D (1 << pci->func); } =20 - for(rc =3D 0, i =3D 7; i >=3D 0; --i) { + for (rc =3D 0, i =3D 7; i >=3D 0; --i) { if ( (1 << i) & pfunc_mask ) { - if ( pcidev->vfunc_mask =3D=3D pfunc_mask ) { - pcidev->func =3D i; - pcidev->vdevfn =3D orig_vdev | i; - }else{ + if ( pci->vfunc_mask =3D=3D pfunc_mask ) { + pci->func =3D i; + pci->vdevfn =3D orig_vdev | i; + } else { /* if not passing through multiple devices in a block make * sure that virtual function number 0 is always used othe= rwise * guest won't see the device */ - pcidev->vdevfn =3D orig_vdev; + pci->vdevfn =3D orig_vdev; } pas->callback =3D device_pci_add_done; - do_pci_add(egc, domid, pcidev, pas); /* must be last */ + do_pci_add(egc, domid, pci, pas); /* must be last */ return; } } @@ -1715,13 +1715,13 @@ static void device_pci_add_done(libxl__egc *egc, EGC_GC; libxl__ao_device *aodev =3D pas->aodev; libxl_domid domid =3D pas->domid; - libxl_device_pci *pcidev =3D aodev->device_config; + libxl_device_pci *pci =3D aodev->device_config; =20 if (rc) { LOGD(ERROR, domid, "libxl__device_pci_add failed for " "PCI device %x:%x:%x.%x (rc %d)", - pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func, + pci->domain, pci->bus, pci->dev, pci->func, rc); } aodev->rc =3D rc; @@ -1733,16 +1733,16 @@ typedef struct { libxl__ao_device *outer_aodev; libxl_domain_config *d_config; libxl_domid domid; -} add_pcidevs_state; +} add_pcis_state; =20 -static void add_pcidevs_done(libxl__egc *, libxl__multidev *, int rc); +static void add_pcis_done(libxl__egc *, libxl__multidev *, int rc); =20 -static void libxl__add_pcidevs(libxl__egc *egc, libxl__ao *ao, uint32_t do= mid, - libxl_domain_config *d_config, - libxl__multidev *multidev) +static void libxl__add_pcis(libxl__egc *egc, libxl__ao *ao, uint32_t domid, + libxl_domain_config *d_config, + libxl__multidev *multidev) { AO_GC; - add_pcidevs_state *apds; + add_pcis_state *apds; int i; =20 /* We need to start a new multidev in order to be able to execute @@ -1752,7 +1752,7 @@ static void libxl__add_pcidevs(libxl__egc *egc, libxl= __ao *ao, uint32_t domid, apds->outer_aodev =3D libxl__multidev_prepare(multidev); apds->d_config =3D d_config; apds->domid =3D domid; - apds->multidev.callback =3D add_pcidevs_done; + apds->multidev.callback =3D add_pcis_done; libxl__multidev_begin(ao, &apds->multidev); =20 for (i =3D 0; i < d_config->num_pcidevs; i++) { @@ -1764,11 +1764,11 @@ static void libxl__add_pcidevs(libxl__egc *egc, lib= xl__ao *ao, uint32_t domid, libxl__multidev_prepared(egc, &apds->multidev, 0); } =20 -static void add_pcidevs_done(libxl__egc *egc, libxl__multidev *multidev, +static void add_pcis_done(libxl__egc *egc, libxl__multidev *multidev, int rc) { EGC_GC; - add_pcidevs_state *apds =3D CONTAINER_OF(multidev, *apds, multidev); + add_pcis_state *apds =3D CONTAINER_OF(multidev, *apds, multidev); =20 /* Convenience aliases */ libxl_domain_config *d_config =3D apds->d_config; @@ -1779,7 +1779,7 @@ static void add_pcidevs_done(libxl__egc *egc, libxl__= multidev *multidev, =20 if (d_config->num_pcidevs > 0 && !libxl_get_stubdom_id(CTX, domid)) { rc =3D libxl__create_pci_backend(gc, domid, d_config->pcidevs, - d_config->num_pcidevs); + d_config->num_pcidevs); if (rc < 0) { LOGD(ERROR, domid, "libxl_create_pci_backend failed: %d", rc); goto out; @@ -1792,7 +1792,7 @@ out: } =20 static int qemu_pci_remove_xenstore(libxl__gc *gc, uint32_t domid, - libxl_device_pci *pcidev, int force) + libxl_device_pci *pci, int force) { libxl_ctx *ctx =3D libxl__gc_owner(gc); char *state; @@ -1804,12 +1804,12 @@ static int qemu_pci_remove_xenstore(libxl__gc *gc, = uint32_t domid, path =3D DEVICE_MODEL_XS_PATH(gc, dm_domid, domid, "/state"); state =3D libxl__xs_read(gc, XBT_NULL, path); path =3D DEVICE_MODEL_XS_PATH(gc, dm_domid, domid, "/parameter"); - libxl__xs_printf(gc, XBT_NULL, path, PCI_BDF, pcidev->domain, - pcidev->bus, pcidev->dev, pcidev->func); + libxl__xs_printf(gc, XBT_NULL, path, PCI_BDF, pci->domain, + pci->bus, pci->dev, pci->func); =20 /* Remove all functions at once atomically by only signalling * device-model for function 0 */ - if ( !force && (pcidev->vdevfn & 0x7) =3D=3D 0 ) { + if ( !force && (pci->vdevfn & 0x7) =3D=3D 0 ) { libxl__qemu_traditional_cmd(gc, domid, "pci-rem"); if (libxl__wait_for_device_model_deprecated(gc, domid, "pci-remove= d", NULL, NULL, NULL) < 0) { @@ -1830,7 +1830,7 @@ static int qemu_pci_remove_xenstore(libxl__gc *gc, ui= nt32_t domid, typedef struct pci_remove_state { libxl__ao_device *aodev; libxl_domid domid; - libxl_device_pci *pcidev; + libxl_device_pci *pci; bool force; bool hvm; unsigned int orig_vdev; @@ -1844,7 +1844,7 @@ typedef struct pci_remove_state { } pci_remove_state; =20 static void libxl__device_pci_remove_common(libxl__egc *egc, - uint32_t domid, libxl_device_pci *pcidev, bool force, + uint32_t domid, libxl_device_pci *pci, bool force, libxl__ao_device *aodev); static void device_pci_remove_common_next(libxl__egc *egc, pci_remove_state *prs, int rc); @@ -1869,7 +1869,7 @@ static void pci_remove_done(libxl__egc *egc, pci_remove_state *prs, int rc); =20 static void do_pci_remove(libxl__egc *egc, uint32_t domid, - libxl_device_pci *pcidev, int force, + libxl_device_pci *pci, int force, pci_remove_state *prs) { STATE_AO_GC(prs->aodev->ao); @@ -1887,8 +1887,8 @@ static void do_pci_remove(libxl__egc *egc, uint32_t d= omid, libxl__ptr_add(gc, assigned); =20 rc =3D ERROR_INVAL; - if ( !is_pcidev_in_array(assigned, num, pcidev->domain, - pcidev->bus, pcidev->dev, pcidev->func) ) { + if ( !is_pci_in_array(assigned, num, pci->domain, + pci->bus, pci->dev, pci->func) ) { LOGD(ERROR, domainid, "PCI device not attached to this domain"); goto out_fail; } @@ -1917,8 +1917,8 @@ static void do_pci_remove(libxl__egc *egc, uint32_t d= omid, } else { assert(type =3D=3D LIBXL_DOMAIN_TYPE_PV); =20 - char *sysfs_path =3D GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/resource",= pcidev->domain, - pcidev->bus, pcidev->dev, pcidev->fun= c); + char *sysfs_path =3D GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/resource",= pci->domain, + pci->bus, pci->dev, pci->func); FILE *f =3D fopen(sysfs_path, "r"); unsigned int start =3D 0, end =3D 0, flags =3D 0, size =3D 0; int irq =3D 0; @@ -1953,8 +1953,8 @@ static void do_pci_remove(libxl__egc *egc, uint32_t d= omid, } fclose(f); skip1: - sysfs_path =3D GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/irq", pcidev->do= main, - pcidev->bus, pcidev->dev, pcidev->func); + sysfs_path =3D GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/irq", pci->domai= n, + pci->bus, pci->dev, pci->func); f =3D fopen(sysfs_path, "r"); if (f =3D=3D NULL) { LOGED(ERROR, domainid, "Couldn't open %s", sysfs_path); @@ -1988,7 +1988,7 @@ static void pci_remove_qemu_trad_watch_state_cb(libxl= __egc *egc, =20 /* Convenience aliases */ libxl_domid domid =3D prs->domid; - libxl_device_pci *const pcidev =3D prs->pcidev; + libxl_device_pci *const pci =3D prs->pci; =20 rc =3D check_qemu_running(gc, domid, xswa, rc, state); if (rc =3D=3D ERROR_NOT_READY) @@ -1996,7 +1996,7 @@ static void pci_remove_qemu_trad_watch_state_cb(libxl= __egc *egc, if (rc) goto out; =20 - rc =3D qemu_pci_remove_xenstore(gc, domid, pcidev, prs->force); + rc =3D qemu_pci_remove_xenstore(gc, domid, pci, prs->force); =20 out: pci_remove_detatched(egc, prs, rc); @@ -2010,7 +2010,7 @@ static void pci_remove_qmp_device_del(libxl__egc *egc, int rc; =20 /* Convenience aliases */ - libxl_device_pci *const pcidev =3D prs->pcidev; + libxl_device_pci *const pci =3D prs->pci; =20 rc =3D libxl__ev_time_register_rel(ao, &prs->timeout, pci_remove_timeout, @@ -2018,7 +2018,7 @@ static void pci_remove_qmp_device_del(libxl__egc *egc, if (rc) goto out; =20 QMP_PARAMETERS_SPRINTF(&args, "id", PCI_PT_QDEV_ID, - pcidev->bus, pcidev->dev, pcidev->func); + pci->bus, pci->dev, pci->func); prs->qmp.callback =3D pci_remove_qmp_device_del_cb; rc =3D libxl__ev_qmp_send(egc, &prs->qmp, "device_del", args); if (rc) goto out; @@ -2080,14 +2080,14 @@ static void pci_remove_qmp_query_cb(libxl__egc *egc, =20 /* Convenience aliases */ libxl__ao *const ao =3D prs->aodev->ao; - libxl_device_pci *const pcidev =3D prs->pcidev; + libxl_device_pci *const pci =3D prs->pci; =20 if (rc) goto out; =20 libxl__ev_qmp_dispose(gc, qmp); =20 asked_id =3D GCSPRINTF(PCI_PT_QDEV_ID, - pcidev->bus, pcidev->dev, pcidev->func); + pci->bus, pci->dev, pci->func); =20 /* query-pci response: * [{ 'devices': [ 'qdev_id': 'str', ... ], ... }] @@ -2135,10 +2135,10 @@ static void pci_remove_timeout(libxl__egc *egc, lib= xl__ev_time *ev, pci_remove_state *prs =3D CONTAINER_OF(ev, *prs, timeout); =20 /* Convenience aliases */ - libxl_device_pci *const pcidev =3D prs->pcidev; + libxl_device_pci *const pci =3D prs->pci; =20 LOGD(WARN, prs->domid, "timed out waiting for DM to remove " - PCI_PT_QDEV_ID, pcidev->bus, pcidev->dev, pcidev->func); + PCI_PT_QDEV_ID, pci->bus, pci->dev, pci->func); =20 /* If we timed out, we might still want to keep destroying the device * (when force=3D=3Dtrue), so let the next function decide what to do = on @@ -2156,7 +2156,7 @@ static void pci_remove_detatched(libxl__egc *egc, bool isstubdom; =20 /* Convenience aliases */ - libxl_device_pci *const pcidev =3D prs->pcidev; + libxl_device_pci *const pci =3D prs->pci; libxl_domid domid =3D prs->domid; =20 /* Cleaning QMP states ASAP */ @@ -2170,30 +2170,30 @@ static void pci_remove_detatched(libxl__egc *egc, isstubdom =3D libxl_is_stubdom(CTX, domid, &domainid); =20 /* don't do multiple resets while some functions are still passed thro= ugh */ - if ( (pcidev->vdevfn & 0x7) =3D=3D 0 ) { - libxl__device_pci_reset(gc, pcidev->domain, pcidev->bus, pcidev->d= ev, pcidev->func); + if ((pci->vdevfn & 0x7) =3D=3D 0) { + libxl__device_pci_reset(gc, pci->domain, pci->bus, pci->dev, pci->= func); } =20 if (!isstubdom) { - rc =3D xc_deassign_device(CTX->xch, domid, pcidev_encode_bdf(pcide= v)); + rc =3D xc_deassign_device(CTX->xch, domid, pci_encode_bdf(pci)); if (rc < 0 && (prs->hvm || errno !=3D ENOSYS)) LOGED(ERROR, domainid, "xc_deassign_device failed"); } =20 stubdomid =3D libxl_get_stubdom_id(CTX, domid); if (stubdomid !=3D 0) { - libxl_device_pci *pcidev_s; + libxl_device_pci *pci_s; libxl__ao_device *const stubdom_aodev =3D &prs->stubdom_aodev; =20 - GCNEW(pcidev_s); - libxl_device_pci_init(pcidev_s); - libxl_device_pci_copy(CTX, pcidev_s, pcidev); + GCNEW(pci_s); + libxl_device_pci_init(pci_s); + libxl_device_pci_copy(CTX, pci_s, pci); =20 libxl__prepare_ao_device(ao, stubdom_aodev); stubdom_aodev->action =3D LIBXL__DEVICE_ACTION_REMOVE; stubdom_aodev->callback =3D pci_remove_stubdom_done; stubdom_aodev->update_json =3D prs->aodev->update_json; - libxl__device_pci_remove_common(egc, stubdomid, pcidev_s, + libxl__device_pci_remove_common(egc, stubdomid, pci_s, prs->force, stubdom_aodev); return; } @@ -2219,14 +2219,14 @@ static void pci_remove_done(libxl__egc *egc, =20 if (rc) goto out; =20 - libxl__device_pci_remove_xenstore(gc, prs->domid, prs->pcidev); + libxl__device_pci_remove_xenstore(gc, prs->domid, prs->pci); out: device_pci_remove_common_next(egc, prs, rc); } =20 static void libxl__device_pci_remove_common(libxl__egc *egc, uint32_t domid, - libxl_device_pci *pcidev, + libxl_device_pci *pci, bool force, libxl__ao_device *aodev) { @@ -2237,7 +2237,7 @@ static void libxl__device_pci_remove_common(libxl__eg= c *egc, GCNEW(prs); prs->aodev =3D aodev; prs->domid =3D domid; - prs->pcidev =3D pcidev; + prs->pci =3D pci; prs->force =3D force; libxl__xswait_init(&prs->xswait); libxl__ev_qmp_init(&prs->qmp); @@ -2247,16 +2247,16 @@ static void libxl__device_pci_remove_common(libxl__= egc *egc, libxl__ev_time_init(&prs->timeout); libxl__ev_time_init(&prs->retry_timer); =20 - prs->orig_vdev =3D pcidev->vdevfn & ~7U; + prs->orig_vdev =3D pci->vdevfn & ~7U; =20 - if ( pcidev->vfunc_mask =3D=3D LIBXL_PCI_FUNC_ALL ) { - if ( pci_multifunction_check(gc, pcidev, &prs->pfunc_mask) ) { + if ( pci->vfunc_mask =3D=3D LIBXL_PCI_FUNC_ALL ) { + if ( pci_multifunction_check(gc, pci, &prs->pfunc_mask) ) { rc =3D ERROR_FAIL; goto out; } - pcidev->vfunc_mask &=3D prs->pfunc_mask; - }else{ - prs->pfunc_mask =3D (1 << pcidev->func); + pci->vfunc_mask &=3D prs->pfunc_mask; + } else { + prs->pfunc_mask =3D (1 << pci->func); } =20 rc =3D 0; @@ -2273,7 +2273,7 @@ static void device_pci_remove_common_next(libxl__egc = *egc, =20 /* Convenience aliases */ libxl_domid domid =3D prs->domid; - libxl_device_pci *const pcidev =3D prs->pcidev; + libxl_device_pci *const pci =3D prs->pci; libxl__ao_device *const aodev =3D prs->aodev; const unsigned int pfunc_mask =3D prs->pfunc_mask; const unsigned int orig_vdev =3D prs->orig_vdev; @@ -2284,13 +2284,13 @@ static void device_pci_remove_common_next(libxl__eg= c *egc, const int i =3D prs->next_func; prs->next_func--; if ( (1 << i) & pfunc_mask ) { - if ( pcidev->vfunc_mask =3D=3D pfunc_mask ) { - pcidev->func =3D i; - pcidev->vdevfn =3D orig_vdev | i; - }else{ - pcidev->vdevfn =3D orig_vdev; + if ( pci->vfunc_mask =3D=3D pfunc_mask ) { + pci->func =3D i; + pci->vdevfn =3D orig_vdev | i; + } else { + pci->vdevfn =3D orig_vdev; } - do_pci_remove(egc, domid, pcidev, prs->force, prs); + do_pci_remove(egc, domid, pci, prs->force, prs); return; } } @@ -2306,7 +2306,7 @@ out: } =20 int libxl_device_pci_remove(libxl_ctx *ctx, uint32_t domid, - libxl_device_pci *pcidev, + libxl_device_pci *pci, const libxl_asyncop_how *ao_how) =20 { @@ -2318,12 +2318,12 @@ int libxl_device_pci_remove(libxl_ctx *ctx, uint32_= t domid, aodev->action =3D LIBXL__DEVICE_ACTION_REMOVE; aodev->callback =3D device_addrm_aocomplete; aodev->update_json =3D true; - libxl__device_pci_remove_common(egc, domid, pcidev, false, aodev); + libxl__device_pci_remove_common(egc, domid, pci, false, aodev); return AO_INPROGRESS; } =20 int libxl_device_pci_destroy(libxl_ctx *ctx, uint32_t domid, - libxl_device_pci *pcidev, + libxl_device_pci *pci, const libxl_asyncop_how *ao_how) { AO_CREATE(ctx, domid, ao_how); @@ -2334,7 +2334,7 @@ int libxl_device_pci_destroy(libxl_ctx *ctx, uint32_t= domid, aodev->action =3D LIBXL__DEVICE_ACTION_REMOVE; aodev->callback =3D device_addrm_aocomplete; aodev->update_json =3D true; - libxl__device_pci_remove_common(egc, domid, pcidev, true, aodev); + libxl__device_pci_remove_common(egc, domid, pci, true, aodev); return AO_INPROGRESS; } =20 @@ -2353,7 +2353,7 @@ static int libxl__device_pci_from_xs_be(libxl__gc *gc, if (s) vdevfn =3D strtol(s, (char **) NULL, 16); =20 - pcidev_struct_fill(pci, domain, bus, dev, func, vdevfn); + pci_struct_fill(pci, domain, bus, dev, func, vdevfn); =20 s =3D libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/opts-%d", be_path, nr= )); if (s) { @@ -2398,7 +2398,7 @@ libxl_device_pci *libxl_device_pci_list(libxl_ctx *ct= x, uint32_t domid, int *num GC_INIT(ctx); char *be_path; unsigned int n, i; - libxl_device_pci *pcidevs =3D NULL; + libxl_device_pci *pcis =3D NULL; =20 *num =3D 0; =20 @@ -2407,28 +2407,28 @@ libxl_device_pci *libxl_device_pci_list(libxl_ctx *= ctx, uint32_t domid, int *num if (libxl__device_pci_get_num(gc, be_path, &n)) goto out; =20 - pcidevs =3D calloc(n, sizeof(libxl_device_pci)); + pcis =3D calloc(n, sizeof(libxl_device_pci)); =20 for (i =3D 0; i < n; i++) - libxl__device_pci_from_xs_be(gc, be_path, i, pcidevs + i); + libxl__device_pci_from_xs_be(gc, be_path, i, pcis + i); =20 *num =3D n; out: GC_FREE; - return pcidevs; + return pcis; } =20 void libxl__device_pci_destroy_all(libxl__egc *egc, uint32_t domid, libxl__multidev *multidev) { STATE_AO_GC(multidev->ao); - libxl_device_pci *pcidevs; + libxl_device_pci *pcis; int num, i; =20 - pcidevs =3D libxl_device_pci_list(CTX, domid, &num); - if ( pcidevs =3D=3D NULL ) + pcis =3D libxl_device_pci_list(CTX, domid, &num); + if ( pcis =3D=3D NULL ) return; - libxl__ptr_add(gc, pcidevs); + libxl__ptr_add(gc, pcis); =20 for (i =3D 0; i < num; i++) { /* Force remove on shutdown since, on HVM, qemu will not always @@ -2436,7 +2436,7 @@ void libxl__device_pci_destroy_all(libxl__egc *egc, u= int32_t domid, * devices by the time we even get here! */ libxl__ao_device *aodev =3D libxl__multidev_prepare(multidev); - libxl__device_pci_remove_common(egc, domid, pcidevs + i, true, + libxl__device_pci_remove_common(egc, domid, pcis + i, true, aodev); } } @@ -2452,10 +2452,10 @@ int libxl__grant_vga_iomem_permission(libxl__gc *gc= , const uint32_t domid, for (i =3D 0 ; i < d_config->num_pcidevs ; i++) { uint64_t vga_iomem_start =3D 0xa0000 >> XC_PAGE_SHIFT; uint32_t stubdom_domid; - libxl_device_pci *pcidev =3D &d_config->pcidevs[i]; + libxl_device_pci *pci =3D &d_config->pcidevs[i]; unsigned long pci_device_class; =20 - if (sysfs_dev_get_class(gc, pcidev, &pci_device_class)) + if (sysfs_dev_get_class(gc, pci, &pci_device_class)) continue; if (pci_device_class !=3D 0x030000) /* VGA class */ continue; @@ -2494,7 +2494,7 @@ static int libxl_device_pci_compare(const libxl_devic= e_pci *d1, =20 #define libxl__device_pci_update_devid NULL =20 -DEFINE_DEVICE_TYPE_STRUCT_X(pcidev, pci, PCI, +DEFINE_DEVICE_TYPE_STRUCT(pci, PCI, pcidevs, .get_num =3D libxl__device_pci_get_num, .from_xenstore =3D libxl__device_pci_from_xs_be, ); diff --git a/tools/libs/light/libxl_pvcalls.c b/tools/libs/light/libxl_pvca= lls.c index 870318e71618..1fbedf651c2c 100644 --- a/tools/libs/light/libxl_pvcalls.c +++ b/tools/libs/light/libxl_pvcalls.c @@ -34,4 +34,4 @@ static LIBXL_DEFINE_DEVICE_FROM_TYPE(pvcallsif) =20 LIBXL_DEFINE_DEVICE_REMOVE(pvcallsif) =20 -DEFINE_DEVICE_TYPE_STRUCT(pvcallsif, PVCALLS); +DEFINE_DEVICE_TYPE_STRUCT(pvcallsif, PVCALLS, pvcallsifs); diff --git a/tools/libs/light/libxl_usb.c b/tools/libs/light/libxl_usb.c index 171bb044394e..c5ae59681c91 100644 --- a/tools/libs/light/libxl_usb.c +++ b/tools/libs/light/libxl_usb.c @@ -2139,7 +2139,7 @@ void libxl_device_usbdev_list_free(libxl_device_usbde= v *list, int nr) =20 LIBXL_DEFINE_DEVID_TO_DEVICE(usbctrl) LIBXL_DEFINE_DEVICE_LIST(usbctrl) -DEFINE_DEVICE_TYPE_STRUCT(usbctrl, VUSB, +DEFINE_DEVICE_TYPE_STRUCT(usbctrl, VUSB, usbctrls, .from_xenstore =3D (device_from_xenstore_fn_t)libxl__usbctrl_from_xens= tore, .dm_needed =3D libxl_device_usbctrl_dm_needed ); @@ -2147,7 +2147,7 @@ DEFINE_DEVICE_TYPE_STRUCT(usbctrl, VUSB, #define libxl__device_from_usbdev NULL #define libxl__device_usbdev_update_devid NULL =20 -DEFINE_DEVICE_TYPE_STRUCT(usbdev, VUSB); +DEFINE_DEVICE_TYPE_STRUCT(usbdev, VUSB, usbdevs); =20 /* * Local variables: diff --git a/tools/libs/light/libxl_vdispl.c b/tools/libs/light/libxl_vdisp= l.c index 8ddc8940e9ff..60427c76c2d1 100644 --- a/tools/libs/light/libxl_vdispl.c +++ b/tools/libs/light/libxl_vdispl.c @@ -206,7 +206,7 @@ LIBXL_DEFINE_DEVICE_ADD(vdispl) LIBXL_DEFINE_DEVICE_REMOVE(vdispl) LIBXL_DEFINE_DEVICE_LIST(vdispl) =20 -DEFINE_DEVICE_TYPE_STRUCT(vdispl, VDISPL, +DEFINE_DEVICE_TYPE_STRUCT(vdispl, VDISPL, vdispls, .update_config =3D (device_update_config_fn_t)libxl__update_config_vdi= spl, .from_xenstore =3D (device_from_xenstore_fn_t)libxl__vdispl_from_xenst= ore, .set_xenstore_config =3D (device_set_xenstore_config_fn_t) diff --git a/tools/libs/light/libxl_vkb.c b/tools/libs/light/libxl_vkb.c index 4c44a813c11a..bb88059f93c3 100644 --- a/tools/libs/light/libxl_vkb.c +++ b/tools/libs/light/libxl_vkb.c @@ -336,7 +336,7 @@ static LIBXL_DEFINE_UPDATE_DEVID(vkb) LIBXL_DEFINE_DEVICE_LIST(vkb) LIBXL_DEFINE_DEVICE_REMOVE(vkb) =20 -DEFINE_DEVICE_TYPE_STRUCT(vkb, VKBD, +DEFINE_DEVICE_TYPE_STRUCT(vkb, VKBD, vkbs, .skip_attach =3D 1, .dm_needed =3D libxl__device_vkb_dm_needed, .set_xenstore_config =3D (device_set_xenstore_config_fn_t) diff --git a/tools/libs/light/libxl_vsnd.c b/tools/libs/light/libxl_vsnd.c index 0bc5f6dbb19f..bb7942bbc991 100644 --- a/tools/libs/light/libxl_vsnd.c +++ b/tools/libs/light/libxl_vsnd.c @@ -670,7 +670,7 @@ LIBXL_DEFINE_DEVICE_ADD(vsnd) LIBXL_DEFINE_DEVICE_REMOVE(vsnd) LIBXL_DEFINE_DEVICE_LIST(vsnd) =20 -DEFINE_DEVICE_TYPE_STRUCT(vsnd, VSND, +DEFINE_DEVICE_TYPE_STRUCT(vsnd, VSND, vsnds, .update_config =3D (device_update_config_fn_t) libxl__update_config_vs= nd, .from_xenstore =3D (device_from_xenstore_fn_t) libxl__vsnd_from_xensto= re, .set_xenstore_config =3D (device_set_xenstore_config_fn_t) diff --git a/tools/libs/light/libxl_vtpm.c b/tools/libs/light/libxl_vtpm.c index dd00b267bbf0..0148c572d444 100644 --- a/tools/libs/light/libxl_vtpm.c +++ b/tools/libs/light/libxl_vtpm.c @@ -231,7 +231,7 @@ LIBXL_DEFINE_DEVICE_ADD(vtpm) LIBXL_DEFINE_DEVICE_REMOVE(vtpm) LIBXL_DEFINE_DEVICE_LIST(vtpm) =20 -DEFINE_DEVICE_TYPE_STRUCT(vtpm, VTPM, +DEFINE_DEVICE_TYPE_STRUCT(vtpm, VTPM, vtpms, .update_config =3D libxl_device_vtpm_update_config, .from_xenstore =3D (device_from_xenstore_fn_t)libxl__vtpm_from_xenstor= e, .set_xenstore_config =3D (device_set_xenstore_config_fn_t) diff --git a/tools/libs/util/libxlu_pci.c b/tools/libs/util/libxlu_pci.c index 12fc0b3a7fdc..1d38fffce357 100644 --- a/tools/libs/util/libxlu_pci.c +++ b/tools/libs/util/libxlu_pci.c @@ -23,15 +23,15 @@ static int hex_convert(const char *str, unsigned int *v= al, unsigned int mask) return 0; } =20 -static int pcidev_struct_fill(libxl_device_pci *pcidev, unsigned int domai= n, - unsigned int bus, unsigned int dev, - unsigned int func, unsigned int vdevfn) +static int pci_struct_fill(libxl_device_pci *pci, unsigned int domain, + unsigned int bus, unsigned int dev, + unsigned int func, unsigned int vdevfn) { - pcidev->domain =3D domain; - pcidev->bus =3D bus; - pcidev->dev =3D dev; - pcidev->func =3D func; - pcidev->vdevfn =3D vdevfn; + pci->domain =3D domain; + pci->bus =3D bus; + pci->dev =3D dev; + pci->func =3D func; + pci->vdevfn =3D vdevfn; return 0; } =20 @@ -47,7 +47,7 @@ static int pcidev_struct_fill(libxl_device_pci *pcidev, u= nsigned int domain, #define STATE_RDM_STRATEGY 10 #define STATE_RESERVE_POLICY 11 #define INVALID 0xffffffff -int xlu_pci_parse_bdf(XLU_Config *cfg, libxl_device_pci *pcidev, const cha= r *str) +int xlu_pci_parse_bdf(XLU_Config *cfg, libxl_device_pci *pci, const char *= str) { unsigned state =3D STATE_DOMAIN; unsigned dom =3D INVALID, bus =3D INVALID, dev =3D INVALID, func =3D I= NVALID, vslot =3D 0; @@ -110,11 +110,11 @@ int xlu_pci_parse_bdf(XLU_Config *cfg, libxl_device_p= ci *pcidev, const char *str } *ptr =3D '\0'; if ( !strcmp(tok, "*") ) { - pcidev->vfunc_mask =3D LIBXL_PCI_FUNC_ALL; + pci->vfunc_mask =3D LIBXL_PCI_FUNC_ALL; }else{ if ( hex_convert(tok, &func, 0x7) ) goto parse_error; - pcidev->vfunc_mask =3D (1 << 0); + pci->vfunc_mask =3D (1 << 0); } tok =3D ptr + 1; } @@ -141,18 +141,18 @@ int xlu_pci_parse_bdf(XLU_Config *cfg, libxl_device_p= ci *pcidev, const char *str state =3D (*ptr =3D=3D ',') ? STATE_OPTIONS_K : STATE_TERM= INAL; *ptr =3D '\0'; if ( !strcmp(optkey, "msitranslate") ) { - pcidev->msitranslate =3D atoi(tok); + pci->msitranslate =3D atoi(tok); }else if ( !strcmp(optkey, "power_mgmt") ) { - pcidev->power_mgmt =3D atoi(tok); + pci->power_mgmt =3D atoi(tok); }else if ( !strcmp(optkey, "permissive") ) { - pcidev->permissive =3D atoi(tok); + pci->permissive =3D atoi(tok); }else if ( !strcmp(optkey, "seize") ) { - pcidev->seize =3D atoi(tok); + pci->seize =3D atoi(tok); } else if (!strcmp(optkey, "rdm_policy")) { if (!strcmp(tok, "strict")) { - pcidev->rdm_policy =3D LIBXL_RDM_RESERVE_POLICY_ST= RICT; + pci->rdm_policy =3D LIBXL_RDM_RESERVE_POLICY_STRIC= T; } else if (!strcmp(tok, "relaxed")) { - pcidev->rdm_policy =3D LIBXL_RDM_RESERVE_POLICY_RE= LAXED; + pci->rdm_policy =3D LIBXL_RDM_RESERVE_POLICY_RELAX= ED; } else { XLU__PCI_ERR(cfg, "%s is not an valid PCI RDM prop= erty" " policy: 'strict' or 'relaxed'.= ", @@ -175,7 +175,7 @@ int xlu_pci_parse_bdf(XLU_Config *cfg, libxl_device_pci= *pcidev, const char *str assert(dom !=3D INVALID && bus !=3D INVALID && dev !=3D INVALID && fun= c !=3D INVALID); =20 /* Just a pretty way to fill in the values */ - pcidev_struct_fill(pcidev, dom, bus, dev, func, vslot << 3); + pci_struct_fill(pci, dom, bus, dev, func, vslot << 3); =20 free(buf2); =20 --=20 2.20.1