[libvirt] [PATCH 5/6] node_device: update sriov/iommu info before dumpxml of a device

Laine Stump laine at laine.org
Fri May 15 15:04:28 UTC 2015

Because reloading a PF driver with a different number of VFs doesn't
result in any sort of event sent from udev to the libvirt node_device
driver, libvirt's cache of that info can be out of date when a request
arrives for the info about a device. To fix this, we refresh that data
at the time of the dumpxml request, similar to what is already done
for netdev link info and SCSI host capabilities.

Since the same is true for iommu group information (for example, some
other device in the same iommu group could have been detached from the
host), we also create a function to update the iommu group info from
sysfs, and a common function that does both. (a later patch will call
this common function from the udev and hal backends).

This resolves:

 src/node_device/node_device_driver.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index c9db00a..34ba1fa 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -59,12 +59,16 @@ static int update_caps(virNodeDeviceObjPtr dev)
             if (virNetDevGetLinkInfo(cap->data.net.ifname, &cap->data.net.lnk) < 0)
                 return -1;
+        case VIR_NODE_DEV_CAP_PCI_DEV:
+           if (nodeDeviceSysfsGetPCIRelatedDevCaps(dev->def->sysfs_path,
+                                                   &dev->def->caps->data) < 0)
+              return -1;
+           break;
         /* all types that (supposedly) don't require any updates
          * relative to what's in the cache.
         case VIR_NODE_DEV_CAP_SYSTEM:
-        case VIR_NODE_DEV_CAP_PCI_DEV:
         case VIR_NODE_DEV_CAP_USB_DEV:

More information about the libvir-list mailing list