[libvirt] [PATCH 08/15] conf: nodedev: Refresh capabilities before touching them

Erik Skultety eskultet at redhat.com
Thu Jan 25 09:23:55 UTC 2018


Most of them are static, however in case of PCI and SCSI_HOST devices,
the nested capabilities can change dynamically, e.g. due to a driver
change (from host_pci_driver -> vfio_pci).

Signed-off-by: Erik Skultety <eskultet at redhat.com>
Suggested-by: Wu Zongyong <cordius.wu at huawei.com>
---
 src/conf/node_device_conf.c | 3 +++
 src/conf/virnodedeviceobj.c | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 9467bb415..3aefc9e5b 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -2515,6 +2515,9 @@ virNodeDeviceCapsListExport(virNodeDeviceDefPtr def,
             tmp[ncaps] = cap; \
     } while (0)
 
+    if (virNodeDeviceUpdateCaps(def) < 0)
+        goto cleanup;
+
     if (want_list && VIR_ALLOC_N(tmp, VIR_NODE_DEV_CAP_LAST - 1) < 0)
         goto cleanup;
 
diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
index 5360df805..34f754454 100644
--- a/src/conf/virnodedeviceobj.c
+++ b/src/conf/virnodedeviceobj.c
@@ -809,6 +809,10 @@ static bool
 virNodeDeviceMatch(virNodeDeviceObjPtr obj,
                    unsigned int flags)
 {
+    /* Refresh the capabilities first, e.g. due to a driver change */
+    if (virNodeDeviceUpdateCaps(obj->def) < 0)
+        return false;
+
     /* filter by cap type */
     if (flags & VIR_CONNECT_LIST_NODE_DEVICES_FILTERS_CAP) {
         if (!(MATCH(SYSTEM)        ||
-- 
2.13.6




More information about the libvir-list mailing list