]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
conf: Always truncate balloon size to maximum memory size
authorPeter Krempa <pkrempa@redhat.com>
Thu, 30 Apr 2015 15:33:41 +0000 (17:33 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 11 May 2015 06:50:36 +0000 (08:50 +0200)
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

index 93d24ee068adba5717f6737743134580539a1fc1..334283d70fb0a19b0abda5c3a7e421b674543aa4 100644 (file)
@@ -3366,27 +3366,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)) {