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(a)linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn(a)redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma(a)redhat.com>
---
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