qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] increase maxmem before calling xc_domain_populate_physmap
@ 2014-11-25 17:45 Stefano Stabellini
  2014-11-25 18:24 ` [Qemu-devel] [Xen-devel] " Andrew Cooper
  0 siblings, 1 reply; 16+ messages in thread
From: Stefano Stabellini @ 2014-11-25 17:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: xen-devel, Wei Liu (Intern), Ian Campbell, Stefano Stabellini

Increase maxmem before calling xc_domain_populate_physmap_exact to avoid
the risk of running out of guest memory. This way we can also avoid
complex memory calculations in libxl at domain construction time.

This patch fixes an abort() when assigning more than 4 NICs to a VM.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

diff --git a/xen-hvm.c b/xen-hvm.c
index 5c69a8d..38e08c3 100644
--- a/xen-hvm.c
+++ b/xen-hvm.c
@@ -218,6 +218,7 @@ void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, MemoryRegion *mr)
     unsigned long nr_pfn;
     xen_pfn_t *pfn_list;
     int i;
+    xc_dominfo_t info;
 
     if (runstate_check(RUN_STATE_INMIGRATE)) {
         /* RAM already populated in Xen */
@@ -240,6 +241,13 @@ void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, MemoryRegion *mr)
         pfn_list[i] = (ram_addr >> TARGET_PAGE_BITS) + i;
     }
 
+    if (xc_domain_getinfo(xen_xc, xen_domid, 1, &info) < 0) {
+        hw_error("xc_domain_getinfo failed");
+    }
+    if (xc_domain_setmaxmem(xen_xc, xen_domid, info.max_memkb +
+                            (nr_pfn * XC_PAGE_SIZE / 1024)) < 0) {
+        hw_error("xc_domain_setmaxmem failed");
+    }
     if (xc_domain_populate_physmap_exact(xen_xc, xen_domid, nr_pfn, 0, 0, pfn_list)) {
         hw_error("xen: failed to populate ram at " RAM_ADDR_FMT, ram_addr);
     }

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2014-12-04 16:38 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-25 17:45 [Qemu-devel] [PATCH] increase maxmem before calling xc_domain_populate_physmap Stefano Stabellini
2014-11-25 18:24 ` [Qemu-devel] [Xen-devel] " Andrew Cooper
2014-11-26 18:17   ` Stefano Stabellini
2014-11-27  2:42     ` Don Slutz
2014-11-27 10:48       ` Stefano Stabellini
2014-12-01 13:33         ` Don Slutz
2014-12-01 15:37           ` Stefano Stabellini
2014-12-01 23:16             ` Don Slutz
2014-12-02 12:26               ` Stefano Stabellini
2014-12-02 20:23                 ` Don Slutz
2014-12-03 10:54                   ` Wei Liu
2014-12-03 12:20                     ` Stefano Stabellini
2014-12-03 13:39                       ` Don Slutz
2014-12-03 14:50                         ` Stefano Stabellini
2014-12-04 16:26                           ` Don Slutz
2014-12-04 16:38                             ` Wei Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).