From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XtKnG-0004wR-5V for qemu-devel@nongnu.org; Tue, 25 Nov 2014 13:24:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XtKnB-0006r3-DD for qemu-devel@nongnu.org; Tue, 25 Nov 2014 13:24:54 -0500 Received: from smtp02.citrix.com ([66.165.176.63]:33733) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XtKnB-0006pk-8W for qemu-devel@nongnu.org; Tue, 25 Nov 2014 13:24:49 -0500 Message-ID: <5474C96A.6090506@citrix.com> Date: Tue, 25 Nov 2014 18:24:42 +0000 From: Andrew Cooper MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [Xen-devel] [PATCH] increase maxmem before calling xc_domain_populate_physmap List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefano Stabellini , qemu-devel@nongnu.org Cc: xen-devel@lists.xensource.com, "Wei Liu (Intern)" , Ian Campbell On 25/11/14 17:45, Stefano Stabellini wrote: > Increase maxmem before calling xc_domain_populate_physmap_exact to avoi= d > 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 > > 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; > =20 > 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] =3D (ram_addr >> TARGET_PAGE_BITS) + i; > } > =20 > + if (xc_domain_getinfo(xen_xc, xen_domid, 1, &info) < 0) { xc_domain_getinfo()'s interface is mad, and provides no guarantee that it returns the information for the domain you requested. It also won't return -1 on error. The correct error handing is: (xc_domain_getinfo(xen_xc, xen_domid, 1, &info) !=3D 1) || (info.domid !=3D= xen_domid) ~Andrew > + 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_a= ddr); > } > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel