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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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(-)

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);
-- 
2.7.3

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]