]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
node_device_udev: Split udevRemoveOneDevice() into two
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 20 Apr 2020 13:59:19 +0000 (15:59 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 22 Apr 2020 10:51:15 +0000 (12:51 +0200)
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 <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/node_device/node_device_udev.c

index 0166a13b0fb230460ffcc95574b9f25ff04aad61..e9a76a7b010f565618a22d8864198411283aa2ed 100644 (file)
@@ -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)