From nobody Mon Feb 9 17:36:18 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=1603470242; cv=none; d=zohomail.com; s=zohoarc; b=n5r+tOzJN9cWQie32Ma6wIKN49kSVOlKP06VFDCCtEXx+SiGfOtzWp2xaiW+UazifNw5HyiwVFF0kVxWht/WxkGibUqH052QC97Hb4f7ddQ7NoBFBAgy0WKBa124jv/IDT4syB6ygJV6au/2XcvrO9f6E+R8B0QIetsIjuCuLeA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603470242; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=2Epbe5jjBp/+RA6U7S2vptokK57Dpce2kJ38YAOJuqY=; b=JUB0OqMyLNxeWi4CF/w7e7zEc64ZrGGeWxU0wrjz7FONYdIBXDG82FFI9iV9zx30S75M/5Q3uDfpHZfUpzXqOK15M3M48KpnqqflbVU1ncoB0iuYoh4KZ9hLuj6DvShzPgK+b41vjLvrM1kkR/TDeI6RgkS56k5q7S7tMYnBSgc= 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 1603470242418623.731478578325; Fri, 23 Oct 2020 09:24:02 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.11164.29633 (Exim 4.92) (envelope-from ) id 1kVzqt-0008MW-D7; Fri, 23 Oct 2020 16:23:39 +0000 Received: by outflank-mailman (output) from mailman id 11164.29633; Fri, 23 Oct 2020 16:23:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kVzqt-0008M9-5T; Fri, 23 Oct 2020 16:23:39 +0000 Received: by outflank-mailman (input) for mailman id 11164; Fri, 23 Oct 2020 16:23:37 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kVzqr-00081e-CW for xen-devel@lists.xenproject.org; Fri, 23 Oct 2020 16:23:37 +0000 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 21eda335-bcb2-431d-8b54-8363e40956a4; Fri, 23 Oct 2020 16:23:22 +0000 (UTC) Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kVzqb-0008Iw-64; Fri, 23 Oct 2020 16:23:21 +0000 Received: from ec2-18-200-132-236.eu-west-1.compute.amazonaws.com ([18.200.132.236] helo=ip-10-0-185-232.eu-west-1.compute.internal) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kVzqa-000376-MR; Fri, 23 Oct 2020 16:23:21 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kVzqr-00081e-CW for xen-devel@lists.xenproject.org; Fri, 23 Oct 2020 16:23:37 +0000 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 21eda335-bcb2-431d-8b54-8363e40956a4; Fri, 23 Oct 2020 16:23:22 +0000 (UTC) Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kVzqb-0008Iw-64; Fri, 23 Oct 2020 16:23:21 +0000 Received: from ec2-18-200-132-236.eu-west-1.compute.amazonaws.com ([18.200.132.236] helo=ip-10-0-185-232.eu-west-1.compute.internal) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kVzqa-000376-MR; Fri, 23 Oct 2020 16:23:21 +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" X-Inumbo-ID: 21eda335-bcb2-431d-8b54-8363e40956a4 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=2Epbe5jjBp/+RA6U7S2vptokK57Dpce2kJ38YAOJuqY=; b=AdOIB0mG+bpDznfUEDEzTL6BL gaezcrVA48p/TZuC6W2jAHliQEDFbwJei9i6MeARq9vrLiYOYIw1joNQCeNpe61DghMTwW5gWAOgw 5mWLqGZAmBqT5oFw3SI80pQ3VauWzGSGI5WshuurDrJWRHxtA6ZlBpmbLvdr/uoDAD6jI=; From: Paul Durrant To: xen-devel@lists.xenproject.org Cc: Paul Durrant , Ian Jackson , Wei Liu , Anthony PERARD Subject: [PATCH 01/25] xl / libxl: s/pcidev/pci and remove DEFINE_DEVICE_TYPE_STRUCT_X Date: Fri, 23 Oct 2020 16:22:50 +0000 Message-Id: <20201023162314.2235-2-paul@xen.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20201023162314.2235-1-paul@xen.org> References: <20201023162314.2235-1-paul@xen.org> X-ZohoMail-DKIM: pass (identity @xen.org) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 code, allowing evaluation = of DEFINE_DEVICE_TYPE_STRUCT_X to be replaced with DEFINE_DEVICE_TYPE_STRUCT, hence allowing removal of the former. For consistency the xl and libs/util code is also modified, but in this case it is purely cosmetic. 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 --- Cc: Ian Jackson Cc: Wei Liu Cc: Anthony PERARD --- tools/include/libxl.h | 17 +- tools/libs/light/libxl_create.c | 6 +- tools/libs/light/libxl_dm.c | 18 +- tools/libs/light/libxl_internal.h | 45 ++- tools/libs/light/libxl_pci.c | 582 +++++++++++++++++++---------------= ---- tools/libs/light/libxl_types.idl | 2 +- tools/libs/util/libxlu_pci.c | 36 +-- tools/xl/xl_parse.c | 28 +- tools/xl/xl_pci.c | 68 ++--- tools/xl/xl_sxp.c | 12 +- 10 files changed, 409 insertions(+), 405 deletions(-) diff --git a/tools/include/libxl.h b/tools/include/libxl.h index 1ea5b4f446..fbe4c81ba5 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -445,6 +445,13 @@ #define LIBXL_HAVE_DISK_SAFE_REMOVE 1 =20 /* + * LIBXL_HAVE_CONFIG_PCIS indicates that the 'pcidevs' and 'num_pcidevs' + * fields in libxl_domain_config have been renamed to 'pcis' and 'num_pcis' + * respectively. + */ +#define LIBXL_HAVE_CONFIG_PCIS 1 + +/* * libxl ABI compatibility * * The only guarantee which libxl makes regarding ABI compatibility @@ -2300,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 @@ -2352,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_create.c b/tools/libs/light/libxl_creat= e.c index 321a13e519..1f5052c520 100644 --- a/tools/libs/light/libxl_create.c +++ b/tools/libs/light/libxl_create.c @@ -1100,7 +1100,7 @@ int libxl__domain_config_setdefault(libxl__gc *gc, goto error_out; } =20 - bool need_pt =3D d_config->num_pcidevs || d_config->num_dtdevs; + bool need_pt =3D d_config->num_pcis || d_config->num_dtdevs; if (c_info->passthrough =3D=3D LIBXL_PASSTHROUGH_DEFAULT) { c_info->passthrough =3D need_pt ? LIBXL_PASSTHROUGH_ENABLED : LIBXL_PASSTHROUGH_DISABLED; @@ -1141,7 +1141,7 @@ int libxl__domain_config_setdefault(libxl__gc *gc, * assignment when PoD is enabled. */ if (d_config->c_info.type !=3D LIBXL_DOMAIN_TYPE_PV && - d_config->num_pcidevs && pod_enabled) { + d_config->num_pcis && pod_enabled) { ret =3D ERROR_INVAL; LOGD(ERROR, domid, "PCI device assignment for HVM guest failed due to PoD enable= d"); @@ -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_dm.c b/tools/libs/light/libxl_dm.c index d1ff35dda3..f147a733c8 100644 --- a/tools/libs/light/libxl_dm.c +++ b/tools/libs/light/libxl_dm.c @@ -442,7 +442,7 @@ int libxl__domain_device_construct_rdm(libxl__gc *gc, =20 /* Might not expose rdm. */ if (strategy =3D=3D LIBXL_RDM_RESERVE_STRATEGY_IGNORE && - !d_config->num_pcidevs) + !d_config->num_pcis) return 0; =20 /* Query all RDM entries in this platform */ @@ -469,13 +469,13 @@ int libxl__domain_device_construct_rdm(libxl__gc *gc, } =20 /* Query RDM entries per-device */ - for (i =3D 0; i < d_config->num_pcidevs; i++) { + for (i =3D 0; i < d_config->num_pcis; i++) { unsigned int n, nr_entries; =20 - seg =3D d_config->pcidevs[i].domain; - bus =3D d_config->pcidevs[i].bus; - devfn =3D PCI_DEVFN(d_config->pcidevs[i].dev, - d_config->pcidevs[i].func); + seg =3D d_config->pcis[i].domain; + bus =3D d_config->pcis[i].bus; + devfn =3D PCI_DEVFN(d_config->pcis[i].dev, + d_config->pcis[i].func); nr_entries =3D 0; rc =3D libxl__xc_device_get_rdm(gc, 0, seg, bus, devfn, &nr_entries, &xrdm); @@ -488,7 +488,7 @@ int libxl__domain_device_construct_rdm(libxl__gc *gc, assert(xrdm); =20 rc =3D libxl__device_pci_setdefault(gc, DOMID_INVALID, - &d_config->pcidevs[i], false); + &d_config->pcis[i], false); if (rc) goto out; =20 @@ -516,7 +516,7 @@ int libxl__domain_device_construct_rdm(libxl__gc *gc, * global policy in this case. */ d_config->rdms[j].policy - =3D d_config->pcidevs[i].rdm_policy; + =3D d_config->pcis[i].rdm_policy; new =3D false; break; } @@ -526,7 +526,7 @@ int libxl__domain_device_construct_rdm(libxl__gc *gc, add_rdm_entry(gc, d_config, pfn_to_paddr(xrdm[n].start_pfn), pfn_to_paddr(xrdm[n].nr_pages), - d_config->pcidevs[i].rdm_policy); + d_config->pcis[i].rdm_policy); } } =20 diff --git a/tools/libs/light/libxl_internal.h b/tools/libs/light/libxl_int= ernal.h index e26cda9b50..3e70ff639b 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, ...) = \ - 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), = \ - .add =3D libxl__add_ ## name ## s, = \ - .set_default =3D (device_set_default_fn_t) = \ - libxl__device_ ## sname ## _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, \ - .dispose =3D (device_dispose_fn_t) = \ - libxl_device_ ## sname ## _dispose, = \ - .compare =3D (device_compare_fn_t) = \ - libxl_device_ ## sname ## _compare, = \ - .update_devid =3D (device_update_devid_fn_t) = \ - libxl__device_ ## sname ## _update_devid, = \ - __VA_ARGS__ = \ +#define DEFINE_DEVICE_TYPE_STRUCT(name, kind, ...) = \ + 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_ ## name), = \ + .add =3D libxl__add_ ## name ## s, = \ + .set_default =3D (device_set_default_fn_t) = \ + 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_ ## name ## _ini= t, \ + .copy =3D (device_copy_fn_t)libxl_device_ ## name ## _cop= y, \ + .dispose =3D (device_dispose_fn_t) = \ + libxl_device_ ## name ## _dispose, = \ + .compare =3D (device_compare_fn_t) = \ + libxl_device_ ## name ## _compare, = \ + .update_devid =3D (device_update_devid_fn_t) = \ + 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_pci.c b/tools/libs/light/libxl_pci.c index bc5843b137..2ff1c64a31 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 @@ -588,16 +588,16 @@ bool libxl__is_igd_vga_passthru(libxl__gc *gc, uint16_t pt_vendor, pt_device; 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); + for (i =3D 0 ; i < d_config->num_pcis ; i++) { + libxl_device_pci *pci =3D &d_config->pcis[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=3D4) { + 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,23 +1752,23 @@ static void libxl__add_pcidevs(libxl__egc *egc, lib= xl__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++) { + for (i =3D 0; i < d_config->num_pcis; i++) { libxl__ao_device *aodev =3D libxl__multidev_prepare(&apds->multide= v); - libxl__device_pci_add(egc, domid, &d_config->pcidevs[i], + libxl__device_pci_add(egc, domid, &d_config->pcis[i], true, aodev); } =20 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; @@ -1777,9 +1777,9 @@ static void add_pcidevs_done(libxl__egc *egc, libxl__= multidev *multidev, =20 if (rc) goto out; =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); + if (d_config->num_pcis > 0 && !libxl_get_stubdom_id(CTX, domid)) { + rc =3D libxl__create_pci_backend(gc, domid, d_config->pcis, + d_config->num_pcis); 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); } } @@ -2449,13 +2449,13 @@ int libxl__grant_vga_iomem_permission(libxl__gc *gc= , const uint32_t domid, if (!libxl_defbool_val(d_config->b_info.u.hvm.gfx_passthru)) return 0; =20 - for (i =3D 0 ; i < d_config->num_pcidevs ; i++) { + for (i =3D 0 ; i < d_config->num_pcis ; 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->pcis[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, .get_num =3D libxl__device_pci_get_num, .from_xenstore =3D libxl__device_pci_from_xs_be, ); diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_type= s.idl index 9d3f05f399..20f8dd7cfa 100644 --- a/tools/libs/light/libxl_types.idl +++ b/tools/libs/light/libxl_types.idl @@ -940,7 +940,7 @@ libxl_domain_config =3D Struct("domain_config", [ =20 ("disks", Array(libxl_device_disk, "num_disks")), ("nics", Array(libxl_device_nic, "num_nics")), - ("pcidevs", Array(libxl_device_pci, "num_pcidevs")), + ("pcis", Array(libxl_device_pci, "num_pcis")), ("rdms", Array(libxl_device_rdm, "num_rdms")), ("dtdevs", Array(libxl_device_dtdev, "num_dtdevs")), ("vfbs", Array(libxl_device_vfb, "num_vfbs")), diff --git a/tools/libs/util/libxlu_pci.c b/tools/libs/util/libxlu_pci.c index 12fc0b3a7f..1d38fffce3 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 diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index cae8eb679c..0765780d9f 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -1470,24 +1470,24 @@ void parse_config_data(const char *config_source, } =20 if (!xlu_cfg_get_list (config, "pci", &pcis, 0, 0)) { - d_config->num_pcidevs =3D 0; - d_config->pcidevs =3D NULL; + d_config->num_pcis =3D 0; + d_config->pcis =3D NULL; for(i =3D 0; (buf =3D xlu_cfg_get_listitem (pcis, i)) !=3D NULL; i= ++) { - libxl_device_pci *pcidev; - - pcidev =3D ARRAY_EXTEND_INIT_NODEVID(d_config->pcidevs, - d_config->num_pcidevs, - libxl_device_pci_init); - pcidev->msitranslate =3D pci_msitranslate; - pcidev->power_mgmt =3D pci_power_mgmt; - pcidev->permissive =3D pci_permissive; - pcidev->seize =3D pci_seize; + libxl_device_pci *pci; + + pci =3D ARRAY_EXTEND_INIT_NODEVID(d_config->pcis, + d_config->num_pcis, + libxl_device_pci_init); + pci->msitranslate =3D pci_msitranslate; + pci->power_mgmt =3D pci_power_mgmt; + pci->permissive =3D pci_permissive; + pci->seize =3D pci_seize; /* * Like other pci option, the per-device policy always follows * the global policy by default. */ - pcidev->rdm_policy =3D b_info->u.hvm.rdm.policy; - e =3D xlu_pci_parse_bdf(config, pcidev, buf); + pci->rdm_policy =3D b_info->u.hvm.rdm.policy; + e =3D xlu_pci_parse_bdf(config, pci, buf); if (e) { fprintf(stderr, "unable to parse PCI BDF `%s' for passthrough\n", @@ -1495,7 +1495,7 @@ void parse_config_data(const char *config_source, exit(-e); } } - if (d_config->num_pcidevs && c_info->type =3D=3D LIBXL_DOMAIN_TYPE= _PV) + if (d_config->num_pcis && c_info->type =3D=3D LIBXL_DOMAIN_TYPE_PV) libxl_defbool_set(&b_info->u.pv.e820_host, true); } =20 diff --git a/tools/xl/xl_pci.c b/tools/xl/xl_pci.c index 58345bdae2..34fcf5a4fa 100644 --- a/tools/xl/xl_pci.c +++ b/tools/xl/xl_pci.c @@ -24,20 +24,20 @@ =20 static void pcilist(uint32_t domid) { - 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; printf("Vdev Device\n"); for (i =3D 0; i < num; i++) { printf("%02x.%01x %04x:%02x:%02x.%01x\n", - (pcidevs[i].vdevfn >> 3) & 0x1f, pcidevs[i].vdevfn & 0x7, - pcidevs[i].domain, pcidevs[i].bus, pcidevs[i].dev, pcidevs[= i].func); - libxl_device_pci_dispose(&pcidevs[i]); + (pcis[i].vdevfn >> 3) & 0x1f, pcis[i].vdevfn & 0x7, + pcis[i].domain, pcis[i].bus, pcis[i].dev, pcis[i].func); + libxl_device_pci_dispose(&pcis[i]); } - free(pcidevs); + free(pcis); } =20 int main_pcilist(int argc, char **argv) @@ -57,28 +57,28 @@ int main_pcilist(int argc, char **argv) =20 static int pcidetach(uint32_t domid, const char *bdf, int force) { - libxl_device_pci pcidev; + libxl_device_pci pci; XLU_Config *config; int r =3D 0; =20 - libxl_device_pci_init(&pcidev); + libxl_device_pci_init(&pci); =20 config =3D xlu_cfg_init(stderr, "command line"); if (!config) { perror("xlu_cfg_inig"); exit(-1); } =20 - if (xlu_pci_parse_bdf(config, &pcidev, bdf)) { + if (xlu_pci_parse_bdf(config, &pci, bdf)) { fprintf(stderr, "pci-detach: malformed BDF specification \"%s\"\n"= , bdf); exit(2); } if (force) { - if (libxl_device_pci_destroy(ctx, domid, &pcidev, 0)) + if (libxl_device_pci_destroy(ctx, domid, &pci, 0)) r =3D 1; } else { - if (libxl_device_pci_remove(ctx, domid, &pcidev, 0)) + if (libxl_device_pci_remove(ctx, domid, &pci, 0)) r =3D 1; } =20 - libxl_device_pci_dispose(&pcidev); + libxl_device_pci_dispose(&pci); xlu_cfg_destroy(config); =20 return r; @@ -108,24 +108,24 @@ int main_pcidetach(int argc, char **argv) =20 static int pciattach(uint32_t domid, const char *bdf, const char *vs) { - libxl_device_pci pcidev; + libxl_device_pci pci; XLU_Config *config; int r =3D 0; =20 - libxl_device_pci_init(&pcidev); + libxl_device_pci_init(&pci); =20 config =3D xlu_cfg_init(stderr, "command line"); if (!config) { perror("xlu_cfg_inig"); exit(-1); } =20 - if (xlu_pci_parse_bdf(config, &pcidev, bdf)) { + if (xlu_pci_parse_bdf(config, &pci, bdf)) { fprintf(stderr, "pci-attach: malformed BDF specification \"%s\"\n"= , bdf); exit(2); } =20 - if (libxl_device_pci_add(ctx, domid, &pcidev, 0)) + if (libxl_device_pci_add(ctx, domid, &pci, 0)) r =3D 1; =20 - libxl_device_pci_dispose(&pcidev); + libxl_device_pci_dispose(&pci); xlu_cfg_destroy(config); =20 return r; @@ -155,19 +155,19 @@ int main_pciattach(int argc, char **argv) =20 static void pciassignable_list(void) { - 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); =20 - if ( pcidevs =3D=3D NULL ) + if ( pcis =3D=3D NULL ) return; for (i =3D 0; i < num; i++) { printf("%04x:%02x:%02x.%01x\n", - pcidevs[i].domain, pcidevs[i].bus, pcidevs[i].dev, pcidevs[= i].func); - libxl_device_pci_dispose(&pcidevs[i]); + pcis[i].domain, pcis[i].bus, pcis[i].dev, pcis[i].func); + libxl_device_pci_dispose(&pcis[i]); } - free(pcidevs); + free(pcis); } =20 int main_pciassignable_list(int argc, char **argv) @@ -184,24 +184,24 @@ int main_pciassignable_list(int argc, char **argv) =20 static int pciassignable_add(const char *bdf, int rebind) { - libxl_device_pci pcidev; + libxl_device_pci pci; XLU_Config *config; int r =3D 0; =20 - libxl_device_pci_init(&pcidev); + libxl_device_pci_init(&pci); =20 config =3D xlu_cfg_init(stderr, "command line"); if (!config) { perror("xlu_cfg_init"); exit(-1); } =20 - if (xlu_pci_parse_bdf(config, &pcidev, bdf)) { + if (xlu_pci_parse_bdf(config, &pci, bdf)) { fprintf(stderr, "pci-assignable-add: malformed BDF specification \= "%s\"\n", bdf); exit(2); } =20 - if (libxl_device_pci_assignable_add(ctx, &pcidev, rebind)) + if (libxl_device_pci_assignable_add(ctx, &pci, rebind)) r =3D 1; =20 - libxl_device_pci_dispose(&pcidev); + libxl_device_pci_dispose(&pci); xlu_cfg_destroy(config); =20 return r; @@ -226,24 +226,24 @@ int main_pciassignable_add(int argc, char **argv) =20 static int pciassignable_remove(const char *bdf, int rebind) { - libxl_device_pci pcidev; + libxl_device_pci pci; XLU_Config *config; int r =3D 0; =20 - libxl_device_pci_init(&pcidev); + libxl_device_pci_init(&pci); =20 config =3D xlu_cfg_init(stderr, "command line"); if (!config) { perror("xlu_cfg_init"); exit(-1); } =20 - if (xlu_pci_parse_bdf(config, &pcidev, bdf)) { + if (xlu_pci_parse_bdf(config, &pci, bdf)) { fprintf(stderr, "pci-assignable-remove: malformed BDF specificatio= n \"%s\"\n", bdf); exit(2); } =20 - if (libxl_device_pci_assignable_remove(ctx, &pcidev, rebind)) + if (libxl_device_pci_assignable_remove(ctx, &pci, rebind)) r =3D 1; =20 - libxl_device_pci_dispose(&pcidev); + libxl_device_pci_dispose(&pci); xlu_cfg_destroy(config); =20 return r; diff --git a/tools/xl/xl_sxp.c b/tools/xl/xl_sxp.c index 359a001570..b03e348ffb 100644 --- a/tools/xl/xl_sxp.c +++ b/tools/xl/xl_sxp.c @@ -190,16 +190,16 @@ void printf_info_sexp(int domid, libxl_domain_config = *d_config, FILE *fh) fprintf(fh, "\t)\n"); } =20 - for (i =3D 0; i < d_config->num_pcidevs; i++) { + for (i =3D 0; i < d_config->num_pcis; i++) { fprintf(fh, "\t(device\n"); fprintf(fh, "\t\t(pci\n"); fprintf(fh, "\t\t\t(pci dev %04x:%02x:%02x.%01x@%02x)\n", - d_config->pcidevs[i].domain, d_config->pcidevs[i].bus, - d_config->pcidevs[i].dev, d_config->pcidevs[i].func, - d_config->pcidevs[i].vdevfn); + d_config->pcis[i].domain, d_config->pcis[i].bus, + d_config->pcis[i].dev, d_config->pcis[i].func, + d_config->pcis[i].vdevfn); fprintf(fh, "\t\t\t(opts msitranslate %d power_mgmt %d)\n", - d_config->pcidevs[i].msitranslate, - d_config->pcidevs[i].power_mgmt); + d_config->pcis[i].msitranslate, + d_config->pcis[i].power_mgmt); fprintf(fh, "\t\t)\n"); fprintf(fh, "\t)\n"); } --=20 2.11.0