[PATCH 1/3] conf: Always truncate balloon size to maximum memory size

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

 



Specifying a balloon size more than the memory size of a guest isn't
something that should be rejected when parsing the XML. Truncate the
size to the maximum memory size.
---
 src/conf/domain_conf.c | 22 ++--------------------
 1 file changed, 2 insertions(+), 20 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5f74ab1..d397bca 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3364,27 +3364,9 @@ virDomainDefPostParseInternal(virDomainDefPtr def,
         return -1;
     }

-    if (def->mem.cur_balloon > virDomainDefGetMemoryActual(def)) {
-        /* Older libvirt could get into this situation due to
-         * rounding; if the discrepancy is less than 4MiB, we silently
-         * round down, otherwise we flag the issue.  */
-        if (VIR_DIV_UP(def->mem.cur_balloon, 4096) >
-            VIR_DIV_UP(virDomainDefGetMemoryActual(def), 4096)) {
-            virReportError(VIR_ERR_XML_ERROR,
-                           _("current memory '%lluk' exceeds "
-                             "maximum '%lluk'"),
-                           def->mem.cur_balloon,
-                           virDomainDefGetMemoryActual(def));
-            return -1;
-        } else {
-            VIR_DEBUG("Truncating current %lluk to maximum %lluk",
-                      def->mem.cur_balloon,
-                      virDomainDefGetMemoryActual(def));
-            def->mem.cur_balloon = virDomainDefGetMemoryActual(def);
-        }
-    } else if (def->mem.cur_balloon == 0) {
+    if (def->mem.cur_balloon > virDomainDefGetMemoryActual(def) ||
+        def->mem.cur_balloon == 0)
         def->mem.cur_balloon = virDomainDefGetMemoryActual(def);
-    }

     if ((def->mem.max_memory || def->mem.memory_slots) &&
         !(def->mem.max_memory && def->mem.memory_slots)) {
-- 
2.3.5

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