All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] oslib-posix: Print errors before aborting on qemu_alloc_stack()
@ 2017-08-29 21:20 Eduardo Habkost
  2017-08-29 23:30 ` Philippe Mathieu-Daudé
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eduardo Habkost @ 2017-08-29 21:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Stefan Hajnoczi

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 <ehabkost@redhat.com>
---
 util/oslib-posix.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index cacf0ef..80086c5 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -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();
     }
 
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] oslib-posix: Print errors before aborting on qemu_alloc_stack()
  2017-08-29 21:20 [Qemu-devel] [PATCH] oslib-posix: Print errors before aborting on qemu_alloc_stack() Eduardo Habkost
@ 2017-08-29 23:30 ` Philippe Mathieu-Daudé
  2017-08-30  8:33 ` Stefan Hajnoczi
  2017-08-30  8:33 ` Stefan Hajnoczi
  2 siblings, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-08-29 23:30 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel; +Cc: Kevin Wolf, Stefan Hajnoczi

On 08/29/2017 06:20 PM, Eduardo Habkost wrote:
> 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 <ehabkost@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>   util/oslib-posix.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/util/oslib-posix.c b/util/oslib-posix.c
> index cacf0ef..80086c5 100644
> --- a/util/oslib-posix.c
> +++ b/util/oslib-posix.c
> @@ -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();
>       }
>   
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] oslib-posix: Print errors before aborting on qemu_alloc_stack()
  2017-08-29 21:20 [Qemu-devel] [PATCH] oslib-posix: Print errors before aborting on qemu_alloc_stack() Eduardo Habkost
  2017-08-29 23:30 ` Philippe Mathieu-Daudé
@ 2017-08-30  8:33 ` Stefan Hajnoczi
  2017-08-30  8:33 ` Stefan Hajnoczi
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2017-08-30  8:33 UTC (permalink / raw)
  To: Eduardo Habkost; +Cc: qemu-devel, Kevin Wolf, Stefan Hajnoczi

On Tue, Aug 29, 2017 at 06:20:53PM -0300, Eduardo Habkost wrote:
> 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 <ehabkost@redhat.com>
> ---
>  util/oslib-posix.c | 2 ++
>  1 file changed, 2 insertions(+)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] oslib-posix: Print errors before aborting on qemu_alloc_stack()
  2017-08-29 21:20 [Qemu-devel] [PATCH] oslib-posix: Print errors before aborting on qemu_alloc_stack() Eduardo Habkost
  2017-08-29 23:30 ` Philippe Mathieu-Daudé
  2017-08-30  8:33 ` Stefan Hajnoczi
@ 2017-08-30  8:33 ` Stefan Hajnoczi
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2017-08-30  8:33 UTC (permalink / raw)
  To: Eduardo Habkost; +Cc: qemu-devel, Kevin Wolf, Stefan Hajnoczi

On Tue, Aug 29, 2017 at 06:20:53PM -0300, Eduardo Habkost wrote:
> 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 <ehabkost@redhat.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-08-30  8:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-29 21:20 [Qemu-devel] [PATCH] oslib-posix: Print errors before aborting on qemu_alloc_stack() Eduardo Habkost
2017-08-29 23:30 ` Philippe Mathieu-Daudé
2017-08-30  8:33 ` Stefan Hajnoczi
2017-08-30  8:33 ` Stefan Hajnoczi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.