提交 bfa8cf4b 编写于 作者: M Michal Privoznik

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: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NMartin Kletzander <mkletzan@redhat.com>
上级 4c1033a1
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册