Create a function which takes a node device "name" entry to lookup and returns a string containing the parent name for the node device. Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- Adjustment from v1... Instead of moving function to virvhba.c, create a new node_device_conf API which does something similar to what the changed code from patch 7 and 8 (e.g. virVHBAGetParent) would have done. src/conf/node_device_conf.c | 30 ++++++++++++++++++++++++++++++ src/conf/node_device_conf.h | 3 +++ src/libvirt_private.syms | 1 + 3 files changed, 34 insertions(+) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index b3063d9..34ca0ef 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -2285,3 +2285,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; +} diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index 40e930a..6c43546 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -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__ */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index d721c12..9ad0b0a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -706,6 +706,7 @@ virNodeDeviceFindVportParentHost; virNodeDeviceGetParentHost; virNodeDeviceGetParentHostByFabricWWN; virNodeDeviceGetParentHostByWWNs; +virNodeDeviceGetParentName; virNodeDeviceGetWWNs; virNodeDeviceHasCap; virNodeDeviceObjListExport; -- 2.9.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list