]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu: Fix issues with maxMemory in qemuDomainSetMemoryFlags()
authorLuyao Huang <lhuang@redhat.com>
Tue, 24 Mar 2015 14:12:37 +0000 (22:12 +0800)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 22 Apr 2015 07:26:25 +0000 (09:26 +0200)
qemuDomainSetMemoryFlags() would allow to set the initial memory greater
than the <maxMemory> field. While the configuration would not work as
memory hotplug requires NUMA to be enabled and the
qemuDomainSetMemoryFlags() API does not work on NUMA guests this just
fixes a corner case.

The fix is still worth though as it allows to induce an invalid
configuration and make the VM vanish on libvirt restart.

Additionally this tweaks error message to be more accurate.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_driver.c

index 6fc9696dd9b495d280ab4b0ae6e7d3a1cab2323a..d174aab4839d271387125c375cc05f4fb2df9893 100644 (file)
@@ -2313,11 +2313,19 @@ static int qemuDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
              * is no way to change the individual node sizes with this API */
             if (virDomainNumaGetNodeCount(persistentDef->numa) > 0) {
                 virReportError(VIR_ERR_OPERATION_INVALID, "%s",
-                               _("maximum memory size of a domain with NUMA "
+                               _("initial memory size of a domain with NUMA "
                                  "nodes cannot be modified with this API"));
                 goto endjob;
             }
 
+            if (persistentDef->mem.max_memory &&
+                persistentDef->mem.max_memory < newmem) {
+                virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                               _("cannot set initial memory size greater than "
+                                 "the maximum memory size"));
+                goto endjob;
+            }
+
             virDomainDefSetMemoryInitial(persistentDef, newmem);
 
             if (persistentDef->mem.cur_balloon > newmem)