提交 381bbfbb 编写于 作者: J John Ferlan

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: NJohn Ferlan <jferlan@redhat.com>
上级 18c551f3
......@@ -110,16 +110,16 @@ nodeDeviceUpdateCaps(virNodeDeviceObjPtr dev)
* udev *and* HAL backends.
*/
static int
nodeDeviceUpdateDriverName(virNodeDeviceObjPtr dev)
nodeDeviceUpdateDriverName(virNodeDeviceDefPtr def)
{
char *driver_link = NULL;
char *devpath = NULL;
char *p;
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;
/* Some devices don't have an explicit driver, so just return
......@@ -136,7 +136,7 @@ nodeDeviceUpdateDriverName(virNodeDeviceObjPtr dev)
}
p = strrchr(devpath, '/');
if (p && VIR_STRDUP(dev->def->driver, p + 1) < 0)
if (p && VIR_STRDUP(def->driver, p + 1) < 0)
goto cleanup;
ret = 0;
......@@ -148,7 +148,7 @@ nodeDeviceUpdateDriverName(virNodeDeviceObjPtr dev)
#else
/* XXX: Implement me for non-linux */
static int
nodeDeviceUpdateDriverName(virNodeDeviceObjPtr dev ATTRIBUTE_UNUSED)
nodeDeviceUpdateDriverName(virNodeDeviceDefPtr def ATTRIBUTE_UNUSED)
{
return 0;
}
......@@ -352,7 +352,9 @@ nodeDeviceGetXMLDesc(virNodeDevicePtr dev,
if (virNodeDeviceGetXMLDescEnsureACL(dev->conn, obj->def) < 0)
goto cleanup;
nodeDeviceUpdateDriverName(obj);
if (nodeDeviceUpdateDriverName(obj->def) < 0)
goto cleanup;
if (nodeDeviceUpdateCaps(obj) < 0)
goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册