]> xenbits.xensource.com Git - libvirt.git/commitdiff
nodedev: transient mdev update on nodeDeviceCreateXML
authorBoris Fiuczynski <fiuczy@linux.ibm.com>
Fri, 30 Jun 2023 11:34:00 +0000 (13:34 +0200)
committerJonathon Jongsma <jjongsma@redhat.com>
Thu, 13 Jul 2023 14:43:34 +0000 (09:43 -0500)
Update the optional mdev attributes by running an mdevctl update on a
new created nodedev object representing an mdev.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2143158
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
src/node_device/node_device_udev.c

index 960f3fd942eae661a09e99bb694d9d2a124cd7bf..921186535313ed295129ebf78a29753626f6b9c2 100644 (file)
@@ -1765,12 +1765,20 @@ nodeStateCleanup(void)
 static int
 udevHandleOneDevice(struct udev_device *device)
 {
+    virNodeDevCapType dev_cap_type;
     const char *action = udev_device_get_action(device);
 
     VIR_DEBUG("udev action: '%s': %s", action, udev_device_get_syspath(device));
 
-    if (STREQ(action, "add") || STREQ(action, "change"))
-        return udevAddOneDevice(device);
+    if (STREQ(action, "add") || STREQ(action, "change")) {
+        int ret = udevAddOneDevice(device);
+        if (ret == 0 &&
+            udevGetDeviceType(device, &dev_cap_type) == 0 &&
+            dev_cap_type == VIR_NODE_DEV_CAP_MDEV)
+            if (nodeDeviceUpdateMediatedDevices() < 0)
+                VIR_WARN("mdevctl failed to update mediated devices");
+        return ret;
+    }
 
     if (STREQ(action, "remove"))
         return udevRemoveOneDevice(device);