qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 3/4] memory-backend-file: improve error handl


From: Igor Mammedov
Subject: Re: [Qemu-devel] [PATCH v2 3/4] memory-backend-file: improve error handling
Date: Tue, 17 Jun 2014 12:03:13 +0200

On Mon, 16 Jun 2014 18:05:43 +0800
Hu Tao <address@hidden> 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 <address@hidden>
> ---
>  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?

> +        g_free(new_block);
> +        error_setg(errp, "failed to allocate memory\n");
> +        return -1;
> +    }
> +
> +    return addr;
>  }
>  #endif
>  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]