From: Dan Zheng Date: Tue, 16 Jan 2018 04:21:21 +0000 (+0800) Subject: nodedev: Add the missing PCI dev checks for 'mdev_types' capability X-Git-Tag: v4.0.0-rc2^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=75cfb8434eab67b790c5979deafd63396bf84ece;p=thirdparty%2Flibvirt.git nodedev: Add the missing PCI dev checks for 'mdev_types' capability Similar to commit @f44ec9c1, commit @500cbc06 introduced a new nested 'mdev_types' capability, however the mentioned commit didn't adjust virNodeDeviceNumOfCaps and virNodeDeviceListCaps functions accordingly to provide proper support for this capability. After applying this patch the following python snippet returns the expected results: import libvirt conn = libvirt.openReadOnly('qemu:///system') devs = conn.listAllDevices() for dev in devs: if 'mdev_types' in dev.listCaps(): print dev.name(),dev.numOfCaps(),dev.listCaps() Signed-off-by: Dan Zheng Signed-off-by: Erik Skultety --- diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index facfeb6957..6216a69773 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -382,6 +382,12 @@ nodeDeviceNumOfCaps(virNodeDevicePtr device) VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS) ncaps++; } + if (caps->data.type == VIR_NODE_DEV_CAP_PCI_DEV) { + if (caps->data.pci_dev.flags & + VIR_NODE_DEV_CAP_FLAG_PCI_MDEV) + ncaps++; + } + } ret = ncaps; @@ -432,6 +438,15 @@ nodeDeviceListCaps(virNodeDevicePtr device, goto cleanup; } } + if (caps->data.type == VIR_NODE_DEV_CAP_PCI_DEV) { + if (ncaps < maxnames && + caps->data.pci_dev.flags & + VIR_NODE_DEV_CAP_FLAG_PCI_MDEV) { + if (VIR_STRDUP(names[ncaps++], + virNodeDevCapTypeToString(VIR_NODE_DEV_CAP_MDEV_TYPES)) < 0) + goto cleanup; + } + } } ret = ncaps;