diff mbox

[2/2] qemu: process: split out startup XML validation

Message ID e6b4c4b908cc8d1cf1dd69de8b7e548a0564e692.1461186083.git.crobinso@redhat.com
State Accepted
Commit 5938f2d0bdda38ea280b1445aebdbcd816202e0a
Headers show

Commit Message

Cole Robinson April 20, 2016, 9:01 p.m. UTC
And document that these specific bits are done at startup time for
back compat reasons
---
 src/qemu/qemu_process.c | 43 +++++++++++++++++++++++++++++++------------
 1 file changed, 31 insertions(+), 12 deletions(-)

-- 
2.7.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
diff mbox

Patch

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 10e1b5a..8a2f65f 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -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);