]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu_domain.c: moving maxCpu validation to qemuDomainDefValidate
authorDaniel Henrique Barboza <danielhb413@gmail.com>
Wed, 14 Nov 2018 19:52:05 +0000 (17:52 -0200)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 15 Nov 2018 21:39:11 +0000 (16:39 -0500)
Adding maxCpu validation in qemuDomainDefValidate allows the user to
spot over the board maxCpus counts at editing time, instead of
facing a runtime error when starting the domain. This check is also
arch independent.

This leaves us with 2 calls to qemuProcessValidateCpuCount: one in
qemuProcessStartValidateXML and the new one at qemuDomainDefValidate.

The call in qemuProcessStartValidateXML is redundant. Following
up in that code, there is a call to virDomainDefValidate, which
in turn will call config.domainValidateCallback. In this case, the
callback function is qemuDomainDefValidate. This means that, on startup
time, qemuProcessValidateCpuCount will be called twice.

To avoid that, let's also remove the qemuProcessValidateCpuCount call
from qemuProcessStartValidateXML.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_domain.c
src/qemu/qemu_process.c

index 730f7103d07b0829ff6832d2e075be320559b879..cdc88def8c2934bd7165450a6beaecddb6f2e914 100644 (file)
@@ -4085,6 +4085,9 @@ qemuDomainDefValidate(const virDomainDef *def,
         }
     }
 
+    if (qemuProcessValidateCpuCount(def, qemuCaps) < 0)
+        goto cleanup;
+
     if (ARCH_IS_X86(def->os.arch) &&
         virDomainDefGetVcpusMax(def) > QEMU_MAX_VCPUS_WITHOUT_EIM) {
         if (!qemuDomainIsQ35(def)) {
index f249de903a8159d42cc8e43908f6fad457cfb612..262aba0a6ca3903ebaf2cb803ac9ff0d4f944c33 100644 (file)
@@ -5153,21 +5153,9 @@ qemuProcessStartValidateDisks(virDomainObjPtr vm,
 static int
 qemuProcessStartValidateXML(virQEMUDriverPtr driver,
                             virDomainObjPtr vm,
-                            virQEMUCapsPtr qemuCaps,
                             virCapsPtr caps,
                             unsigned int flags)
 {
-    /* The bits we validate here are XML configs that we previously
-     * accepted. We reject them at VM startup time rather than parse
-     * time so that pre-existing VMs aren't rejected and dropped from
-     * the VM list when libvirt is updated.
-     *
-     * If back compat isn't a concern, XML validation should probably
-     * be done at parse time.
-     */
-    if (qemuProcessValidateCpuCount(vm->def, qemuCaps) < 0)
-        return -1;
-
     /* checks below should not be executed when starting a qemu process for a
      * VM that was running before (migration, snapshots, save). It's more
      * important to start such VM than keep the configuration clean */
@@ -5217,7 +5205,7 @@ qemuProcessStartValidate(virQEMUDriverPtr driver,
 
     }
 
-    if (qemuProcessStartValidateXML(driver, vm, qemuCaps, caps, flags) < 0)
+    if (qemuProcessStartValidateXML(driver, vm, caps, flags) < 0)
         return -1;
 
     if (qemuProcessStartValidateGraphics(vm) < 0)