oslib-posix: Print errors before aborting on qemu_alloc_stack()
PATCH 1/1 oslib-posix: Print errors before aborting on qemu_alloc_stack()
If QEMU is running on a system that's out of memory and mmap() fails, QEMU aborts with no error message at all, making it hard to debug the reason for the failure.
Add perror() calls that will print error information before aborting.
--- util/oslib-posix.c | 2 ++ 1 file changed, 2 insertions(+)
util/oslib-posix.c +2 -0
@@ -530,6 +530,7 @@ void *qemu_alloc_stack(size_t *sz) ptr =mmap (NULL , *sz,PROT_READ |PROT_WRITE ,MAP_PRIVATE |MAP_ANONYMOUS ,-1 ,0 );if (ptr ==MAP_FAILED ) { +perror ("failed to allocate memory for stack" );abort (); }
@@ -544,6 +545,7 @@ void *qemu_alloc_stack(size_t *sz) guardpage = ptr;#endif if (mprotect (guardpage, pagesz,PROT_NONE ) !=0 ) { +perror ("failed to set up stack guard page" );abort (); }
Signature · 1 line
2.9.4
Quoted 8 lines · Eduardo Habkost
If QEMU is running on a system that's out of memory and
mmap()fails, QEMU aborts with no error message at all, making it hard to debug the reason for the failure.Add
perror()calls that will print error information before aborting.Signed-off-by Eduardo Habkost <[email protected]>
Quoted 25 lines
--- util/oslib-posix.c | 2 ++ 1 file changed, 2 insertions(+)util/oslib-posix.c +2
-0@@ -530,6 +530,7 @@ void *qemu_alloc_stack(size_t *sz) ptr =mmap (NULL , *sz,PROT_READ |PROT_WRITE ,MAP_PRIVATE |MAP_ANONYMOUS ,-1 ,0 );if (ptr ==MAP_FAILED ) { +perror ("failed to allocate memory for stack" );abort (); }@@ -544,6 +545,7 @@ void *qemu_alloc_stack(size_t *sz) guardpage = ptr;#endif if (mprotect (guardpage, pagesz,PROT_NONE ) !=0 ) { +perror ("failed to set up stack guard page" );abort (); }
Quoted 11 lines · Eduardo Habkost
If QEMU is running on a system that's out of memory and
mmap()fails, QEMU aborts with no error message at all, making it hard to debug the reason for the failure.Add
perror()calls that will print error information before aborting.Signed-off-by Eduardo Habkost <[email protected]>--- util/oslib-posix.c | 2 ++ 1 file changed, 2 insertions(+)
Stefan Hajnoczi
AppliedQuoted 11 lines · Eduardo Habkost
If QEMU is running on a system that's out of memory and
mmap()fails, QEMU aborts with no error message at all, making it hard to debug the reason for the failure.Add
perror()calls that will print error information before aborting.Signed-off-by Eduardo Habkost <[email protected]>--- util/oslib-posix.c | 2 ++ 1 file changed, 2 insertions(+)
Thanks, applied to my block-next tree:
https://github.com/stefanha/qemu/commits/block-next
Stefan