]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: command: move qemuBuildBootCommandLine validation to qemu_domain.c
authorDaniel Henrique Barboza <danielhb413@gmail.com>
Mon, 9 Dec 2019 23:15:23 +0000 (20:15 -0300)
committerCole Robinson <crobinso@redhat.com>
Mon, 16 Dec 2019 22:51:10 +0000 (17:51 -0500)
Move the boot validation being done by qemuBuildBootCommandLine()
to to a new qemuDomainDefValidateBoot() function. This new function
is called by qemuDomainDefValidate(), allowing boot validation in
domain define time.

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 95dd2c2514f77fe6bc2e9b5bce1dc50c0d6c7b24..c60953c68e3739256a3092e3464dd39962c28518 100644 (file)
@@ -6336,28 +6336,13 @@ qemuBuildBootCommandLine(virCommandPtr cmd,
     }
 
     if (def->os.bios.rt_set) {
-        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_REBOOT_TIMEOUT)) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("reboot timeout is not supported "
-                             "by this QEMU binary"));
-            return -1;
-        }
-
         virBufferAsprintf(&boot_buf,
                           "reboot-timeout=%d,",
                           def->os.bios.rt_delay);
     }
 
-    if (def->os.bm_timeout_set) {
-        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPLASH_TIMEOUT)) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("splash timeout is not supported "
-                             "by this QEMU binary"));
-            return -1;
-        }
-
+    if (def->os.bm_timeout_set)
         virBufferAsprintf(&boot_buf, "splash-time=%u,", def->os.bm_timeout);
-    }
 
     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOT_STRICT))
         virBufferAddLit(&boot_buf, "strict=on,");
index aa2da0a81a9d9468437e62ede7dec79ceaf6dc8b..9840bee32486f41bed2c4c080c74a68005e0a21a 100644 (file)
@@ -5495,6 +5495,32 @@ qemuDomainDefValidatePM(const virDomainDef *def,
 }
 
 
+static int
+qemuDomainDefValidateBoot(const virDomainDef *def,
+                          virQEMUCapsPtr qemuCaps)
+{
+    if (def->os.bios.rt_set) {
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_REBOOT_TIMEOUT)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("reboot timeout is not supported "
+                             "by this QEMU binary"));
+            return -1;
+        }
+    }
+
+    if (def->os.bm_timeout_set) {
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPLASH_TIMEOUT)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("splash timeout is not supported "
+                             "by this QEMU binary"));
+            return -1;
+        }
+    }
+
+    return 0;
+}
+
+
 static int
 qemuDomainDefValidate(const virDomainDef *def,
                       void *opaque)
@@ -5614,6 +5640,9 @@ qemuDomainDefValidate(const virDomainDef *def,
     if (qemuDomainDefValidatePM(def, qemuCaps) < 0)
         goto cleanup;
 
+    if (qemuDomainDefValidateBoot(def, qemuCaps) < 0)
+        goto cleanup;
+
     /* QEMU 2.7 (detected via the availability of query-hotpluggable-cpus)
      * enforces stricter rules than previous versions when it comes to guest
      * CPU topology. Verify known constraints are respected */
index d0fd4bccef58e76eecf7025d9db919838d7cd6c5..0db4160a77418b7ecc3143abb0852977f37de8eb 100644 (file)
@@ -844,7 +844,7 @@ mymain(void)
     DO_TEST("boot-menu-enable", NONE);
     DO_TEST("boot-menu-enable-with-timeout",
             QEMU_CAPS_SPLASH_TIMEOUT);
-    DO_TEST_FAILURE("boot-menu-enable-with-timeout", NONE);
+    DO_TEST_PARSE_ERROR("boot-menu-enable-with-timeout", NONE);
     DO_TEST_PARSE_ERROR("boot-menu-enable-with-timeout-invalid", NONE);
     DO_TEST("boot-menu-disable", NONE);
     DO_TEST("boot-menu-disable-drive", NONE);
@@ -860,7 +860,7 @@ mymain(void)
 
     DO_TEST("reboot-timeout-disabled", QEMU_CAPS_REBOOT_TIMEOUT);
     DO_TEST("reboot-timeout-enabled", QEMU_CAPS_REBOOT_TIMEOUT);
-    DO_TEST_FAILURE("reboot-timeout-enabled", NONE);
+    DO_TEST_PARSE_ERROR("reboot-timeout-enabled", NONE);
 
     DO_TEST("bios",
             QEMU_CAPS_DEVICE_ISA_SERIAL,
index 9d727ce074f96cbac86f126402d510a223e2e3e9..ca993c35b2db02e00fe5c12914ccbb9b0b235998 100644 (file)
@@ -251,13 +251,13 @@ mymain(void)
             QEMU_CAPS_DEVICE_IOH3420,
             QEMU_CAPS_ICH9_AHCI);
     DO_TEST("boot-multi", NONE);
-    DO_TEST("boot-menu-enable-with-timeout", NONE);
+    DO_TEST("boot-menu-enable-with-timeout", QEMU_CAPS_SPLASH_TIMEOUT);
     DO_TEST("boot-menu-disable", NONE);
     DO_TEST("boot-menu-disable-with-timeout", NONE);
     DO_TEST("boot-order", NONE);
 
-    DO_TEST("reboot-timeout-enabled", NONE);
-    DO_TEST("reboot-timeout-disabled", NONE);
+    DO_TEST("reboot-timeout-enabled", QEMU_CAPS_REBOOT_TIMEOUT);
+    DO_TEST("reboot-timeout-disabled", QEMU_CAPS_REBOOT_TIMEOUT);
 
     DO_TEST("clock-utc", NONE);
     DO_TEST("clock-localtime", NONE);