[PATCH v2 4/4] nodedev: trigger mdev device definition update on udev add and remove

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When nodedev objects are added and removed if possible check if mdev-types is
supported by the object and trigger a mdev device definition update to correct
the associated parent nodedevs.

Signed-off-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxx>
Reviewed-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
Reviewed-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
---
 src/node_device/node_device_udev.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 17b6bb9299..b3e8103dae 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1440,6 +1440,10 @@ udevRemoveOneDeviceSysPath(const char *path)
     }
     virNodeDeviceObjEndAPI(&obj);
 
+    /* cannot check for mdev_types since they have already been removed */
+    if (nodeDeviceUpdateMediatedDevices() < 0)
+        VIR_WARN("mdevctl failed to update mediated devices");
+
     virObjectEventStateQueue(driver->nodeDeviceEventState, event);
     return 0;
 }
@@ -1507,6 +1511,7 @@ udevAddOneDevice(struct udev_device *device)
     bool persistent = false;
     bool autostart = false;
     bool is_mdev;
+    bool has_mdev_types = false;
 
     def = g_new0(virNodeDeviceDef, 1);
 
@@ -1562,8 +1567,12 @@ udevAddOneDevice(struct udev_device *device)
         event = virNodeDeviceEventUpdateNew(objdef->name);
 
     virNodeDeviceObjSetActive(obj, true);
+    has_mdev_types = virNodeDeviceObjHasCap(obj, VIR_NODE_DEV_CAP_MDEV_TYPES);
     virNodeDeviceObjEndAPI(&obj);
 
+    if (has_mdev_types && nodeDeviceUpdateMediatedDevices() < 0)
+        VIR_WARN("mdevctl failed to update mediated devices");
+
     ret = 0;
 
  cleanup:
-- 
2.33.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux