qemu: Use virDomainPCIControllerOpts in qemuBuildControllerDevStr

Shorten up a few characters and reference the pciopts pointer
This commit is contained in:
John Ferlan 2017-11-27 14:45:54 -05:00
parent e1f7c354f0
commit c44ba1d4d1

View File

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