From f2f656d426e2829ba93ddf153294bff16cdf9976 Mon Sep 17 00:00:00 2001 From: Dave Allan Date: Thu, 19 Nov 2009 16:02:18 +0100 Subject: [PATCH] Removing devicePath member from dev struct I realized that I inadvertently added a member to the def struct to contain each device's sysfs path when there was an existing member in the dev struct for "OS specific path to device metadat, eg sysfs" Since the udev backend needs to record the sysfs path while it's in the process of creating the device, before the dev struct gets allocated, I chose to remove the member from the dev struct. * src/conf/node_device_conf.c src/conf/node_device_conf.h src/node_device/node_device_driver.c src/node_device/node_device_hal.c src/node_device/node_device_udev.c: remove devicePath from the structure and use def->sysfs_path instead --- src/conf/node_device_conf.c | 1 - src/conf/node_device_conf.h | 1 - src/node_device/node_device_driver.c | 2 +- src/node_device/node_device_hal.c | 2 +- src/node_device/node_device_udev.c | 7 ------- 5 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index f55c9c76c3..f2faeec62c 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -156,7 +156,6 @@ void virNodeDeviceObjFree(virNodeDeviceObjPtr dev) if (!dev) return; - VIR_FREE(dev->devicePath); virNodeDeviceDefFree(dev->def); if (dev->privateFree) (*dev->privateFree)(dev->privateData); diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index 639a7e7a70..7a20bd67bb 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -178,7 +178,6 @@ typedef virNodeDeviceObj *virNodeDeviceObjPtr; struct _virNodeDeviceObj { virMutex lock; - char *devicePath; /* OS specific path to device metadat, eg sysfs */ virNodeDeviceDefPtr def; /* device definition */ void *privateData; /* driver-specific private data */ void (*privateFree)(void *data); /* destructor for private data */ diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index b474d434e5..f083f168a2 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -85,7 +85,7 @@ static int update_driver_name(virConnectPtr conn, VIR_FREE(dev->def->driver); - if (virAsprintf(&driver_link, "%s/driver", dev->devicePath) < 0) { + if (virAsprintf(&driver_link, "%s/driver", dev->def->sysfs_path) < 0) { virReportOOMError(conn); goto cleanup; } diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c index 1e1d872cd2..31c1764484 100644 --- a/src/node_device/node_device_hal.c +++ b/src/node_device/node_device_hal.c @@ -470,7 +470,7 @@ static void dev_create(const char *udi) dev->privateData = privData; dev->privateFree = free_udi; - dev->devicePath = devicePath; + dev->def->sysfs_path = devicePath; virNodeDeviceObjUnlock(dev); diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 4ddf360fe6..9b48052929 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1230,13 +1230,6 @@ static int udevAddOneDevice(struct udev_device *device) goto out; } - dev->devicePath = strdup(udev_device_get_devpath(device)); - if (dev->devicePath == NULL) { - virReportOOMError(NULL); - virNodeDeviceObjRemove(&driverState->devs, dev); - goto out; - } - virNodeDeviceObjUnlock(dev); ret = 0; -- GitLab