[PATCH] qemu: fix can use setmaxmem to change the maximum memory biger than max memory

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

 



When call qemuDomainSetMemoryFlags() to change maximum memory size, we
do not check if the maximum memory is biger than the max memory, this will
make vm disappear after libvirtd restart if we set a big maximum memory.

Add a check for this, also fix a typos issue.

Signed-off-by: Luyao Huang <lhuang@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 2 +-
 src/qemu/qemu_driver.c | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d633f93..0d4b165 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -16646,7 +16646,7 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
 
     if (src->mem.memory_slots != dst->mem.memory_slots) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("Target domain memory slots count '%u' doesn't match source '%u"),
+                       _("Target domain memory slots count '%u' doesn't match source '%u'"),
                        dst->mem.memory_slots, src->mem.memory_slots);
         goto error;
     }
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 3518dec..86b87af 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2324,6 +2324,13 @@ static int qemuDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
                                  "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 maximum memory size biger than "
+                                 "the max memory size"));
+                goto endjob;
+            }
 
             virDomainDefSetMemoryInitial(persistentDef, newmem);
 
-- 
1.8.3.1

--
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]