exec: file_ram_alloc(): print error when prealloc fails
diff mbox

Message ID 20140908140826.3a673423@redhat.com
State New
Headers show

Commit Message

Luiz Capitulino Sept. 8, 2014, 6:08 p.m. UTC
If memory allocation fails when using the -mem-prealloc command-line
option, QEMU exits without printing any error information to
the user:

 # qemu [...] -m 1G -mem-prealloc -mem-path /dev/hugepages
 # echo $?
 1

This commit adds an error message, so that we print instead:

 # qemu [...] -m 1G -mem-prealloc -mem-path /dev/hugepages
 qemu: unable to map backing store for hugepages: Cannot allocate memory

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 exec.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Eric Blake Sept. 8, 2014, 7:28 p.m. UTC | #1
On 09/08/2014 12:08 PM, Luiz Capitulino wrote:
> If memory allocation fails when using the -mem-prealloc command-line
> option, QEMU exits without printing any error information to
> the user:
> 
>  # qemu [...] -m 1G -mem-prealloc -mem-path /dev/hugepages
>  # echo $?
>  1
> 
> This commit adds an error message, so that we print instead:
> 
>  # qemu [...] -m 1G -mem-prealloc -mem-path /dev/hugepages
>  qemu: unable to map backing store for hugepages: Cannot allocate memory
> 
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> ---
>  exec.c | 1 +
>  1 file changed, 1 insertion(+)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

Patch
diff mbox

diff --git a/exec.c b/exec.c
index 7dddcc8..cb73d16 100644
--- a/exec.c
+++ b/exec.c
@@ -1130,6 +1130,7 @@  static void *file_ram_alloc(RAMBlock *block,
 
 error:
     if (mem_prealloc) {
+        error_report("%s\n", error_get_pretty(*errp));
         exit(1);
     }
     return NULL;