]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: reflect any memory rounding back to xml
authorEric Blake <eblake@redhat.com>
Fri, 30 Mar 2012 15:40:09 +0000 (09:40 -0600)
committerEric Blake <eblake@redhat.com>
Sat, 31 Mar 2012 15:17:35 +0000 (09:17 -0600)
If we round up a user's memory request, we should update the XML
to reflect the actual value in use by the VM, rather than giving
an artificially small value back to the user.

* src/qemu/qemu_command.c (qemuBuildNumaArgStr)
(qemuBuildCommandLine): Reflect rounding back to XML.

src/qemu/qemu_command.c

index f971a08ceae0a64f123d0820cb7075a3617077f1..cfd5d756cb7b9419b6e1eb86543b6b06347265ff 100644 (file)
@@ -3902,8 +3902,9 @@ qemuBuildNumaArgStr(const virDomainDefPtr def, virCommandPtr cmd)
         virBufferAsprintf(&buf, "node,nodeid=%d", def->cpu->cells[i].cellid);
         virBufferAddLit(&buf, ",cpus=");
         qemuBuildNumaCPUArgStr(def->cpu->cells[i].cpumask, &buf);
-        virBufferAsprintf(&buf, "mem=%d",
-            VIR_DIV_UP(def->cpu->cells[i].mem, 1024));
+        def->cpu->cells[i].mem = VIR_DIV_UP(def->cpu->cells[i].mem,
+                                            1024) * 1024;
+        virBufferAsprintf(&buf, "mem=%d", def->cpu->cells[i].mem / 1024);
 
         if (virBufferError(&buf))
             goto error;
@@ -4047,10 +4048,12 @@ qemuBuildCommandLine(virConnectPtr conn,
 
     /* Set '-m MB' based on maxmem, because the lower 'memory' limit
      * is set post-startup using the balloon driver. If balloon driver
-     * is not supported, then they're out of luck anyway
+     * is not supported, then they're out of luck anyway.  Update the
+     * XML to reflect our rounding.
      */
     virCommandAddArg(cmd, "-m");
-    virCommandAddArgFormat(cmd, "%llu", VIR_DIV_UP(def->mem.max_balloon, 1024));
+    def->mem.max_balloon = VIR_DIV_UP(def->mem.max_balloon, 1024) * 1024;
+    virCommandAddArgFormat(cmd, "%llu", def->mem.max_balloon / 1024);
     if (def->mem.hugepage_backed) {
         if (!driver->hugetlbfs_mount) {
             qemuReportError(VIR_ERR_INTERNAL_ERROR,