]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: process: split out startup XML validation
authorCole Robinson <crobinso@redhat.com>
Wed, 20 Apr 2016 20:55:48 +0000 (16:55 -0400)
committerCole Robinson <crobinso@redhat.com>
Thu, 21 Apr 2016 13:29:20 +0000 (09:29 -0400)
And document that these specific bits are done at startup time for
back compat reasons

src/qemu/qemu_process.c

index 10e1b5a2fed9095928f3421fd1694805369cd1f1..8a2f65fe7fa24cb25b8366c17793a969e23213bb 100644 (file)
@@ -4546,6 +4546,36 @@ qemuProcessStartWarnShmem(virDomainObjPtr vm)
     }
 }
 
+static int
+qemuProcessStartValidateXML(virDomainObjPtr vm,
+                            virQEMUCapsPtr qemuCaps,
+                            bool migration,
+                            bool snapshot)
+{
+    /* 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 (qemuValidateCpuCount(vm->def, qemuCaps) < 0)
+        return -1;
+
+    if (!migration && !snapshot &&
+        virDomainDefCheckDuplicateDiskInfo(vm->def) < 0)
+        return -1;
+
+    if (vm->def->mem.min_guarantee) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("Parameter 'min_guarantee' "
+                         "not supported by QEMU."));
+        return -1;
+    }
+
+    return 0;
+}
 
 /**
  * qemuProcessStartValidate:
@@ -4590,20 +4620,9 @@ qemuProcessStartValidate(virQEMUDriverPtr driver,
 
     }
 
-    if (qemuValidateCpuCount(vm->def, qemuCaps) < 0)
-        return -1;
-
-    if (!migration && !snapshot &&
-        virDomainDefCheckDuplicateDiskInfo(vm->def) < 0)
+    if (qemuProcessStartValidateXML(vm, qemuCaps, migration, snapshot) < 0)
         return -1;
 
-    if (vm->def->mem.min_guarantee) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("Parameter 'min_guarantee' "
-                         "not supported by QEMU."));
-        return -1;
-    }
-
     VIR_DEBUG("Checking for any possible (non-fatal) issues");
 
     qemuProcessStartWarnShmem(vm);