diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f3b706e16e48a0e212a1b1bc773cbf195ecb885f..4f1dd990cc66eada93951fd9a939b048aaf9650e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12506,6 +12506,40 @@ virDomainControllerFind(virDomainDefPtr def, return -1; } + +const char * +virDomainControllerAliasFind(virDomainDefPtr def, + int type, int idx) +{ + int contIndex; + const char *contTypeStr = virDomainControllerTypeToString(type); + + if (!contTypeStr) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown controller type %d"), + type); + return NULL; + } + + contIndex = virDomainControllerFind(def, type, idx); + if (contIndex < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not find %s controller with index %d " + "required for device"), + contTypeStr, idx); + return NULL; + } + if (!def->controllers[contIndex]->info.alias) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Device alias was not set for %s controller " + "with index %d "), + contTypeStr, idx); + return NULL; + } + return def->controllers[contIndex]->info.alias; +} + + int virDomainControllerFindByType(virDomainDefPtr def, int type) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 8312c2050bc800afc18dd3f5b27f7410bfaf0c27..2544cbc2cb993df48014d6005ee04b093adf1c6a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2745,6 +2745,9 @@ int virDomainControllerFindByType(virDomainDefPtr def, int type); int virDomainControllerFindByPCIAddress(virDomainDefPtr def, virDevicePCIAddressPtr addr); virDomainControllerDefPtr virDomainControllerRemove(virDomainDefPtr def, size_t i); +const char *virDomainControllerAliasFind(virDomainDefPtr def, + int type, int idx) + ATTRIBUTE_NONNULL(1); int virDomainLeaseIndex(virDomainDefPtr def, virDomainLeaseDefPtr lease); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index f80fc7021308974c1fb0eb54b4480973fd349f11..9c468dbe1da40a06418a52ab3ee9fda72916edf6 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -181,6 +181,7 @@ virDomainClockBasisTypeToString; virDomainClockOffsetTypeFromString; virDomainClockOffsetTypeToString; virDomainConfigFile; +virDomainControllerAliasFind; virDomainControllerDefFree; virDomainControllerFind; virDomainControllerFindByType;