Shorten up a few characters and reference the pciopts pointer
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/qemu/qemu_command.c | 118 ++++++++++++++++++++++++------------------------
1 file changed, 60 insertions(+), 58 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index abff1049b..518a867d5 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2608,6 +2608,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
int *nusbcontroller)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
+ const virDomainPCIControllerOpts *pciopts;
const char *modelName = NULL;
*devstr = NULL;
@@ -2711,24 +2712,26 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
break;
case VIR_DOMAIN_CONTROLLER_TYPE_PCI:
+ pciopts = &def->opts.pciopts;
+
switch ((virDomainControllerModelPCI) def->model) {
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE:
- if (def->opts.pciopts.modelName
+ if (pciopts->modelName
== VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE ||
- def->opts.pciopts.chassisNr == -1) {
+ pciopts->chassisNr == -1) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("autogenerated pci-bridge options not set"));
goto error;
}
- modelName =
virDomainControllerPCIModelNameTypeToString(def->opts.pciopts.modelName);
+ modelName =
virDomainControllerPCIModelNameTypeToString(pciopts->modelName);
if (!modelName) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown pci-bridge model name value %d"),
- def->opts.pciopts.modelName);
+ pciopts->modelName);
goto error;
}
- if (def->opts.pciopts.modelName
+ if (pciopts->modelName
!= VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCI_BRIDGE) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("PCI controller model name '%s' "
@@ -2743,26 +2746,26 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
goto error;
}
virBufferAsprintf(&buf, "%s,chassis_nr=%d,id=%s",
- modelName, def->opts.pciopts.chassisNr,
+ modelName, pciopts->chassisNr,
def->info.alias);
break;
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS:
- if (def->opts.pciopts.modelName
+ if (pciopts->modelName
== VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE ||
- def->opts.pciopts.busNr == -1) {
+ pciopts->busNr == -1) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("autogenerated pci-expander-bus options not
set"));
goto error;
}
- modelName =
virDomainControllerPCIModelNameTypeToString(def->opts.pciopts.modelName);
+ modelName =
virDomainControllerPCIModelNameTypeToString(pciopts->modelName);
if (!modelName) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown pci-expander-bus model name value
%d"),
- def->opts.pciopts.modelName);
+ pciopts->modelName);
goto error;
}
- if (def->opts.pciopts.modelName
+ if (pciopts->modelName
!= VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("PCI controller model name '%s' "
@@ -2777,28 +2780,28 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
goto error;
}
virBufferAsprintf(&buf, "%s,bus_nr=%d,id=%s",
- modelName, def->opts.pciopts.busNr,
+ modelName, pciopts->busNr,
def->info.alias);
- if (def->opts.pciopts.numaNode != -1)
+ if (pciopts->numaNode != -1)
virBufferAsprintf(&buf, ",numa_node=%d",
- def->opts.pciopts.numaNode);
+ pciopts->numaNode);
break;
case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE:
- if (def->opts.pciopts.modelName
+ if (pciopts->modelName
== VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("autogenerated dmi-to-pci-bridge options not
set"));
goto error;
}
- modelName =
virDomainControllerPCIModelNameTypeToString(def->opts.pciopts.modelName);
+ modelName =
virDomainControllerPCIModelNameTypeToString(pciopts->modelName);
if (!modelName) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown dmi-to-pci-bridge model name value
%d"),
- def->opts.pciopts.modelName);
+ pciopts->modelName);
goto error;
}
- if (def->opts.pciopts.modelName
+ if (pciopts->modelName
!= VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_I82801B11_BRIDGE) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("PCI controller model name '%s' "
@@ -2815,24 +2818,23 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
virBufferAsprintf(&buf, "%s,id=%s", modelName,
def->info.alias);
break;
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT:
- if (def->opts.pciopts.modelName
+ if (pciopts->modelName
== VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE ||
- def->opts.pciopts.chassis == -1 ||
- def->opts.pciopts.port == -1) {
+ pciopts->chassis == -1 || pciopts->port == -1) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("autogenerated pcie-root-port options not
set"));
goto error;
}
- modelName =
virDomainControllerPCIModelNameTypeToString(def->opts.pciopts.modelName);
+ modelName =
virDomainControllerPCIModelNameTypeToString(pciopts->modelName);
if (!modelName) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown pcie-root-port model name value
%d"),
- def->opts.pciopts.modelName);
+ pciopts->modelName);
goto error;
}
- if ((def->opts.pciopts.modelName !=
+ if ((pciopts->modelName !=
VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420) &&
- (def->opts.pciopts.modelName !=
+ (pciopts->modelName !=
VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCIE_ROOT_PORT)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("PCI controller model name '%s' "
@@ -2840,7 +2842,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
modelName);
goto error;
}
- if ((def->opts.pciopts.modelName ==
+ if ((pciopts->modelName ==
VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420) &&
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_IOH3420)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -2848,7 +2850,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
"controller is not supported in this QEMU
binary"));
goto error;
}
- if ((def->opts.pciopts.modelName ==
+ if ((pciopts->modelName ==
VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCIE_ROOT_PORT) &&
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PCIE_ROOT_PORT)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -2858,24 +2860,24 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
}
virBufferAsprintf(&buf, "%s,port=0x%x,chassis=%d,id=%s",
- modelName, def->opts.pciopts.port,
- def->opts.pciopts.chassis, def->info.alias);
+ modelName, pciopts->port,
+ pciopts->chassis, def->info.alias);
break;
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT:
- if (def->opts.pciopts.modelName
+ if (pciopts->modelName
== VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("autogenerated pcie-switch-upstream-port options
not set"));
goto error;
}
- modelName =
virDomainControllerPCIModelNameTypeToString(def->opts.pciopts.modelName);
+ modelName =
virDomainControllerPCIModelNameTypeToString(pciopts->modelName);
if (!modelName) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown pcie-switch-upstream-port model name value
%d"),
- def->opts.pciopts.modelName);
+ pciopts->modelName);
goto error;
}
- if (def->opts.pciopts.modelName
+ if (pciopts->modelName
!= VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_X3130_UPSTREAM) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("PCI controller model name '%s' "
@@ -2893,24 +2895,24 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
virBufferAsprintf(&buf, "%s,id=%s", modelName,
def->info.alias);
break;
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT:
- if (def->opts.pciopts.modelName
+ if (pciopts->modelName
== VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE ||
- def->opts.pciopts.chassis == -1 ||
- def->opts.pciopts.port == -1) {
+ pciopts->chassis == -1 ||
+ pciopts->port == -1) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("autogenerated pcie-switch-downstream-port "
"options not set"));
goto error;
}
- modelName =
virDomainControllerPCIModelNameTypeToString(def->opts.pciopts.modelName);
+ modelName =
virDomainControllerPCIModelNameTypeToString(pciopts->modelName);
if (!modelName) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown pcie-switch-downstream-port model name
value %d"),
- def->opts.pciopts.modelName);
+ pciopts->modelName);
goto error;
}
- if (def->opts.pciopts.modelName
+ if (pciopts->modelName
!= VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_XIO3130_DOWNSTREAM) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("PCI controller model name '%s' "
@@ -2926,26 +2928,26 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
goto error;
}
virBufferAsprintf(&buf, "%s,port=0x%x,chassis=%d,id=%s",
- modelName, def->opts.pciopts.port,
- def->opts.pciopts.chassis, def->info.alias);
+ modelName, pciopts->port,
+ pciopts->chassis, def->info.alias);
break;
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS:
- if (def->opts.pciopts.modelName
+ if (pciopts->modelName
== VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE ||
- def->opts.pciopts.busNr == -1) {
+ pciopts->busNr == -1) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("autogenerated pcie-expander-bus options not
set"));
goto error;
}
- modelName =
virDomainControllerPCIModelNameTypeToString(def->opts.pciopts.modelName);
+ modelName =
virDomainControllerPCIModelNameTypeToString(pciopts->modelName);
if (!modelName) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown pcie-expander-bus model name value
%d"),
- def->opts.pciopts.modelName);
+ pciopts->modelName);
goto error;
}
- if (def->opts.pciopts.modelName
+ if (pciopts->modelName
!= VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB_PCIE) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("PCI controller model name '%s' "
@@ -2960,32 +2962,32 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
goto error;
}
virBufferAsprintf(&buf, "%s,bus_nr=%d,id=%s",
- modelName, def->opts.pciopts.busNr,
+ modelName, pciopts->busNr,
def->info.alias);
- if (def->opts.pciopts.numaNode != -1)
+ if (pciopts->numaNode != -1)
virBufferAsprintf(&buf, ",numa_node=%d",
- def->opts.pciopts.numaNode);
+ pciopts->numaNode);
break;
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
- if (def->opts.pciopts.modelName ==
VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE ||
- def->opts.pciopts.targetIndex == -1) {
+ if (pciopts->modelName == VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE ||
+ pciopts->targetIndex == -1) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("autogenerated pci-root options not set"));
goto error;
}
/* Skip the implicit one */
- if (def->opts.pciopts.targetIndex == 0)
+ if (pciopts->targetIndex == 0)
goto done;
- modelName =
virDomainControllerPCIModelNameTypeToString(def->opts.pciopts.modelName);
+ modelName =
virDomainControllerPCIModelNameTypeToString(pciopts->modelName);
if (!modelName) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown pci-root model name value %d"),
- def->opts.pciopts.modelName);
+ pciopts->modelName);
goto error;
}
- if (def->opts.pciopts.modelName !=
VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_SPAPR_PCI_HOST_BRIDGE) {
+ if (pciopts->modelName !=
VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_SPAPR_PCI_HOST_BRIDGE) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("PCI controller model name '%s' is not
valid for a pci-root"),
modelName);
@@ -2998,17 +3000,17 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
goto error;
}
virBufferAsprintf(&buf, "%s,index=%d,id=%s",
- modelName, def->opts.pciopts.targetIndex,
+ modelName, pciopts->targetIndex,
def->info.alias);
- if (def->opts.pciopts.numaNode != -1) {
+ if (pciopts->numaNode != -1) {
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPAPR_PCI_HOST_BRIDGE_NUMA_NODE))
{
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("the spapr-pci-host-bridge controller "
"doesn't support numa_node on this QEMU
binary"));
goto error;
}
- virBufferAsprintf(&buf, ",numa_node=%d",
def->opts.pciopts.numaNode);
+ virBufferAsprintf(&buf, ",numa_node=%d",
pciopts->numaNode);
}
break;
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
--
2.13.6