[PATCH 2/7] qemu: lxc: Clarify error message when setting current memory

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

 



Commit 60f7303c151cccdbe214b9f9ac59ecaf95cbf24b introduced the error
message but it's unclear whether the persistent config or the live
config tripped the message. Later the LXC driver copied the same code.

Separate the message which will also clarify the code.
---
 src/lxc/lxc_driver.c   | 21 +++++++++++----------
 src/qemu/qemu_driver.c | 19 ++++++++++---------
 2 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 3adb21d..5af0554 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -742,18 +742,19 @@ static int lxcDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
                 goto cleanup;
         }
     } else {
-        unsigned long oldmax = 0;
-
-        if (flags & VIR_DOMAIN_AFFECT_LIVE)
-            oldmax = vm->def->mem.max_balloon;
-        if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
-            if (!oldmax || oldmax > persistentDef->mem.max_balloon)
-                oldmax = persistentDef->mem.max_balloon;
+        if (flags & VIR_DOMAIN_AFFECT_LIVE &&
+            newmem > vm->def->mem.max_balloon) {
+            virReportError(VIR_ERR_INVALID_ARG, "%s",
+                           _("max memory of the live instance can't be less "
+                             "than the current memory"));
+            goto cleanup;
         }

-        if (newmem > oldmax) {
-            virReportError(VIR_ERR_INVALID_ARG,
-                           "%s", _("Cannot set memory higher than max memory"));
+        if (flags & VIR_DOMAIN_AFFECT_CONFIG &&
+            newmem > persistentDef->mem.max_balloon) {
+            virReportError(VIR_ERR_INVALID_ARG, "%s",
+                           _("max memory of the persistent configuration can't "
+                             "be less than the current memory"));
             goto cleanup;
         }

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e2abbe0..4458e02 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2326,18 +2326,19 @@ static int qemuDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,

     } else {
         /* resize the current memory */
-        unsigned long oldmax = 0;
-
-        if (flags & VIR_DOMAIN_AFFECT_LIVE)
-            oldmax = vm->def->mem.max_balloon;
-        if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
-            if (!oldmax || oldmax > persistentDef->mem.max_balloon)
-                oldmax = persistentDef->mem.max_balloon;
+        if (flags & VIR_DOMAIN_AFFECT_LIVE &&
+            newmem > vm->def->mem.max_balloon) {
+            virReportError(VIR_ERR_INVALID_ARG, "%s",
+                           _("max memory of the live instance can't be less "
+                             "than the current memory"));
+            goto endjob;
         }

-        if (newmem > oldmax) {
+        if (flags & VIR_DOMAIN_AFFECT_CONFIG &&
+            newmem > persistentDef->mem.max_balloon) {
             virReportError(VIR_ERR_INVALID_ARG, "%s",
-                           _("cannot set memory higher than max memory"));
+                           _("max memory of the persistent configuration can't "
+                             "be less than the current memory"));
             goto endjob;
         }

-- 
2.2.2

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