提交 aa6aa624 编写于 作者: J John Ferlan

nodedev: Introduce virNodeDeviceGetParentName

Create a function which takes a node device "name" entry to lookup
and returns a string containing the parent name for the node device.
上级 16416816
......@@ -2288,3 +2288,33 @@ virNodeDeviceObjListExport(virConnectPtr conn,
VIR_FREE(tmp_devices);
return ret;
}
/* virNodeDeviceGetParentName
* @conn: Connection pointer
* @nodedev_name: Node device to lookup
*
* Lookup the node device by name and return the parent name
*
* Returns parent name on success, caller is responsible for freeing;
* otherwise, returns NULL on failure
*/
char *
virNodeDeviceGetParentName(virConnectPtr conn,
const char *nodedev_name)
{
virNodeDevicePtr device = NULL;
char *parent;
if (!(device = virNodeDeviceLookupByName(conn, nodedev_name))) {
virReportError(VIR_ERR_XML_ERROR,
_("Cannot find '%s' in node device database"),
nodedev_name);
return NULL;
}
ignore_value(VIR_STRDUP(parent, virNodeDeviceGetParent(device)));
virObjectUnref(device);
return parent;
}
......@@ -352,4 +352,7 @@ int virNodeDeviceObjListExport(virConnectPtr conn,
virNodeDeviceObjListFilter filter,
unsigned int flags);
char *virNodeDeviceGetParentName(virConnectPtr conn,
const char *nodedev_name);
#endif /* __VIR_NODE_DEVICE_CONF_H__ */
......@@ -706,6 +706,7 @@ virNodeDeviceFindVportParentHost;
virNodeDeviceGetParentHost;
virNodeDeviceGetParentHostByFabricWWN;
virNodeDeviceGetParentHostByWWNs;
virNodeDeviceGetParentName;
virNodeDeviceGetWWNs;
virNodeDeviceHasCap;
virNodeDeviceObjListExport;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册