提交 cbd1eba8 编写于 作者: A Andrea Bolognani

qemu: Simplify modelName stringification

There's no need to perform checks before conversion, we can just
call virDomainControllerPCIModelNameTypeToString() and check the
results later on.

Since the variables involved are only used for PCI controllers,
we can declare them in the 'case' scope rather than in the
function scope to make everything a bit nicer while at it.
Signed-off-by: NAndrea Bolognani <abologna@redhat.com>
上级 35e9c02c
......@@ -2625,8 +2625,6 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
int address_type = def->info.type;
const virDomainPCIControllerOpts *pciopts;
const char *modelName = NULL;
*devstr = NULL;
......@@ -2726,11 +2724,9 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
break;
case VIR_DOMAIN_CONTROLLER_TYPE_PCI:
pciopts = &def->opts.pciopts;
if (def->model != VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT &&
def->model != VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST)
modelName = virDomainControllerPCIModelNameTypeToString(pciopts->modelName);
case VIR_DOMAIN_CONTROLLER_TYPE_PCI: {
const virDomainPCIControllerOpts *pciopts = &def->opts.pciopts;
const char *modelName = virDomainControllerPCIModelNameTypeToString(pciopts->modelName);
/* Skip the implicit PHB for pSeries guests */
if (def->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT &&
......@@ -2739,6 +2735,13 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
goto done;
}
if (!modelName) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unknown virDomainControllerPCIModelName value: %d"),
pciopts->modelName);
return -1;
}
switch ((virDomainControllerModelPCI) def->model) {
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE:
virBufferAsprintf(&buf, "%s,chassis_nr=%d,id=%s",
......@@ -2780,6 +2783,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
goto error;
}
break;
}
case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册