Skip to contentSkip to conversation

exec: file_ram_alloc(): print error when prealloc fails

PATCH In review Luiz Capitulino 2 participants 2 messages Sep 8, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 exec: file_ram_alloc(): print error when prealloc fails

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
---
 exec.c | 1 +
 1 file changed, 1 insertion(+)
exec.c +1 -0
index 7dddcc8..cb73d16 100644
@@ -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;
Signature · 1 line
1.9.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Luiz Capitulino

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:

Quoted 8 lines
 # qemu [...] -m 1G -mem-prealloc -mem-path /dev/hugepages
 qemu: unable to map backing store for hugepages: Cannot allocate memory
---
 exec.c | 1 +
 1 file changed, 1 insertion(+)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org