mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
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: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
parent
35e9c02cbe
commit
cbd1eba8b7
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user