From 75cfb8434eab67b790c5979deafd63396bf84ece Mon Sep 17 00:00:00 2001 From: Dan Zheng Date: Tue, 16 Jan 2018 12:21:21 +0800 Subject: [PATCH] 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 --- src/node_device/node_device_driver.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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;