提交 a3dfaf12 编写于 作者: L Laine Stump

conf: utility to return alias of a controller based on type/index

Because there are multiple potential reasons for an error, this
function logs any errors before returning NULL (since the caller won't
have the information needed to determine which was the reason for
failure).
上级 a6922778
......@@ -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)
......
......@@ -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);
......
......@@ -181,6 +181,7 @@ virDomainClockBasisTypeToString;
virDomainClockOffsetTypeFromString;
virDomainClockOffsetTypeToString;
virDomainConfigFile;
virDomainControllerAliasFind;
virDomainControllerDefFree;
virDomainControllerFind;
virDomainControllerFindByType;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册