[libvirt] [PATCH v3 0/4] Fix parsing our own XMLs

v3: - Actually use virPCIDeviceAddress. It was actually ACKed with that changed but I feel like it's way too big of a change for just pushing it. Also, I'm in no rush with this, so I'l gladly wait after therelease with this. v2: - Just a rebase - I did *not* use virPCIDeviceAddress wording instead as discussed in the v1 thread. That's because we have lot of functions working with virDevicePCIAddress named exactly after that and renaming those would be ugly IMHO. - https://www.redhat.com/archives/libvir-list/2016-April/msg00714.html v1: - https://www.redhat.com/archives/libvir-list/2016-April/msg00081.html Martin Kletzander (4): Change virDevicePCIAddress to virPCIDeviceAddress Move capability formatting together schemas: Update nodedev schema to match reality conf: Parse more of our nodedev XML docs/schemas/nodedev.rng | 29 +++--- src/bhyve/bhyve_device.c | 4 +- src/conf/device_conf.c | 16 +-- src/conf/device_conf.h | 25 ++--- src/conf/domain_addr.c | 24 ++--- src/conf/domain_addr.h | 22 ++-- src/conf/domain_conf.c | 26 ++--- src/conf/domain_conf.h | 10 +- src/conf/network_conf.c | 8 +- src/conf/network_conf.h | 2 +- src/conf/node_device_conf.c | 111 +++++++++++++++++++-- src/conf/storage_conf.c | 14 +-- src/conf/storage_conf.h | 2 +- src/libvirt_private.syms | 8 +- src/network/bridge_driver.c | 4 +- src/qemu/qemu_agent.c | 2 +- src/qemu/qemu_domain_address.c | 12 +-- src/qemu/qemu_hotplug.c | 10 +- src/qemu/qemu_monitor.c | 12 +-- src/qemu/qemu_monitor.h | 14 +-- src/qemu/qemu_monitor_json.c | 12 +-- src/qemu/qemu_monitor_json.h | 12 +-- src/qemu/qemu_monitor_text.c | 14 +-- src/qemu/qemu_monitor_text.h | 12 +-- src/storage/storage_backend_scsi.c | 2 +- src/util/virpci.c | 2 +- src/util/virpci.h | 3 +- src/xen/xend_internal.c | 2 +- .../pci_0000_00_1c_0_header_type.xml | 2 +- tests/nodedevschemadata/pci_0000_02_10_7_sriov.xml | 23 +++++ .../pci_0000_02_10_7_sriov_pf_vfs_all.xml | 29 ++++++ ...i_0000_02_10_7_sriov_pf_vfs_all_header_type.xml | 30 ++++++ .../pci_0000_02_10_7_sriov_vfs.xml | 26 +++++ .../pci_0000_02_10_7_sriov_zero_vfs_max_count.xml | 21 ++++ tests/nodedevxml2xmltest.c | 7 ++ 35 files changed, 391 insertions(+), 161 deletions(-) create mode 100644 tests/nodedevschemadata/pci_0000_02_10_7_sriov.xml create mode 100644 tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all.xml create mode 100644 tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all_header_type.xml create mode 100644 tests/nodedevschemadata/pci_0000_02_10_7_sriov_vfs.xml create mode 100644 tests/nodedevschemadata/pci_0000_02_10_7_sriov_zero_vfs_max_count.xml -- 2.8.1

We had both and the only difference was that the latter also included information about multifunction setting. The problem with that was that we couldn't use functions made for only one of the structs (e.g. parsing). To consolidate those two structs, use the one in virpci.h, include that in domain_conf.h and add the multifunction member in it. Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/bhyve/bhyve_device.c | 4 ++-- src/conf/device_conf.c | 16 ++++++++-------- src/conf/device_conf.h | 25 ++++++++----------------- src/conf/domain_addr.c | 24 ++++++++++++------------ src/conf/domain_addr.h | 22 +++++++++++----------- src/conf/domain_conf.c | 26 +++++++++++++------------- src/conf/domain_conf.h | 10 +++++----- src/conf/network_conf.c | 8 ++++---- src/conf/network_conf.h | 2 +- src/conf/node_device_conf.c | 4 ++-- src/conf/storage_conf.c | 14 +++++++------- src/conf/storage_conf.h | 2 +- src/libvirt_private.syms | 8 ++++---- src/network/bridge_driver.c | 4 ++-- src/qemu/qemu_agent.c | 2 +- src/qemu/qemu_domain_address.c | 12 ++++++------ src/qemu/qemu_hotplug.c | 10 +++++----- src/qemu/qemu_monitor.c | 12 ++++++------ src/qemu/qemu_monitor.h | 14 +++++++------- src/qemu/qemu_monitor_json.c | 12 ++++++------ src/qemu/qemu_monitor_json.h | 12 ++++++------ src/qemu/qemu_monitor_text.c | 14 +++++++------- src/qemu/qemu_monitor_text.h | 12 ++++++------ src/storage/storage_backend_scsi.c | 2 +- src/util/virpci.c | 2 +- src/util/virpci.h | 3 ++- src/xen/xend_internal.c | 2 +- 27 files changed, 135 insertions(+), 143 deletions(-) diff --git a/src/bhyve/bhyve_device.c b/src/bhyve/bhyve_device.c index fe1c567be37f..3eb295658016 100644 --- a/src/bhyve/bhyve_device.c +++ b/src/bhyve/bhyve_device.c @@ -40,7 +40,7 @@ bhyveCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED, { int ret = -1; virDomainPCIAddressSetPtr addrs = opaque; - virDevicePCIAddressPtr addr = &info->addr.pci; + virPCIDeviceAddressPtr addr = &info->addr.pci; if (addr->domain == 0 && addr->bus == 0) { if (addr->slot == 0) { @@ -88,7 +88,7 @@ bhyveAssignDevicePCISlots(virDomainDefPtr def, virDomainPCIAddressSetPtr addrs) { size_t i; - virDevicePCIAddress lpc_addr; + virPCIDeviceAddress lpc_addr; /* explicitly reserve slot 1 for LPC-ISA bridge */ memset(&lpc_addr, 0, sizeof(lpc_addr)); diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index 4e15d38463fe..9d9f6a79151a 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -55,7 +55,7 @@ VIR_ENUM_IMPL(virNetDevFeature, "rdma", "txudptnl") -int virDevicePCIAddressIsValid(virDevicePCIAddressPtr addr, +int virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr, bool report) { if (addr->domain > 0xFFFF) { @@ -102,8 +102,8 @@ int virDevicePCIAddressIsValid(virDevicePCIAddressPtr addr, int -virDevicePCIAddressParseXML(xmlNodePtr node, - virDevicePCIAddressPtr addr) +virPCIDeviceAddressParseXML(xmlNodePtr node, + virPCIDeviceAddressPtr addr) { char *domain, *slot, *bus, *function, *multi; int ret = -1; @@ -152,7 +152,7 @@ virDevicePCIAddressParseXML(xmlNodePtr node, goto cleanup; } - if (!virDevicePCIAddressIsValid(addr, true)) + if (!virPCIDeviceAddressIsValid(addr, true)) goto cleanup; ret = 0; @@ -167,8 +167,8 @@ virDevicePCIAddressParseXML(xmlNodePtr node, } int -virDevicePCIAddressFormat(virBufferPtr buf, - virDevicePCIAddress addr, +virPCIDeviceAddressFormat(virBufferPtr buf, + virPCIDeviceAddress addr, bool includeTypeInAddr) { virBufferAsprintf(buf, "<address %sdomain='0x%.4x' bus='0x%.2x' " @@ -182,8 +182,8 @@ virDevicePCIAddressFormat(virBufferPtr buf, } bool -virDevicePCIAddressEqual(virDevicePCIAddress *addr1, - virDevicePCIAddress *addr2) +virPCIDeviceAddressEqual(virPCIDeviceAddress *addr1, + virPCIDeviceAddress *addr2) { if (addr1->domain == addr2->domain && addr1->bus == addr2->bus && diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h index 85ce40f6831e..fc0f4abb36cd 100644 --- a/src/conf/device_conf.h +++ b/src/conf/device_conf.h @@ -31,6 +31,7 @@ # include "virutil.h" # include "virthread.h" # include "virbuffer.h" +# include "virpci.h" typedef enum { VIR_INTERFACE_STATE_UNKNOWN = 1, @@ -45,16 +46,6 @@ typedef enum { VIR_ENUM_DECL(virInterfaceState) -typedef struct _virDevicePCIAddress virDevicePCIAddress; -typedef virDevicePCIAddress *virDevicePCIAddressPtr; -struct _virDevicePCIAddress { - unsigned int domain; - unsigned int bus; - unsigned int slot; - unsigned int function; - int multi; /* virTristateSwitch */ -}; - typedef struct _virInterfaceLink virInterfaceLink; typedef virInterfaceLink *virInterfaceLinkPtr; struct _virInterfaceLink { @@ -81,18 +72,18 @@ typedef enum { VIR_ENUM_DECL(virNetDevFeature) -int virDevicePCIAddressIsValid(virDevicePCIAddressPtr addr, +int virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr, bool report); -int virDevicePCIAddressParseXML(xmlNodePtr node, - virDevicePCIAddressPtr addr); +int virPCIDeviceAddressParseXML(xmlNodePtr node, + virPCIDeviceAddressPtr addr); -int virDevicePCIAddressFormat(virBufferPtr buf, - virDevicePCIAddress addr, +int virPCIDeviceAddressFormat(virBufferPtr buf, + virPCIDeviceAddress addr, bool includeTypeInAddr); -bool virDevicePCIAddressEqual(virDevicePCIAddress *addr1, - virDevicePCIAddress *addr2); +bool virPCIDeviceAddressEqual(virPCIDeviceAddress *addr1, + virPCIDeviceAddress *addr2); int virInterfaceLinkParseXML(xmlNodePtr node, virInterfaceLinkPtr lnk); diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index c0afa21e0564..acd8ce6ed33b 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -88,7 +88,7 @@ virDomainPCIControllerModelToConnectType(virDomainControllerModelPCI model) } bool -virDomainPCIAddressFlagsCompatible(virDevicePCIAddressPtr addr, +virDomainPCIAddressFlagsCompatible(virPCIDeviceAddressPtr addr, const char *addrStr, virDomainPCIConnectFlags busFlags, virDomainPCIConnectFlags devFlags, @@ -163,7 +163,7 @@ virDomainPCIAddressFlagsCompatible(virDevicePCIAddressPtr addr, */ bool virDomainPCIAddressValidate(virDomainPCIAddressSetPtr addrs, - virDevicePCIAddressPtr addr, + virPCIDeviceAddressPtr addr, const char *addrStr, virDomainPCIConnectFlags flags, bool fromConfig) @@ -315,7 +315,7 @@ virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus, */ int virDomainPCIAddressSetGrow(virDomainPCIAddressSetPtr addrs, - virDevicePCIAddressPtr addr, + virPCIDeviceAddressPtr addr, virDomainPCIConnectFlags flags) { int add; @@ -351,7 +351,7 @@ virDomainPCIAddressSetGrow(virDomainPCIAddressSetPtr addrs, char * -virDomainPCIAddressAsString(virDevicePCIAddressPtr addr) +virDomainPCIAddressAsString(virPCIDeviceAddressPtr addr) { char *str; @@ -369,7 +369,7 @@ virDomainPCIAddressAsString(virDevicePCIAddressPtr addr) */ bool virDomainPCIAddressSlotInUse(virDomainPCIAddressSetPtr addrs, - virDevicePCIAddressPtr addr) + virPCIDeviceAddressPtr addr) { return !!addrs->buses[addr->bus].slots[addr->slot]; } @@ -386,7 +386,7 @@ virDomainPCIAddressSlotInUse(virDomainPCIAddressSetPtr addrs, */ int virDomainPCIAddressReserveAddr(virDomainPCIAddressSetPtr addrs, - virDevicePCIAddressPtr addr, + virPCIDeviceAddressPtr addr, virDomainPCIConnectFlags flags, bool reserveEntireSlot, bool fromConfig) @@ -448,7 +448,7 @@ virDomainPCIAddressReserveAddr(virDomainPCIAddressSetPtr addrs, int virDomainPCIAddressReserveSlot(virDomainPCIAddressSetPtr addrs, - virDevicePCIAddressPtr addr, + virPCIDeviceAddressPtr addr, virDomainPCIConnectFlags flags) { return virDomainPCIAddressReserveAddr(addrs, addr, flags, true, false); @@ -499,7 +499,7 @@ virDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPtr addrs, int virDomainPCIAddressReleaseAddr(virDomainPCIAddressSetPtr addrs, - virDevicePCIAddressPtr addr) + virPCIDeviceAddressPtr addr) { addrs->buses[addr->bus].slots[addr->slot] &= ~(1 << addr->function); return 0; @@ -507,7 +507,7 @@ virDomainPCIAddressReleaseAddr(virDomainPCIAddressSetPtr addrs, int virDomainPCIAddressReleaseSlot(virDomainPCIAddressSetPtr addrs, - virDevicePCIAddressPtr addr) + virPCIDeviceAddressPtr addr) { /* permit any kind of connection type in validation, since we * already had it, and are giving it back. @@ -563,13 +563,13 @@ virDomainPCIAddressSetFree(virDomainPCIAddressSetPtr addrs) int virDomainPCIAddressGetNextSlot(virDomainPCIAddressSetPtr addrs, - virDevicePCIAddressPtr next_addr, + virPCIDeviceAddressPtr next_addr, virDomainPCIConnectFlags flags) { /* default to starting the search for a free slot from * the first slot of domain 0 bus 0... */ - virDevicePCIAddress a = { 0, 0, 0, 0, false }; + virPCIDeviceAddress a = { 0, 0, 0, 0, false }; char *addrStr = NULL; if (addrs->nbuses == 0) { @@ -666,7 +666,7 @@ virDomainPCIAddressReserveNextSlot(virDomainPCIAddressSetPtr addrs, virDomainDeviceInfoPtr dev, virDomainPCIConnectFlags flags) { - virDevicePCIAddress addr; + virPCIDeviceAddress addr; if (virDomainPCIAddressGetNextSlot(addrs, &addr, flags) < 0) return -1; diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h index 5b5de8a31ca7..f3eda89d5c1a 100644 --- a/src/conf/domain_addr.h +++ b/src/conf/domain_addr.h @@ -79,7 +79,7 @@ typedef virDomainPCIAddressBus *virDomainPCIAddressBusPtr; struct _virDomainPCIAddressSet { virDomainPCIAddressBus *buses; size_t nbuses; - virDevicePCIAddress lastaddr; + virPCIDeviceAddress lastaddr; virDomainPCIConnectFlags lastFlags; bool dryRun; /* on a dry run, new buses are auto-added and addresses aren't saved in device infos */ @@ -87,14 +87,14 @@ struct _virDomainPCIAddressSet { typedef struct _virDomainPCIAddressSet virDomainPCIAddressSet; typedef virDomainPCIAddressSet *virDomainPCIAddressSetPtr; -char *virDomainPCIAddressAsString(virDevicePCIAddressPtr addr) +char *virDomainPCIAddressAsString(virPCIDeviceAddressPtr addr) ATTRIBUTE_NONNULL(1); virDomainPCIAddressSetPtr virDomainPCIAddressSetAlloc(unsigned int nbuses); void virDomainPCIAddressSetFree(virDomainPCIAddressSetPtr addrs); -bool virDomainPCIAddressFlagsCompatible(virDevicePCIAddressPtr addr, +bool virDomainPCIAddressFlagsCompatible(virPCIDeviceAddressPtr addr, const char *addrStr, virDomainPCIConnectFlags busFlags, virDomainPCIConnectFlags devFlags, @@ -103,7 +103,7 @@ bool virDomainPCIAddressFlagsCompatible(virDevicePCIAddressPtr addr, ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); bool virDomainPCIAddressValidate(virDomainPCIAddressSetPtr addrs, - virDevicePCIAddressPtr addr, + virPCIDeviceAddressPtr addr, const char *addrStr, virDomainPCIConnectFlags flags, bool fromConfig) @@ -115,23 +115,23 @@ int virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus, ATTRIBUTE_NONNULL(1); bool virDomainPCIAddressSlotInUse(virDomainPCIAddressSetPtr addrs, - virDevicePCIAddressPtr addr) + virPCIDeviceAddressPtr addr) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); int virDomainPCIAddressSetGrow(virDomainPCIAddressSetPtr addrs, - virDevicePCIAddressPtr addr, + virPCIDeviceAddressPtr addr, virDomainPCIConnectFlags flags) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); int virDomainPCIAddressReserveAddr(virDomainPCIAddressSetPtr addrs, - virDevicePCIAddressPtr addr, + virPCIDeviceAddressPtr addr, virDomainPCIConnectFlags flags, bool reserveEntireSlot, bool fromConfig) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); int virDomainPCIAddressReserveSlot(virDomainPCIAddressSetPtr addrs, - virDevicePCIAddressPtr addr, + virPCIDeviceAddressPtr addr, virDomainPCIConnectFlags flags) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); @@ -140,15 +140,15 @@ int virDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPtr addrs, ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); int virDomainPCIAddressReleaseAddr(virDomainPCIAddressSetPtr addrs, - virDevicePCIAddressPtr addr) + virPCIDeviceAddressPtr addr) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); int virDomainPCIAddressReleaseSlot(virDomainPCIAddressSetPtr addrs, - virDevicePCIAddressPtr addr) + virPCIDeviceAddressPtr addr) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); int virDomainPCIAddressGetNextSlot(virDomainPCIAddressSetPtr addrs, - virDevicePCIAddressPtr next_addr, + virPCIDeviceAddressPtr next_addr, virDomainPCIConnectFlags flags) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d8bed670f243..62d369d5a008 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3097,7 +3097,7 @@ int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info, switch (info->type) { case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: - return virDevicePCIAddressIsValid(&info->addr.pci, false); + return virPCIDeviceAddressIsValid(&info->addr.pci, false); case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE: return 1; @@ -5027,7 +5027,7 @@ virDomainDeviceInfoParseXML(xmlNodePtr node, switch ((virDomainDeviceAddressType) info->type) { case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: - if (virDevicePCIAddressParseXML(address, &info->addr.pci) < 0) + if (virPCIDeviceAddressParseXML(address, &info->addr.pci) < 0) goto cleanup; break; @@ -5097,7 +5097,7 @@ virDomainDeviceInfoParseXML(xmlNodePtr node, static int virDomainParseLegacyDeviceAddress(char *devaddr, - virDevicePCIAddressPtr pci) + virPCIDeviceAddressPtr pci) { char *tmp; @@ -5301,10 +5301,10 @@ virDomainHostdevSubsysPCIDefParseXML(xmlNodePtr node, while (cur != NULL) { if (cur->type == XML_ELEMENT_NODE) { if (xmlStrEqual(cur->name, BAD_CAST "address")) { - virDevicePCIAddressPtr addr = + virPCIDeviceAddressPtr addr = &def->source.subsys.u.pci.addr; - if (virDevicePCIAddressParseXML(cur, addr) < 0) + if (virPCIDeviceAddressParseXML(cur, addr) < 0) goto out; } else if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) && xmlStrEqual(cur->name, BAD_CAST "state")) { @@ -13257,7 +13257,7 @@ virDomainDiskControllerMatch(int controller_type, int disk_bus) int virDomainDiskIndexByAddress(virDomainDefPtr def, - virDevicePCIAddressPtr pci_address, + virPCIDeviceAddressPtr pci_address, unsigned int bus, unsigned int target, unsigned int unit) { @@ -13272,7 +13272,7 @@ virDomainDiskIndexByAddress(virDomainDefPtr def, for (i = 0; i < def->ndisks; i++) { vdisk = def->disks[i]; if (vdisk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI && - virDevicePCIAddressEqual(&vdisk->info.addr.pci, pci_address)) + virPCIDeviceAddressEqual(&vdisk->info.addr.pci, pci_address)) return i; if (vdisk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) { virDomainDeviceDriveAddressPtr drive = &vdisk->info.addr.drive; @@ -13289,7 +13289,7 @@ virDomainDiskIndexByAddress(virDomainDefPtr def, virDomainDiskDefPtr virDomainDiskByAddress(virDomainDefPtr def, - virDevicePCIAddressPtr pci_address, + virPCIDeviceAddressPtr pci_address, unsigned int bus, unsigned int target, unsigned int unit) @@ -13459,7 +13459,7 @@ virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net) return -1; } if (PCIAddrSpecified) { - if (virDevicePCIAddressEqual(&def->nets[i]->info.addr.pci, + if (virPCIDeviceAddressEqual(&def->nets[i]->info.addr.pci, &net->info.addr.pci)) { /* exit early if the pci address was specified and * it matches, as this guarantees no duplicates. @@ -13503,7 +13503,7 @@ virDomainHasNet(virDomainDefPtr def, virDomainNetDefPtr net) continue; if (PCIAddrSpecified) { - if (virDevicePCIAddressEqual(&def->nets[i]->info.addr.pci, + if (virPCIDeviceAddressEqual(&def->nets[i]->info.addr.pci, &net->info.addr.pci)) return true; } else { @@ -13680,7 +13680,7 @@ virDomainControllerFindByType(virDomainDefPtr def, int virDomainControllerFindByPCIAddress(virDomainDefPtr def, - virDevicePCIAddressPtr addr) + virPCIDeviceAddressPtr addr) { size_t i; @@ -13688,7 +13688,7 @@ virDomainControllerFindByPCIAddress(virDomainDefPtr def, virDomainDeviceInfoPtr info = &def->controllers[i]->info; if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI && - virDevicePCIAddressEqual(&info->addr.pci, addr)) + virPCIDeviceAddressEqual(&info->addr.pci, addr)) return i; } @@ -19740,7 +19740,7 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf, } break; case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: - if (virDevicePCIAddressFormat(buf, pcisrc->addr, + if (virPCIDeviceAddressFormat(buf, pcisrc->addr, includeTypeInAddr) != 0) virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("PCI address Formatting failed")); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 31e7a86d4746..cfb6f7cac832 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -348,7 +348,7 @@ struct _virDomainDeviceInfo { char *alias; int type; /* virDomainDeviceAddressType */ union { - virDevicePCIAddress pci; + virPCIDeviceAddress pci; virDomainDeviceDriveAddress drive; virDomainDeviceVirtioSerialAddress vioserial; virDomainDeviceCcidAddress ccid; @@ -456,7 +456,7 @@ struct _virDomainHostdevSubsysUSB { typedef struct _virDomainHostdevSubsysPCI virDomainHostdevSubsysPCI; typedef virDomainHostdevSubsysPCI *virDomainHostdevSubsysPCIPtr; struct _virDomainHostdevSubsysPCI { - virDevicePCIAddress addr; /* host address */ + virPCIDeviceAddress addr; /* host address */ int backend; /* enum virDomainHostdevSubsysPCIBackendType */ }; @@ -2778,11 +2778,11 @@ int virDomainDefCompatibleDevice(virDomainDefPtr def, void virDomainRNGDefFree(virDomainRNGDefPtr def); int virDomainDiskIndexByAddress(virDomainDefPtr def, - virDevicePCIAddressPtr pci_controller, + virPCIDeviceAddressPtr pci_controller, unsigned int bus, unsigned int target, unsigned int unit); virDomainDiskDefPtr virDomainDiskByAddress(virDomainDefPtr def, - virDevicePCIAddressPtr pci_controller, + virPCIDeviceAddressPtr pci_controller, unsigned int bus, unsigned int target, unsigned int unit); @@ -2853,7 +2853,7 @@ void virDomainControllerInsertPreAlloced(virDomainDefPtr def, int virDomainControllerFind(const virDomainDef *def, int type, int idx); int virDomainControllerFindByType(virDomainDefPtr def, int type); int virDomainControllerFindByPCIAddress(virDomainDefPtr def, - virDevicePCIAddressPtr addr); + virPCIDeviceAddressPtr addr); virDomainControllerDefPtr virDomainControllerRemove(virDomainDefPtr def, size_t i); const char *virDomainControllerAliasFind(const virDomainDef *def, int type, int idx) diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index e6915ffde74f..c574b01b712b 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -1974,13 +1974,13 @@ virNetworkForwardDefParseXML(const char *networkName, switch (def->ifs[i].type) { case VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI: { - virDevicePCIAddressPtr addr = &def->ifs[i].device.pci; + virPCIDeviceAddressPtr addr = &def->ifs[i].device.pci; - if (virDevicePCIAddressParseXML(forwardAddrNodes[i], addr) < 0) + if (virPCIDeviceAddressParseXML(forwardAddrNodes[i], addr) < 0) goto cleanup; for (j = 0; j < i; j++) { - if (virDevicePCIAddressEqual(addr, &def->ifs[j].device.pci)) { + if (virPCIDeviceAddressEqual(addr, &def->ifs[j].device.pci)) { virReportError(VIR_ERR_XML_ERROR, _("PCI device '%04x:%02x:%02x.%x' can " "only be listed once in network %s"), @@ -2797,7 +2797,7 @@ virNetworkDefFormatBuf(virBufferPtr buf, virBufferAddLit(buf, "/>\n"); } else { if (def->forward.ifs[i].type == VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI) { - if (virDevicePCIAddressFormat(buf, + if (virPCIDeviceAddressFormat(buf, def->forward.ifs[i].device.pci, true) < 0) goto error; diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h index b72257b970a8..0d34dfe62658 100644 --- a/src/conf/network_conf.h +++ b/src/conf/network_conf.h @@ -169,7 +169,7 @@ typedef virNetworkForwardIfDef *virNetworkForwardIfDefPtr; struct _virNetworkForwardIfDef { int type; union { - virDevicePCIAddress pci; /*PCI Address of device */ + virPCIDeviceAddress pci; /*PCI Address of device */ /* when USB devices are supported a new variable to be added here */ char *dev; /* name of device */ }device; diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index a76f785eddc0..e7e4bbd390fa 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1164,8 +1164,8 @@ virNodeDevCapPCIDevIommuGroupParseXML(xmlXPathContextPtr ctxt, goto cleanup; for (i = 0; i < nAddrNodes; i++) { - virDevicePCIAddress addr = { 0, 0, 0, 0, 0 }; - if (virDevicePCIAddressParseXML(addrNodes[i], &addr) < 0) + virPCIDeviceAddress addr = { 0, 0, 0, 0, 0 }; + if (virPCIDeviceAddressParseXML(addrNodes[i], &addr) < 0) goto cleanup; if (VIR_ALLOC(pciAddr) < 0) goto cleanup; diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index daf8f99285b9..3c832269125d 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -603,7 +603,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, if (virXPathNode("./adapter/parentaddr", ctxt)) { xmlNodePtr addrnode = virXPathNode("./adapter/parentaddr/address", ctxt); - virDevicePCIAddressPtr addr = + virPCIDeviceAddressPtr addr = &source->adapter.data.scsi_host.parentaddr; if (!addrnode) { @@ -612,7 +612,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, goto cleanup; } source->adapter.data.scsi_host.has_parent = true; - if (virDevicePCIAddressParseXML(addrnode, addr) < 0) + if (virPCIDeviceAddressParseXML(addrnode, addr) < 0) goto cleanup; if ((virXPathInt("string(./adapter/parentaddr/@unique_id)", ctxt, @@ -1103,14 +1103,14 @@ virStoragePoolSourceFormat(virBufferPtr buf, virBufferAsprintf(buf, " name='%s'/>\n", src->adapter.data.scsi_host.name); } else { - virDevicePCIAddress addr; + virPCIDeviceAddress addr; virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); virBufferAsprintf(buf, "<parentaddr unique_id='%d'>\n", src->adapter.data.scsi_host.unique_id); virBufferAdjustIndent(buf, 2); addr = src->adapter.data.scsi_host.parentaddr; - ignore_value(virDevicePCIAddressFormat(buf, addr, false)); + ignore_value(virPCIDeviceAddressFormat(buf, addr, false)); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</parentaddr>\n"); virBufferAdjustIndent(buf, -2); @@ -2315,7 +2315,7 @@ getSCSIHostNumber(virStoragePoolSourceAdapter adapter, char *name = NULL; if (adapter.data.scsi_host.has_parent) { - virDevicePCIAddress addr = adapter.data.scsi_host.parentaddr; + virPCIDeviceAddress addr = adapter.data.scsi_host.parentaddr; unsigned int unique_id = adapter.data.scsi_host.unique_id; if (!(name = virGetSCSIHostNameByParentaddr(addr.domain, @@ -2419,9 +2419,9 @@ static bool matchSCSIAdapterParent(virStoragePoolObjPtr pool, virStoragePoolDefPtr def) { - virDevicePCIAddressPtr pooladdr = + virPCIDeviceAddressPtr pooladdr = &pool->def->source.adapter.data.scsi_host.parentaddr; - virDevicePCIAddressPtr defaddr = + virPCIDeviceAddressPtr defaddr = &def->source.adapter.data.scsi_host.parentaddr; int pool_unique_id = pool->def->source.adapter.data.scsi_host.unique_id; diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h index 31b45be04f9a..54116a690c25 100644 --- a/src/conf/storage_conf.h +++ b/src/conf/storage_conf.h @@ -186,7 +186,7 @@ struct _virStoragePoolSourceAdapter { union { struct { char *name; - virDevicePCIAddress parentaddr; /* host address */ + virPCIDeviceAddress parentaddr; /* host address */ int unique_id; bool has_parent; } scsi_host; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 5030ec3a1521..a057a1e8305c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -76,14 +76,14 @@ virCPUModeTypeToString; # conf/device_conf.h -virDevicePCIAddressEqual; -virDevicePCIAddressFormat; -virDevicePCIAddressIsValid; -virDevicePCIAddressParseXML; virInterfaceLinkFormat; virInterfaceLinkParseXML; virInterfaceStateTypeFromString; virInterfaceStateTypeToString; +virPCIDeviceAddressEqual; +virPCIDeviceAddressFormat; +virPCIDeviceAddressIsValid; +virPCIDeviceAddressParseXML; # conf/domain_addr.h diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 29c5febc7696..45248d5d6ad5 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -4457,7 +4457,7 @@ networkNotifyActualDevice(virDomainDefPtr dom, for (i = 0; i < netdef->forward.nifs; i++) { if (netdef->forward.ifs[i].type == VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI && - virDevicePCIAddressEqual(&hostdev->source.subsys.u.pci.addr, + virPCIDeviceAddressEqual(&hostdev->source.subsys.u.pci.addr, &netdef->forward.ifs[i].device.pci)) { dev = &netdef->forward.ifs[i]; break; @@ -4616,7 +4616,7 @@ networkReleaseActualDevice(virDomainDefPtr dom, for (i = 0; i < netdef->forward.nifs; i++) { if (netdef->forward.ifs[i].type == VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI && - virDevicePCIAddressEqual(&hostdev->source.subsys.u.pci.addr, + virPCIDeviceAddressEqual(&hostdev->source.subsys.u.pci.addr, &netdef->forward.ifs[i].device.pci)) { dev = &netdef->forward.ifs[i]; break; diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 0610f75e52aa..c55f304d5a54 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -1770,7 +1770,7 @@ qemuAgentGetFSInfo(qemuAgentPtr mon, virDomainFSInfoPtr **info, virJSONValuePtr reply = NULL; virJSONValuePtr data; virDomainFSInfoPtr *info_ret = NULL; - virDevicePCIAddress pci_address; + virPCIDeviceAddress pci_address; cmd = qemuAgentMakeCommand("guest-get-fsinfo", NULL); if (!cmd) diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index f4d55334efdb..c651dce6d78c 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -423,7 +423,7 @@ qemuDomainCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED, { virDomainPCIAddressSetPtr addrs = opaque; int ret = -1; - virDevicePCIAddressPtr addr = &info->addr.pci; + virPCIDeviceAddressPtr addr = &info->addr.pci; bool entireSlot; /* flags may be changed from default below */ virDomainPCIConnectFlags flags = (VIR_PCI_CONNECT_HOTPLUGGABLE | @@ -620,7 +620,7 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr def, { int ret = -1; size_t i; - virDevicePCIAddress tmp_addr; + virPCIDeviceAddress tmp_addr; bool qemuDeviceVideoUsable = virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY); char *addrStr = NULL; virDomainPCIConnectFlags flags = (VIR_PCI_CONNECT_HOTPLUGGABLE @@ -754,7 +754,7 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr def, { int ret = -1; size_t i; - virDevicePCIAddress tmp_addr; + virPCIDeviceAddress tmp_addr; bool qemuDeviceVideoUsable = virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY); char *addrStr = NULL; virDomainPCIConnectFlags flags = VIR_PCI_CONNECT_TYPE_PCIE_DEVICE; @@ -1021,7 +1021,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def, { size_t i, j; virDomainPCIConnectFlags flags = 0; /* initialize to quiet gcc warning */ - virDevicePCIAddress tmp_addr; + virPCIDeviceAddress tmp_addr; /* PCI controllers */ for (i = 0; i < def->ncontrollers; i++) { @@ -1120,7 +1120,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def, /* USB2 needs special handling to put all companions in the same slot */ if (IS_USB2_CONTROLLER(def->controllers[i])) { - virDevicePCIAddress addr = { 0, 0, 0, 0, false }; + virPCIDeviceAddress addr = { 0, 0, 0, 0, false }; bool foundAddr = false; memset(&tmp_addr, 0, sizeof(tmp_addr)); @@ -1545,7 +1545,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def, for (i = 0; i < def->ncontrollers; i++) { virDomainControllerDefPtr cont = def->controllers[i]; int idx = cont->idx; - virDevicePCIAddressPtr addr; + virPCIDeviceAddressPtr addr; virDomainPCIControllerOptsPtr options; if (cont->type != VIR_DOMAIN_CONTROLLER_TYPE_PCI) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index ef8696be4690..f952497e7a03 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -390,7 +390,7 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn, } } else if (!disk->info.type || disk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { - virDevicePCIAddress guestAddr = disk->info.addr.pci; + virPCIDeviceAddress guestAddr = disk->info.addr.pci; ret = qemuMonitorAddPCIDisk(priv->mon, src, type, &guestAddr); if (ret == 0) { disk->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; @@ -820,7 +820,7 @@ int qemuDomainAttachNetDevice(virConnectPtr conn, char *netstr = NULL; virNetDevVPortProfilePtr vport = NULL; int ret = -1; - virDevicePCIAddress guestAddr; + virPCIDeviceAddress guestAddr; int vlan; bool releaseaddr = false; bool iface_connected = false; @@ -1292,8 +1292,8 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver, if (qemuDomainObjExitMonitor(driver, vm) < 0) goto error; } else { - virDevicePCIAddressPtr guestAddr = &hostdev->info->addr.pci; - virDevicePCIAddressPtr hostAddr = &hostdev->source.subsys.u.pci.addr; + virPCIDeviceAddressPtr guestAddr = &hostdev->info->addr.pci; + virPCIDeviceAddressPtr hostAddr = &hostdev->source.subsys.u.pci.addr; if (hostAddr->domain && !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_HOST_PCI_MULTIDOMAIN)) { @@ -2323,7 +2323,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, virDomainDeviceInfoCopy(&newdev->info, &olddev->info) < 0) { goto cleanup; } - if (!virDevicePCIAddressEqual(&olddev->info.addr.pci, + if (!virPCIDeviceAddressEqual(&olddev->info.addr.pci, &newdev->info.addr.pci)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("cannot modify network device guest PCI address")); diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index fe8e89f45e59..c4ca8481365e 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2453,8 +2453,8 @@ qemuMonitorAddUSBDeviceMatch(qemuMonitorPtr mon, int qemuMonitorAddPCIHostDevice(qemuMonitorPtr mon, - virDevicePCIAddress *hostAddr, - virDevicePCIAddress *guestAddr) + virPCIDeviceAddress *hostAddr, + virPCIDeviceAddress *guestAddr) { VIR_DEBUG("domain=%d bus=%d slot=%d function=%d", hostAddr->domain, hostAddr->bus, hostAddr->slot, hostAddr->function); @@ -2472,7 +2472,7 @@ int qemuMonitorAddPCIDisk(qemuMonitorPtr mon, const char *path, const char *bus, - virDevicePCIAddress *guestAddr) + virPCIDeviceAddress *guestAddr) { VIR_DEBUG("path=%s bus=%s", path, bus); @@ -2488,7 +2488,7 @@ qemuMonitorAddPCIDisk(qemuMonitorPtr mon, int qemuMonitorAddPCINetwork(qemuMonitorPtr mon, const char *nicstr, - virDevicePCIAddress *guestAddr) + virPCIDeviceAddress *guestAddr) { VIR_DEBUG("nicstr=%s", nicstr); @@ -2503,7 +2503,7 @@ qemuMonitorAddPCINetwork(qemuMonitorPtr mon, int qemuMonitorRemovePCIDevice(qemuMonitorPtr mon, - virDevicePCIAddress *guestAddr) + virPCIDeviceAddress *guestAddr) { VIR_DEBUG("domain=%d bus=%d slot=%d function=%d", guestAddr->domain, guestAddr->bus, guestAddr->slot, @@ -2812,7 +2812,7 @@ qemuMonitorGetChardevInfo(qemuMonitorPtr mon, int qemuMonitorAttachPCIDiskController(qemuMonitorPtr mon, const char *bus, - virDevicePCIAddress *guestAddr) + virPCIDeviceAddress *guestAddr) { VIR_DEBUG("type=%s", bus); diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 470c7292b3cf..3e2739b6e746 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -643,8 +643,8 @@ int qemuMonitorAddUSBDeviceMatch(qemuMonitorPtr mon, int qemuMonitorAddPCIHostDevice(qemuMonitorPtr mon, - virDevicePCIAddress *hostAddr, - virDevicePCIAddress *guestAddr); + virPCIDeviceAddress *hostAddr, + virPCIDeviceAddress *guestAddr); /* XXX disk driver type eg, qcow/etc. * XXX cache mode @@ -652,17 +652,17 @@ int qemuMonitorAddPCIHostDevice(qemuMonitorPtr mon, int qemuMonitorAddPCIDisk(qemuMonitorPtr mon, const char *path, const char *bus, - virDevicePCIAddress *guestAddr); + virPCIDeviceAddress *guestAddr); /* XXX do we really want to hardcode 'nicstr' as the * sendable item here */ int qemuMonitorAddPCINetwork(qemuMonitorPtr mon, const char *nicstr, - virDevicePCIAddress *guestAddr); + virPCIDeviceAddress *guestAddr); int qemuMonitorRemovePCIDevice(qemuMonitorPtr mon, - virDevicePCIAddress *guestAddr); + virPCIDeviceAddress *guestAddr); int qemuMonitorSendFileHandle(qemuMonitorPtr mon, @@ -712,13 +712,13 @@ int qemuMonitorGetChardevInfo(qemuMonitorPtr mon, int qemuMonitorAttachPCIDiskController(qemuMonitorPtr mon, const char *bus, - virDevicePCIAddress *guestAddr); + virPCIDeviceAddress *guestAddr); typedef struct _qemuMonitorPCIAddress qemuMonitorPCIAddress; struct _qemuMonitorPCIAddress { unsigned int vendor; unsigned int product; - virDevicePCIAddress addr; + virPCIDeviceAddress addr; }; int qemuMonitorGetAllPCIAddresses(qemuMonitorPtr mon, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 7bb99767c9bd..2bc5fdd205d1 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -3062,8 +3062,8 @@ int qemuMonitorJSONAddUSBDeviceMatch(qemuMonitorPtr mon ATTRIBUTE_UNUSED, int qemuMonitorJSONAddPCIHostDevice(qemuMonitorPtr mon ATTRIBUTE_UNUSED, - virDevicePCIAddress *hostAddr ATTRIBUTE_UNUSED, - virDevicePCIAddress *guestAddr ATTRIBUTE_UNUSED) + virPCIDeviceAddress *hostAddr ATTRIBUTE_UNUSED, + virPCIDeviceAddress *guestAddr ATTRIBUTE_UNUSED) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("pci_add not supported in JSON mode")); @@ -3074,7 +3074,7 @@ int qemuMonitorJSONAddPCIHostDevice(qemuMonitorPtr mon ATTRIBUTE_UNUSED, int qemuMonitorJSONAddPCIDisk(qemuMonitorPtr mon ATTRIBUTE_UNUSED, const char *path ATTRIBUTE_UNUSED, const char *bus ATTRIBUTE_UNUSED, - virDevicePCIAddress *guestAddr ATTRIBUTE_UNUSED) + virPCIDeviceAddress *guestAddr ATTRIBUTE_UNUSED) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("pci_add not supported in JSON mode")); @@ -3084,7 +3084,7 @@ int qemuMonitorJSONAddPCIDisk(qemuMonitorPtr mon ATTRIBUTE_UNUSED, int qemuMonitorJSONAddPCINetwork(qemuMonitorPtr mon ATTRIBUTE_UNUSED, const char *nicstr ATTRIBUTE_UNUSED, - virDevicePCIAddress *guestAddr ATTRIBUTE_UNUSED) + virPCIDeviceAddress *guestAddr ATTRIBUTE_UNUSED) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("pci_add not supported in JSON mode")); @@ -3093,7 +3093,7 @@ int qemuMonitorJSONAddPCINetwork(qemuMonitorPtr mon ATTRIBUTE_UNUSED, int qemuMonitorJSONRemovePCIDevice(qemuMonitorPtr mon ATTRIBUTE_UNUSED, - virDevicePCIAddress *guestAddr ATTRIBUTE_UNUSED) + virPCIDeviceAddress *guestAddr ATTRIBUTE_UNUSED) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("pci_del not supported in JSON mode")); @@ -3601,7 +3601,7 @@ qemuMonitorJSONGetChardevInfo(qemuMonitorPtr mon, int qemuMonitorJSONAttachPCIDiskController(qemuMonitorPtr mon ATTRIBUTE_UNUSED, const char *bus ATTRIBUTE_UNUSED, - virDevicePCIAddress *guestAddr ATTRIBUTE_UNUSED) + virPCIDeviceAddress *guestAddr ATTRIBUTE_UNUSED) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("pci_add not supported in JSON mode")); diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 8b5d4220d088..c11c84fe98b7 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -181,20 +181,20 @@ int qemuMonitorJSONAddUSBDeviceMatch(qemuMonitorPtr mon, int qemuMonitorJSONAddPCIHostDevice(qemuMonitorPtr mon, - virDevicePCIAddress *hostAddr, - virDevicePCIAddress *guestAddr); + virPCIDeviceAddress *hostAddr, + virPCIDeviceAddress *guestAddr); int qemuMonitorJSONAddPCIDisk(qemuMonitorPtr mon, const char *path, const char *bus, - virDevicePCIAddress *guestAddr); + virPCIDeviceAddress *guestAddr); int qemuMonitorJSONAddPCINetwork(qemuMonitorPtr mon, const char *nicstr, - virDevicePCIAddress *guestAddr); + virPCIDeviceAddress *guestAddr); int qemuMonitorJSONRemovePCIDevice(qemuMonitorPtr mon, - virDevicePCIAddress *guestAddr); + virPCIDeviceAddress *guestAddr); int qemuMonitorJSONSendFileHandle(qemuMonitorPtr mon, const char *fdname, @@ -220,7 +220,7 @@ int qemuMonitorJSONGetChardevInfo(qemuMonitorPtr mon, int qemuMonitorJSONAttachPCIDiskController(qemuMonitorPtr mon, const char *bus, - virDevicePCIAddress *guestAddr); + virPCIDeviceAddress *guestAddr); int qemuMonitorJSONGetAllPCIAddresses(qemuMonitorPtr mon, qemuMonitorPCIAddress **addrs); diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index ccae02f99cf4..c21639fbaded 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -1674,7 +1674,7 @@ int qemuMonitorTextAddUSBDeviceMatch(qemuMonitorPtr mon, static int qemuMonitorTextParsePCIAddReply(qemuMonitorPtr mon ATTRIBUTE_UNUSED, const char *reply, - virDevicePCIAddress *addr) + virPCIDeviceAddress *addr) { char *s, *e; @@ -1736,8 +1736,8 @@ qemuMonitorTextParsePCIAddReply(qemuMonitorPtr mon ATTRIBUTE_UNUSED, int qemuMonitorTextAddPCIHostDevice(qemuMonitorPtr mon, - virDevicePCIAddress *hostAddr, - virDevicePCIAddress *guestAddr) + virPCIDeviceAddress *hostAddr, + virPCIDeviceAddress *guestAddr) { char *cmd; char *reply = NULL; @@ -1787,7 +1787,7 @@ int qemuMonitorTextAddPCIHostDevice(qemuMonitorPtr mon, int qemuMonitorTextAddPCIDisk(qemuMonitorPtr mon, const char *path, const char *bus, - virDevicePCIAddress *guestAddr) + virPCIDeviceAddress *guestAddr) { char *cmd = NULL; char *reply = NULL; @@ -1832,7 +1832,7 @@ int qemuMonitorTextAddPCIDisk(qemuMonitorPtr mon, int qemuMonitorTextAddPCINetwork(qemuMonitorPtr mon, const char *nicstr, - virDevicePCIAddress *guestAddr) + virPCIDeviceAddress *guestAddr) { char *cmd; char *reply = NULL; @@ -1860,7 +1860,7 @@ int qemuMonitorTextAddPCINetwork(qemuMonitorPtr mon, int qemuMonitorTextRemovePCIDevice(qemuMonitorPtr mon, - virDevicePCIAddress *guestAddr) + virPCIDeviceAddress *guestAddr) { char *cmd = NULL; char *reply = NULL; @@ -2173,7 +2173,7 @@ int qemuMonitorTextGetChardevInfo(qemuMonitorPtr mon, int qemuMonitorTextAttachPCIDiskController(qemuMonitorPtr mon, const char *bus, - virDevicePCIAddress *guestAddr) + virPCIDeviceAddress *guestAddr) { char *cmd = NULL; char *reply = NULL; diff --git a/src/qemu/qemu_monitor_text.h b/src/qemu/qemu_monitor_text.h index 287a8518b925..3303ba4d6d94 100644 --- a/src/qemu/qemu_monitor_text.h +++ b/src/qemu/qemu_monitor_text.h @@ -131,20 +131,20 @@ int qemuMonitorTextAddUSBDeviceMatch(qemuMonitorPtr mon, int qemuMonitorTextAddPCIHostDevice(qemuMonitorPtr mon, - virDevicePCIAddress *hostAddr, - virDevicePCIAddress *guestAddr); + virPCIDeviceAddress *hostAddr, + virPCIDeviceAddress *guestAddr); int qemuMonitorTextAddPCIDisk(qemuMonitorPtr mon, const char *path, const char *bus, - virDevicePCIAddress *guestAddr); + virPCIDeviceAddress *guestAddr); int qemuMonitorTextAddPCINetwork(qemuMonitorPtr mon, const char *nicstr, - virDevicePCIAddress *guestAddr); + virPCIDeviceAddress *guestAddr); int qemuMonitorTextRemovePCIDevice(qemuMonitorPtr mon, - virDevicePCIAddress *guestAddr); + virPCIDeviceAddress *guestAddr); int qemuMonitorTextSendFileHandle(qemuMonitorPtr mon, const char *fdname, @@ -171,7 +171,7 @@ int qemuMonitorTextGetChardevInfo(qemuMonitorPtr mon, int qemuMonitorTextAttachPCIDiskController(qemuMonitorPtr mon, const char *bus, - virDevicePCIAddress *guestAddr); + virPCIDeviceAddress *guestAddr); int qemuMonitorTextGetAllPCIAddresses(qemuMonitorPtr mon, qemuMonitorPCIAddress **addrs); diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c index 7c7d7d0da92e..be993f19d49c 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -640,7 +640,7 @@ getAdapterName(virStoragePoolSourceAdapter adapter) if (adapter.type == VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { if (adapter.data.scsi_host.has_parent) { - virDevicePCIAddress addr = adapter.data.scsi_host.parentaddr; + virPCIDeviceAddress addr = adapter.data.scsi_host.parentaddr; unsigned int unique_id = adapter.data.scsi_host.unique_id; if (!(name = virGetSCSIHostNameByParentaddr(addr.domain, diff --git a/src/util/virpci.c b/src/util/virpci.c index f7921f86d6de..3f1252d42bbc 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -2517,7 +2517,7 @@ virPCIGetVirtualFunctions(const char *sysfs_path, int ret = -1; size_t i; char *device_link = NULL; - virPCIDeviceAddress *config_addr = NULL; + virPCIDeviceAddressPtr config_addr = NULL; char *totalvfs_file = NULL, *totalvfs_str = NULL; *virtual_functions = NULL; diff --git a/src/util/virpci.h b/src/util/virpci.h index 82f45ec4175f..5c63eab73615 100644 --- a/src/util/virpci.h +++ b/src/util/virpci.h @@ -40,6 +40,7 @@ struct _virPCIDeviceAddress { unsigned int bus; unsigned int slot; unsigned int function; + int multi; /* virTristateSwitch */ }; typedef enum { @@ -168,7 +169,7 @@ int virPCIDeviceFileIterate(virPCIDevicePtr dev, virPCIDeviceFileActor actor, void *opaque); -typedef int (*virPCIDeviceAddressActor)(virPCIDeviceAddress *addr, +typedef int (*virPCIDeviceAddressActor)(virPCIDeviceAddressPtr addr, void *opaque); int virPCIDeviceAddressIOMMUGroupIterate(virPCIDeviceAddressPtr orig, virPCIDeviceAddressActor actor, diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index cf7cdd034c8b..4dd6b417f767 100644 --- a/src/xen/xend_internal.c +++ b/src/xen/xend_internal.c @@ -2167,7 +2167,7 @@ xenDaemonAttachDeviceFlags(virConnectPtr conn, if (xenFormatSxprOnePCI(dev->data.hostdev, &buf, 0) < 0) goto cleanup; - virDevicePCIAddress PCIAddr; + virPCIDeviceAddress PCIAddr; PCIAddr = dev->data.hostdev->source.subsys.u.pci.addr; if (virAsprintf(&target, "PCI device: %.4x:%.2x:%.2x", -- 2.8.1

All sub-PCI capabilities should be next to each other for clarity. Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- docs/schemas/nodedev.rng | 22 +++++++++++----------- src/conf/node_device_conf.c | 9 ++++----- .../pci_0000_00_1c_0_header_type.xml | 2 +- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng index d9375130487c..6b9b54298b21 100644 --- a/docs/schemas/nodedev.rng +++ b/docs/schemas/nodedev.rng @@ -149,6 +149,17 @@ </optional> <optional> + <element name='capability'> + <attribute name='type'> + <choice> + <value>pci-bridge</value> + <value>cardbus-bridge</value> + </choice> + </attribute> + </element> + </optional> + + <optional> <element name='iommuGroup'> <attribute name='number'> <ref name='unsignedInt'/> @@ -170,17 +181,6 @@ </optional> <optional> - <element name='capability'> - <attribute name='type'> - <choice> - <value>pci-bridge</value> - <value>cardbus-bridge</value> - </choice> - </attribute> - </element> - </optional> - - <optional> <element name='pci-express'> <zeroOrMore> <element name='link'> diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index e7e4bbd390fa..96ec6a003714 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -383,6 +383,10 @@ char *virNodeDeviceDefFormat(const virNodeDeviceDef *def) virBufferAddLit(&buf, "</capability>\n"); } } + if (data->pci_dev.hdrType) { + virBufferAsprintf(&buf, "<capability type='%s'/>\n", + virPCIHeaderTypeToString(data->pci_dev.hdrType)); + } if (data->pci_dev.nIommuGroupDevices) { virBufferAsprintf(&buf, "<iommuGroup number='%d'>\n", data->pci_dev.iommuGroupNumber); @@ -403,11 +407,6 @@ char *virNodeDeviceDefFormat(const virNodeDeviceDef *def) virBufferAsprintf(&buf, "<numa node='%d'/>\n", data->pci_dev.numa_node); - if (data->pci_dev.hdrType) { - virBufferAsprintf(&buf, "<capability type='%s'/>\n", - virPCIHeaderTypeToString(data->pci_dev.hdrType)); - } - if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCIE) virPCIEDeviceInfoFormat(&buf, data->pci_dev.pci_express); break; diff --git a/tests/nodedevschemadata/pci_0000_00_1c_0_header_type.xml b/tests/nodedevschemadata/pci_0000_00_1c_0_header_type.xml index dea5f05237ff..c1be9f7d9cc0 100644 --- a/tests/nodedevschemadata/pci_0000_00_1c_0_header_type.xml +++ b/tests/nodedevschemadata/pci_0000_00_1c_0_header_type.xml @@ -8,10 +8,10 @@ <function>0</function> <product id='0x8c10'>8 Series/C220 Series Chipset Family PCI Express Root Port #1</product> <vendor id='0x8086'>Intel Corporation</vendor> + <capability type='pci-bridge'/> <iommuGroup number='8'> <address domain='0x0000' bus='0x00' slot='0x1c' function='0x0'/> </iommuGroup> - <capability type='pci-bridge'/> <pci-express> <link validity='cap' port='1' speed='5' width='1'/> <link validity='sta' speed='2.5' width='1'/> -- 2.8.1

There were few things done in the nodedev code but we were lacking tests for it. And because of that we missed that the schema was not updated either. Fix the schema and add various test files to show the schema is correct. Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- docs/schemas/nodedev.rng | 7 ++++- tests/nodedevschemadata/pci_0000_02_10_7_sriov.xml | 23 +++++++++++++++++ .../pci_0000_02_10_7_sriov_pf_vfs_all.xml | 29 +++++++++++++++++++++ ...i_0000_02_10_7_sriov_pf_vfs_all_header_type.xml | 30 ++++++++++++++++++++++ .../pci_0000_02_10_7_sriov_vfs.xml | 26 +++++++++++++++++++ .../pci_0000_02_10_7_sriov_zero_vfs_max_count.xml | 21 +++++++++++++++ 6 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 tests/nodedevschemadata/pci_0000_02_10_7_sriov.xml create mode 100644 tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all.xml create mode 100644 tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all_header_type.xml create mode 100644 tests/nodedevschemadata/pci_0000_02_10_7_sriov_vfs.xml create mode 100644 tests/nodedevschemadata/pci_0000_02_10_7_sriov_zero_vfs_max_count.xml diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng index 6b9b54298b21..93a88d883056 100644 --- a/docs/schemas/nodedev.rng +++ b/docs/schemas/nodedev.rng @@ -143,8 +143,13 @@ <value>virt_functions</value> </attribute> <optional> - <ref name='address'/> + <attribute name='maxCount'> + <ref name='unsignedInt'/> + </attribute> </optional> + <zeroOrMore> + <ref name='address'/> + </zeroOrMore> </element> </optional> diff --git a/tests/nodedevschemadata/pci_0000_02_10_7_sriov.xml b/tests/nodedevschemadata/pci_0000_02_10_7_sriov.xml new file mode 100644 index 000000000000..8f243b4d6119 --- /dev/null +++ b/tests/nodedevschemadata/pci_0000_02_10_7_sriov.xml @@ -0,0 +1,23 @@ +<device> + <name>pci_0000_02_10_7</name> + <parent>pci_0000_00_04_0</parent> + <capability type='pci'> + <domain>0</domain> + <bus>2</bus> + <slot>16</slot> + <function>7</function> + <product id='0x10ca'>82576 Virtual Function</product> + <vendor id='0x8086'>Intel Corporation</vendor> + <capability type='phys_function'> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x1'/> + </capability> + <iommuGroup number='31'> + <address domain='0x0000' bus='0x02' slot='0x10' function='0x7'/> + </iommuGroup> + <numa node='0'/> + <pci-express> + <link validity='cap' port='0' speed='2.5' width='4'/> + <link validity='sta' width='0'/> + </pci-express> + </capability> +</device> diff --git a/tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all.xml b/tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all.xml new file mode 100644 index 000000000000..9e8dace020a1 --- /dev/null +++ b/tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all.xml @@ -0,0 +1,29 @@ +<device> + <name>pci_0000_02_10_7</name> + <parent>pci_0000_00_04_0</parent> + <capability type='pci'> + <domain>0</domain> + <bus>2</bus> + <slot>16</slot> + <function>7</function> + <product id='0x10ca'>82576 Virtual Function</product> + <vendor id='0x8086'>Intel Corporation</vendor> + <capability type='phys_function'> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x1'/> + </capability> + <capability type='virt_functions' maxCount='7'> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x2'/> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x3'/> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x4'/> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x5'/> + </capability> + <iommuGroup number='31'> + <address domain='0x0000' bus='0x02' slot='0x10' function='0x7'/> + </iommuGroup> + <numa node='0'/> + <pci-express> + <link validity='cap' port='0' speed='2.5' width='4'/> + <link validity='sta' width='0'/> + </pci-express> + </capability> +</device> diff --git a/tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all_header_type.xml b/tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all_header_type.xml new file mode 100644 index 000000000000..4e6323a3ecdd --- /dev/null +++ b/tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all_header_type.xml @@ -0,0 +1,30 @@ +<device> + <name>pci_0000_02_10_7</name> + <parent>pci_0000_00_04_0</parent> + <capability type='pci'> + <domain>0</domain> + <bus>2</bus> + <slot>16</slot> + <function>7</function> + <product id='0x10ca'>82576 Virtual Function</product> + <vendor id='0x8086'>Intel Corporation</vendor> + <capability type='phys_function'> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x1'/> + </capability> + <capability type='virt_functions' maxCount='7'> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x2'/> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x3'/> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x4'/> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x5'/> + </capability> + <capability type='pci-bridge'/> + <iommuGroup number='31'> + <address domain='0x0000' bus='0x02' slot='0x10' function='0x7'/> + </iommuGroup> + <numa node='0'/> + <pci-express> + <link validity='cap' port='0' speed='2.5' width='4'/> + <link validity='sta' width='0'/> + </pci-express> + </capability> +</device> diff --git a/tests/nodedevschemadata/pci_0000_02_10_7_sriov_vfs.xml b/tests/nodedevschemadata/pci_0000_02_10_7_sriov_vfs.xml new file mode 100644 index 000000000000..355eaaad97d4 --- /dev/null +++ b/tests/nodedevschemadata/pci_0000_02_10_7_sriov_vfs.xml @@ -0,0 +1,26 @@ +<device> + <name>pci_0000_02_10_7</name> + <parent>pci_0000_00_04_0</parent> + <capability type='pci'> + <domain>0</domain> + <bus>2</bus> + <slot>16</slot> + <function>7</function> + <product id='0x10ca'>82576 Virtual Function</product> + <vendor id='0x8086'>Intel Corporation</vendor> + <capability type='virt_functions'> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x2'/> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x3'/> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x4'/> + <address domain='0x0000' bus='0x02' slot='0x00' function='0x5'/> + </capability> + <iommuGroup number='31'> + <address domain='0x0000' bus='0x02' slot='0x10' function='0x7'/> + </iommuGroup> + <numa node='0'/> + <pci-express> + <link validity='cap' port='0' speed='2.5' width='4'/> + <link validity='sta' width='0'/> + </pci-express> + </capability> +</device> diff --git a/tests/nodedevschemadata/pci_0000_02_10_7_sriov_zero_vfs_max_count.xml b/tests/nodedevschemadata/pci_0000_02_10_7_sriov_zero_vfs_max_count.xml new file mode 100644 index 000000000000..e9eb122bfec9 --- /dev/null +++ b/tests/nodedevschemadata/pci_0000_02_10_7_sriov_zero_vfs_max_count.xml @@ -0,0 +1,21 @@ +<device> + <name>pci_0000_02_10_7</name> + <parent>pci_0000_00_04_0</parent> + <capability type='pci'> + <domain>0</domain> + <bus>2</bus> + <slot>16</slot> + <function>7</function> + <product id='0x10ca'>82576 Virtual Function</product> + <vendor id='0x8086'>Intel Corporation</vendor> + <capability type='virt_functions' maxCount='3'/> + <iommuGroup number='31'> + <address domain='0x0000' bus='0x02' slot='0x10' function='0x7'/> + </iommuGroup> + <numa node='0'/> + <pci-express> + <link validity='cap' port='0' speed='2.5' width='4'/> + <link validity='sta' width='0'/> + </pci-express> + </capability> +</device> -- 2.8.1

We were lacking tests that are checking for the completeness of our nodedev XMLs and also whether we output properly formatted ones. This patch adds parsing for the capability elements inside the <capability type='pci'> element. Also bunch of tests are added to show everything works properly. Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/conf/node_device_conf.c | 98 +++++++++++++++++++++++++++++++++++++++++++++ tests/nodedevxml2xmltest.c | 7 ++++ 2 files changed, 105 insertions(+) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 96ec6a003714..a06e45042851 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1269,15 +1269,103 @@ virPCIEDeviceInfoParseXML(xmlXPathContextPtr ctxt, static int +virNodeDevPCICapabilityParseXML(xmlXPathContextPtr ctxt, + xmlNodePtr node, + virNodeDevCapDataPtr data) +{ + char *maxFuncsStr = virXMLPropString(node, "maxCount"); + char *type = virXMLPropString(node, "type"); + xmlNodePtr *addresses = NULL; + xmlNodePtr orignode = ctxt->node; + int ret = -1; + size_t i = 0; + + ctxt->node = node; + + if (!type) { + virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing capability type")); + goto out; + } + + if (STREQ(type, "phys_function")) { + xmlNodePtr address = virXPathNode("./address[1]", ctxt); + + if (VIR_ALLOC(data->pci_dev.physical_function) < 0) + goto out; + + data->pci_dev.flags |= VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION; + + if (!address) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing address in 'phys_function' capability")); + goto out; + } + + if (virPCIDeviceAddressParseXML(address, + data->pci_dev.physical_function) < 0) + goto out; + } else if (STREQ(type, "virt_functions")) { + int naddresses = virXPathNodeSet("./address", ctxt, &addresses); + + if (maxFuncsStr && + virStrToLong_uip(maxFuncsStr, NULL, 10, + &data->pci_dev.max_virtual_functions) < 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Malformed 'maxCount' parameter")); + goto out; + } + + if (VIR_ALLOC_N(data->pci_dev.virtual_functions, naddresses) < 0) + goto out; + + for (i = 0; i < naddresses; i++) { + virPCIDeviceAddressPtr addr = NULL; + + if (VIR_ALLOC(addr) < 0) + goto out; + + if (virPCIDeviceAddressParseXML(addresses[i], addr) < 0) { + VIR_FREE(addr); + goto out; + } + + if (VIR_APPEND_ELEMENT(data->pci_dev.virtual_functions, + data->pci_dev.num_virtual_functions, + addr) < 0) + goto out; + } + + data->pci_dev.flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION; + } else { + int hdrType = virPCIHeaderTypeFromString(type); + + if (hdrType > 0 && !data->pci_dev.hdrType) + data->pci_dev.hdrType = hdrType; + } + + ret = 0; + out: + VIR_FREE(addresses); + VIR_FREE(maxFuncsStr); + VIR_FREE(type); + ctxt->node = orignode; + return ret; +} + + +static int virNodeDevCapPCIDevParseXML(xmlXPathContextPtr ctxt, virNodeDeviceDefPtr def, xmlNodePtr node, virNodeDevCapDataPtr data) { xmlNodePtr orignode, iommuGroupNode, pciExpress; + xmlNodePtr *nodes = NULL; + int n = 0; int ret = -1; virPCIEDeviceInfoPtr pci_express = NULL; char *tmp = NULL; + size_t i = 0; orignode = ctxt->node; ctxt->node = node; @@ -1321,6 +1409,15 @@ virNodeDevCapPCIDevParseXML(xmlXPathContextPtr ctxt, data->pci_dev.vendor_name = virXPathString("string(./vendor[1])", ctxt); data->pci_dev.product_name = virXPathString("string(./product[1])", ctxt); + if ((n = virXPathNodeSet("./capability", ctxt, &nodes)) < 0) + goto out; + + for (i = 0; i < n; i++) { + if (virNodeDevPCICapabilityParseXML(ctxt, nodes[i], data) < 0) + goto out; + } + VIR_FREE(nodes); + if ((iommuGroupNode = virXPathNode("./iommuGroup[1]", ctxt))) { if (virNodeDevCapPCIDevIommuGroupParseXML(ctxt, iommuGroupNode, data) < 0) { @@ -1349,6 +1446,7 @@ virNodeDevCapPCIDevParseXML(xmlXPathContextPtr ctxt, ret = 0; out: + VIR_FREE(nodes); VIR_FREE(tmp); virPCIEDeviceInfoFree(pci_express); ctxt->node = orignode; diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c index 96041f50b9cd..0ed06fdff3e2 100644 --- a/tests/nodedevxml2xmltest.c +++ b/tests/nodedevxml2xmltest.c @@ -91,7 +91,14 @@ mymain(void) DO_TEST("usb_device_1d6b_1_0000_00_1d_0"); DO_TEST("pci_8086_4238_pcie_wireless"); DO_TEST("pci_8086_0c0c_snd_hda_intel"); + DO_TEST("pci_0000_00_02_0_header_type"); + DO_TEST("pci_0000_00_1c_0_header_type"); DO_TEST("scsi_target0_0_0"); + DO_TEST("pci_0000_02_10_7_sriov"); + DO_TEST("pci_0000_02_10_7_sriov_vfs"); + DO_TEST("pci_0000_02_10_7_sriov_zero_vfs_max_count"); + DO_TEST("pci_0000_02_10_7_sriov_pf_vfs_all"); + DO_TEST("pci_0000_02_10_7_sriov_pf_vfs_all_header_type"); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } -- 2.8.1

On 28.04.2016 16:26, Martin Kletzander wrote:
v3: - Actually use virPCIDeviceAddress. It was actually ACKed with that changed but I feel like it's way too big of a change for just pushing it. Also, I'm in no rush with this, so I'l gladly wait after therelease with this.
v2: - Just a rebase - I did *not* use virPCIDeviceAddress wording instead as discussed in the v1 thread. That's because we have lot of functions working with virDevicePCIAddress named exactly after that and renaming those would be ugly IMHO. - https://www.redhat.com/archives/libvir-list/2016-April/msg00714.html
v1: - https://www.redhat.com/archives/libvir-list/2016-April/msg00081.html
Martin Kletzander (4): Change virDevicePCIAddress to virPCIDeviceAddress Move capability formatting together schemas: Update nodedev schema to match reality conf: Parse more of our nodedev XML
docs/schemas/nodedev.rng | 29 +++--- src/bhyve/bhyve_device.c | 4 +- src/conf/device_conf.c | 16 +-- src/conf/device_conf.h | 25 ++--- src/conf/domain_addr.c | 24 ++--- src/conf/domain_addr.h | 22 ++-- src/conf/domain_conf.c | 26 ++--- src/conf/domain_conf.h | 10 +- src/conf/network_conf.c | 8 +- src/conf/network_conf.h | 2 +- src/conf/node_device_conf.c | 111 +++++++++++++++++++-- src/conf/storage_conf.c | 14 +-- src/conf/storage_conf.h | 2 +- src/libvirt_private.syms | 8 +- src/network/bridge_driver.c | 4 +- src/qemu/qemu_agent.c | 2 +- src/qemu/qemu_domain_address.c | 12 +-- src/qemu/qemu_hotplug.c | 10 +- src/qemu/qemu_monitor.c | 12 +-- src/qemu/qemu_monitor.h | 14 +-- src/qemu/qemu_monitor_json.c | 12 +-- src/qemu/qemu_monitor_json.h | 12 +-- src/qemu/qemu_monitor_text.c | 14 +-- src/qemu/qemu_monitor_text.h | 12 +-- src/storage/storage_backend_scsi.c | 2 +- src/util/virpci.c | 2 +- src/util/virpci.h | 3 +- src/xen/xend_internal.c | 2 +- .../pci_0000_00_1c_0_header_type.xml | 2 +- tests/nodedevschemadata/pci_0000_02_10_7_sriov.xml | 23 +++++ .../pci_0000_02_10_7_sriov_pf_vfs_all.xml | 29 ++++++ ...i_0000_02_10_7_sriov_pf_vfs_all_header_type.xml | 30 ++++++ .../pci_0000_02_10_7_sriov_vfs.xml | 26 +++++ .../pci_0000_02_10_7_sriov_zero_vfs_max_count.xml | 21 ++++ tests/nodedevxml2xmltest.c | 7 ++ 35 files changed, 391 insertions(+), 161 deletions(-) create mode 100644 tests/nodedevschemadata/pci_0000_02_10_7_sriov.xml create mode 100644 tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all.xml create mode 100644 tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all_header_type.xml create mode 100644 tests/nodedevschemadata/pci_0000_02_10_7_sriov_vfs.xml create mode 100644 tests/nodedevschemadata/pci_0000_02_10_7_sriov_zero_vfs_max_count.xml
ACK series Michal
participants (2)
-
Martin Kletzander
-
Michal Privoznik