mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 23:25:24 +00:00
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 <mprivozn@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
4c1033a151
commit
bfa8cf4b29
@ -1222,17 +1222,15 @@ udevGetDeviceDetails(struct udev_device *device,
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
udevRemoveOneDevice(struct udev_device *device)
|
udevRemoveOneDeviceSysPath(const char *path)
|
||||||
{
|
{
|
||||||
virNodeDeviceObjPtr obj = NULL;
|
virNodeDeviceObjPtr obj = NULL;
|
||||||
virNodeDeviceDefPtr def;
|
virNodeDeviceDefPtr def;
|
||||||
virObjectEventPtr event = NULL;
|
virObjectEventPtr event = NULL;
|
||||||
const char *name = NULL;
|
|
||||||
|
|
||||||
name = udev_device_get_syspath(device);
|
if (!(obj = virNodeDeviceObjListFindBySysfsPath(driver->devs, path))) {
|
||||||
if (!(obj = virNodeDeviceObjListFindBySysfsPath(driver->devs, name))) {
|
VIR_DEBUG("Failed to find device to remove that has udev path '%s'",
|
||||||
VIR_DEBUG("Failed to find device to remove that has udev name '%s'",
|
path);
|
||||||
name);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
def = virNodeDeviceObjGetDef(obj);
|
def = virNodeDeviceObjGetDef(obj);
|
||||||
@ -1242,7 +1240,7 @@ udevRemoveOneDevice(struct udev_device *device)
|
|||||||
0);
|
0);
|
||||||
|
|
||||||
VIR_DEBUG("Removing device '%s' with sysfs path '%s'",
|
VIR_DEBUG("Removing device '%s' with sysfs path '%s'",
|
||||||
def->name, name);
|
def->name, path);
|
||||||
virNodeDeviceObjListRemove(driver->devs, obj);
|
virNodeDeviceObjListRemove(driver->devs, obj);
|
||||||
virNodeDeviceObjEndAPI(&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
|
static int
|
||||||
udevSetParent(struct udev_device *device,
|
udevSetParent(struct udev_device *device,
|
||||||
virNodeDeviceDefPtr def)
|
virNodeDeviceDefPtr def)
|
||||||
|
Loading…
Reference in New Issue
Block a user