}
+static int
+qemuBuildGlobalControllerCommandLine(virCommandPtr cmd,
+ const virDomainDef *def,
+ virQEMUCapsPtr qemuCaps)
+{
+ size_t i;
+
+ for (i = 0; i < def->ncontrollers; i++) {
+ virDomainControllerDefPtr cont = def->controllers[i];
+ if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
+ cont->opts.pciopts.pcihole64) {
+ const char *hoststr = NULL;
+ bool cap = false;
+ bool machine = false;
+
+ switch (cont->model) {
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
+ hoststr = "i440FX-pcihost";
+ cap = virQEMUCapsGet(qemuCaps, QEMU_CAPS_I440FX_PCI_HOLE64_SIZE);
+ machine = qemuDomainMachineIsI440FX(def);
+ break;
+
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
+ hoststr = "q35-pcihost";
+ cap = virQEMUCapsGet(qemuCaps, QEMU_CAPS_Q35_PCI_HOLE64_SIZE);
+ machine = qemuDomainMachineIsQ35(def);
+ break;
+
+ default:
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("64-bit PCI hole setting is only for root"
+ " PCI controllers"));
+ return -1;
+ }
+
+ if (!machine) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Setting the 64-bit PCI hole size is not "
+ "supported for machine '%s'"), def->os.machine);
+ return -1;
+ }
+ if (!cap) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("64-bit PCI hole size setting is not supported "
+ "with this QEMU binary"));
+ return -1;
+ }
+
+ virCommandAddArg(cmd, "-global");
+ virCommandAddArgFormat(cmd, "%s.pci-hole64-size=%luK", hoststr,
+ cont->opts.pciopts.pcihole64size);
+ }
+ }
+
+ return 0;
+}
+
+
static int
qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
const virDomainDef *def,
if (qemuBuildBootCommandLine(cmd, def, qemuCaps, &emitBootindex) < 0)
goto error;
- for (i = 0; i < def->ncontrollers; i++) {
- virDomainControllerDefPtr cont = def->controllers[i];
- if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
- cont->opts.pciopts.pcihole64) {
- const char *hoststr = NULL;
- bool cap = false;
- bool machine = false;
-
- switch (cont->model) {
- case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
- hoststr = "i440FX-pcihost";
- cap = virQEMUCapsGet(qemuCaps, QEMU_CAPS_I440FX_PCI_HOLE64_SIZE);
- machine = qemuDomainMachineIsI440FX(def);
- break;
-
- case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
- hoststr = "q35-pcihost";
- cap = virQEMUCapsGet(qemuCaps, QEMU_CAPS_Q35_PCI_HOLE64_SIZE);
- machine = qemuDomainMachineIsQ35(def);
- break;
-
- default:
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("64-bit PCI hole setting is only for root"
- " PCI controllers"));
- goto error;
- }
-
- if (!machine) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Setting the 64-bit PCI hole size is not "
- "supported for machine '%s'"), def->os.machine);
- goto error;
- }
- if (!cap) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("64-bit PCI hole size setting is not supported "
- "with this QEMU binary"));
- goto error;
- }
-
- virCommandAddArg(cmd, "-global");
- virCommandAddArgFormat(cmd, "%s.pci-hole64-size=%luK", hoststr,
- cont->opts.pciopts.pcihole64size);
- }
- }
+ if (qemuBuildGlobalControllerCommandLine(cmd, def, qemuCaps) < 0)
+ goto error;
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
for (j = 0; j < ARRAY_CARDINALITY(contOrder); j++) {