mirror of https://gitee.com/openkylin/libvirt.git
nodedev: Alter param to nodeDeviceUpdateDriverName
Rather than taking an virNodeDeviceObjPtr and dereffing the obj->def, just pass the def. Also check for an error in the function to have the calling function goto cleanup on error. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
18c551f378
commit
381bbfbbb6
|
@ -110,16 +110,16 @@ nodeDeviceUpdateCaps(virNodeDeviceObjPtr dev)
|
||||||
* udev *and* HAL backends.
|
* udev *and* HAL backends.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
nodeDeviceUpdateDriverName(virNodeDeviceObjPtr dev)
|
nodeDeviceUpdateDriverName(virNodeDeviceDefPtr def)
|
||||||
{
|
{
|
||||||
char *driver_link = NULL;
|
char *driver_link = NULL;
|
||||||
char *devpath = NULL;
|
char *devpath = NULL;
|
||||||
char *p;
|
char *p;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
VIR_FREE(dev->def->driver);
|
VIR_FREE(def->driver);
|
||||||
|
|
||||||
if (virAsprintf(&driver_link, "%s/driver", dev->def->sysfs_path) < 0)
|
if (virAsprintf(&driver_link, "%s/driver", def->sysfs_path) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
/* Some devices don't have an explicit driver, so just return
|
/* Some devices don't have an explicit driver, so just return
|
||||||
|
@ -136,7 +136,7 @@ nodeDeviceUpdateDriverName(virNodeDeviceObjPtr dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
p = strrchr(devpath, '/');
|
p = strrchr(devpath, '/');
|
||||||
if (p && VIR_STRDUP(dev->def->driver, p + 1) < 0)
|
if (p && VIR_STRDUP(def->driver, p + 1) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ nodeDeviceUpdateDriverName(virNodeDeviceObjPtr dev)
|
||||||
#else
|
#else
|
||||||
/* XXX: Implement me for non-linux */
|
/* XXX: Implement me for non-linux */
|
||||||
static int
|
static int
|
||||||
nodeDeviceUpdateDriverName(virNodeDeviceObjPtr dev ATTRIBUTE_UNUSED)
|
nodeDeviceUpdateDriverName(virNodeDeviceDefPtr def ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -352,7 +352,9 @@ nodeDeviceGetXMLDesc(virNodeDevicePtr dev,
|
||||||
if (virNodeDeviceGetXMLDescEnsureACL(dev->conn, obj->def) < 0)
|
if (virNodeDeviceGetXMLDescEnsureACL(dev->conn, obj->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
nodeDeviceUpdateDriverName(obj);
|
if (nodeDeviceUpdateDriverName(obj->def) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (nodeDeviceUpdateCaps(obj) < 0)
|
if (nodeDeviceUpdateCaps(obj) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue