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 <hu...@cn.fujitsu.com> 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 <hu...@cn.fujitsu.com> > > > --- > > > 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 > > >