]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
libxl: round memory values to next 1MiB increment v4.1.0-rc1
authorJim Fehlig <jfehlig@suse.com>
Thu, 22 Feb 2018 01:48:38 +0000 (18:48 -0700)
committerJim Fehlig <jfehlig@suse.com>
Fri, 23 Feb 2018 22:01:27 +0000 (15:01 -0700)
libxl requires the memory sizes to be rounded to 1MiB increments.
Attempting to start a domain that violates this requirement will
fail with the marginally helpful error

2018-02-22 01:55:32.921+0000: xc: panic: xc_dom_boot.c:141: xc_dom_boot_mem_init: can't allocate low memory for domain: Out of memory
2018-02-22 01:55:32.921+0000: libxl: libxl_dom.c:671:libxl__build_dom: xc_dom_boot_mem_init failed: No such file or directory

Round the maximum and current memory values to the next 1MiB
increment when generating the libxl_domain_config object.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
src/libxl/libxl_conf.c

index dcd46873c78bfaa1f15fb6ff3aec4a108a6df13a..ea2b0c588f9b9cfa996a3e570989c08c7b80dd5a 100644 (file)
@@ -367,6 +367,10 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
     }
 
     b_info->sched_params.weight = 1000;
+    /* Xen requires the memory sizes to be rounded to 1MiB increments */
+    virDomainDefSetMemoryTotal(def,
+                               VIR_ROUND_UP(virDomainDefGetMemoryInitial(def), 1024));
+    def->mem.cur_balloon = VIR_ROUND_UP(def->mem.cur_balloon, 1024);
     b_info->max_memkb = virDomainDefGetMemoryInitial(def);
     b_info->target_memkb = def->mem.cur_balloon;
     if (hvm) {