nodedev: trigger mdev device definition update on udev add and remove

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@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
Boris Fiuczynski 2022-03-17 10:48:30 +01:00 committed by Michal Privoznik
parent 06aebe8f9a
commit 8efdf5b083

View File

@ -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: