From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wwr47-00089g-64 for qemu-devel@nongnu.org; Tue, 17 Jun 2014 06:56:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wwr42-0005nG-Hc for qemu-devel@nongnu.org; Tue, 17 Jun 2014 06:56:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43191) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wwr42-0005nA-8H for qemu-devel@nongnu.org; Tue, 17 Jun 2014 06:56:30 -0400 Date: Tue, 17 Jun 2014 13:56:52 +0300 From: "Michael S. Tsirkin" Message-ID: <20140617105652.GC6991@redhat.com> References: <20140617120313.09e90c6f@nial.usersys.redhat.com> <20140617100908.GB10134@G08FNSTD100614.fnst.cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140617100908.GB10134@G08FNSTD100614.fnst.cn.fujitsu.com> Subject: Re: [Qemu-devel] [PATCH v2 3/4] memory-backend-file: improve error handling List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Hu Tao Cc: Igor Mammedov , Paolo Bonzini , qemu-devel@nongnu.org, Yasunori Goto On Tue, Jun 17, 2014 at 06:09:08PM +0800, Hu Tao wrote: > On Tue, Jun 17, 2014 at 12:03:13PM +0200, Igor Mammedov wrote: > > On Mon, 16 Jun 2014 18:05:43 +0800 > > Hu Tao wrote: > > > > > This patch fixes two problems of memory-backend-file: > > > > > > 1. If user adds a memory-backend-file object using object_add command, > > > specifying a non-existing directory for property mem-path, qemu > > > will core dump with message: > > > > > > /nonexistingdir: No such file or directory > > > Bad ram offset fffffffffffff000 > > > Aborted (core dumped) > > > > > > 2. If user adds a memory-backend-file object using object_add command, > > > specifying a size that is less than huge page size, qemu > > > will core dump with message: > > > > > > Bad ram offset fffffffffffff000 > > > Aborted (core dumped) > > > > > > Signed-off-by: Hu Tao > > > --- > > > exec.c | 26 ++++++++++++++++++-------- > > > 1 file changed, 18 insertions(+), 8 deletions(-) > > > > > > diff --git a/exec.c b/exec.c > > > index 8705cc5..a6afb4d 100644 > > > --- a/exec.c > > > +++ b/exec.c > > [...] > > > @@ -1308,7 +1311,14 @@ ram_addr_t qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr, > > > return -1; > > > } > > > > > > - return ram_block_add(new_block); > > > + addr = ram_block_add(new_block); > > > + if (addr == -1) { > > how this hunk is relevant to commit message? > > > > and more important in what case ram_block_add() returns -1? > > See patch 03 int v1(titled [PATCH RFC 3/4] exec: don't exit unconditionally if failed to allocate memory) > It is not included in this version but we'll fix it after the merge. So maybe defer this hunk to after the merge too. > > > > > + g_free(new_block); > > > + error_setg(errp, "failed to allocate memory\n"); > > > + return -1; > > > + } > > > + > > > + return addr; > > > } > > > #endif > > >