From bfa8cf4b299086719bc644fcb70f24793b5eb49a Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Mon, 20 Apr 2020 15:59:19 +0200 Subject: [PATCH] node_device_udev: Split udevRemoveOneDevice() into two Move internals of udevRemoveOneDevice() into a separate function which accepts sysfs path as an argument and actually removes the device from the internal list. It will be reused later. Signed-off-by: Michal Privoznik Reviewed-by: Martin Kletzander --- src/node_device/node_device_udev.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 0166a13b0f..e9a76a7b01 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1222,17 +1222,15 @@ udevGetDeviceDetails(struct udev_device *device, static int -udevRemoveOneDevice(struct udev_device *device) +udevRemoveOneDeviceSysPath(const char *path) { virNodeDeviceObjPtr obj = NULL; virNodeDeviceDefPtr def; virObjectEventPtr event = NULL; - const char *name = NULL; - name = udev_device_get_syspath(device); - if (!(obj = virNodeDeviceObjListFindBySysfsPath(driver->devs, name))) { - VIR_DEBUG("Failed to find device to remove that has udev name '%s'", - name); + if (!(obj = virNodeDeviceObjListFindBySysfsPath(driver->devs, path))) { + VIR_DEBUG("Failed to find device to remove that has udev path '%s'", + path); return -1; } def = virNodeDeviceObjGetDef(obj); @@ -1242,7 +1240,7 @@ udevRemoveOneDevice(struct udev_device *device) 0); VIR_DEBUG("Removing device '%s' with sysfs path '%s'", - def->name, name); + def->name, path); virNodeDeviceObjListRemove(driver->devs, obj); virNodeDeviceObjEndAPI(&obj); @@ -1251,6 +1249,15 @@ udevRemoveOneDevice(struct udev_device *device) } +static int +udevRemoveOneDevice(struct udev_device *device) +{ + const char *path = udev_device_get_syspath(device); + + return udevRemoveOneDeviceSysPath(path); +} + + static int udevSetParent(struct udev_device *device, virNodeDeviceDefPtr def)