]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: command: move pcihole64 validation to qemu_domain.c
authorDaniel Henrique Barboza <danielhb413@gmail.com>
Mon, 9 Dec 2019 23:15:24 +0000 (20:15 -0300)
committerCole Robinson <crobinso@redhat.com>
Mon, 16 Dec 2019 22:51:14 +0000 (17:51 -0500)
Move the pcihole64 validation being done by
qemuBuildGlobalControllerCommandLine() to the existing function
qemuDomainDeviceDefValidateControllerPCI(), which provides
domain define time validation.

The existing pcihole64 validations in qemu_domain.c were replaced
by the ones moved from qemu_command.c. The reason is that they
are more specific, allowing VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT
and VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT to have distinct validation,
with exclusive QEMU caps and machine types.

Tests were adapted to consider the new caps being needed in
this earlier stage.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/qemu/qemu_command.c
src/qemu/qemu_domain.c
tests/qemuxml2argvtest.c
tests/qemuxml2xmltest.c

index c60953c68e3739256a3092e3464dd39962c28518..e547474f9a63b105d83b24443cad0b951eb7c179 100644 (file)
@@ -6435,8 +6435,7 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
 
 static int
 qemuBuildGlobalControllerCommandLine(virCommandPtr cmd,
-                                     const virDomainDef *def,
-                                     virQEMUCapsPtr qemuCaps)
+                                     const virDomainDef *def)
 {
     size_t i;
 
@@ -6445,20 +6444,14 @@ qemuBuildGlobalControllerCommandLine(virCommandPtr cmd,
         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 = qemuDomainIsI440FX(def);
                 break;
 
             case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
                 hoststr = "q35-pcihost";
-                cap = virQEMUCapsGet(qemuCaps, QEMU_CAPS_Q35_PCI_HOLE64_SIZE);
-                machine = qemuDomainIsQ35(def);
                 break;
 
             default:
@@ -6468,19 +6461,6 @@ qemuBuildGlobalControllerCommandLine(virCommandPtr cmd,
                 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);
@@ -10043,7 +10023,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
     if (qemuBuildIOMMUCommandLine(cmd, def, qemuCaps) < 0)
         return NULL;
 
-    if (qemuBuildGlobalControllerCommandLine(cmd, def, qemuCaps) < 0)
+    if (qemuBuildGlobalControllerCommandLine(cmd, def) < 0)
         return NULL;
 
     if (qemuBuildControllersCommandLine(cmd, def, qemuCaps) < 0)
index 9840bee32486f41bed2c4c080c74a68005e0a21a..058c75d5878f9866db27fb72007ae5a7529dd5f8 100644 (file)
@@ -7255,13 +7255,38 @@ qemuDomainDeviceDefValidateControllerPCI(const virDomainControllerDef *cont,
     /* pcihole64 */
     switch ((virDomainControllerModelPCI) cont->model) {
     case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
+        if (pciopts->pcihole64 ||  pciopts->pcihole64size != 0) {
+            if (!qemuDomainIsI440FX(def)) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                               _("Setting the 64-bit PCI hole size is not "
+                                 "supported for machine '%s'"), def->os.machine);
+                return -1;
+            }
+
+            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_I440FX_PCI_HOLE64_SIZE)) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("64-bit PCI hole size setting is not supported "
+                                 "with this QEMU binary"));
+                return -1;
+            }
+        }
+        break;
+
     case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
-        /* The pcihole64 option only applies to x86 guests */
-        if ((pciopts->pcihole64 ||
-             pciopts->pcihole64size != 0) &&
-            !ARCH_IS_X86(def->os.arch)) {
-            virReportControllerInvalidOption(cont, model, modelName, "pcihole64");
-            return -1;
+        if (pciopts->pcihole64 || pciopts->pcihole64size != 0) {
+            if (!qemuDomainIsQ35(def)) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                               _("Setting the 64-bit PCI hole size is not "
+                                 "supported for machine '%s'"), def->os.machine);
+                return -1;
+            }
+
+            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_Q35_PCI_HOLE64_SIZE)) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("64-bit PCI hole size setting is not supported "
+                                 "with this QEMU binary"));
+                return -1;
+            }
         }
         break;
 
index 0db4160a77418b7ecc3143abb0852977f37de8eb..4227737bc75cd3990f3eac47526b5bc61c7e3908 100644 (file)
@@ -2526,7 +2526,7 @@ mymain(void)
             QEMU_CAPS_KVM, QEMU_CAPS_VIRTIO_SCSI);
 
     DO_TEST("pcihole64", QEMU_CAPS_I440FX_PCI_HOLE64_SIZE);
-    DO_TEST_FAILURE("pcihole64-none", NONE);
+    DO_TEST_PARSE_ERROR("pcihole64-none", NONE);
     DO_TEST("pcihole64-q35",
             QEMU_CAPS_DEVICE_IOH3420,
             QEMU_CAPS_ICH9_AHCI,
index ca993c35b2db02e00fe5c12914ccbb9b0b235998..d1eee0f00f12e8b2f699cf406cb8d89f88de6b41 100644 (file)
@@ -991,9 +991,9 @@ mymain(void)
     DO_TEST("s390-serial-console",
             QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
 
-    DO_TEST("pcihole64", NONE);
-    DO_TEST("pcihole64-gib", NONE);
-    DO_TEST("pcihole64-none", NONE);
+    DO_TEST("pcihole64", QEMU_CAPS_I440FX_PCI_HOLE64_SIZE);
+    DO_TEST("pcihole64-gib", QEMU_CAPS_I440FX_PCI_HOLE64_SIZE);
+    DO_TEST("pcihole64-none", QEMU_CAPS_I440FX_PCI_HOLE64_SIZE);
     DO_TEST("pcihole64-q35",
             QEMU_CAPS_DEVICE_IOH3420,
             QEMU_CAPS_ICH9_AHCI,