All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Stefan Weil <weil@mail.berlios.de>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] Tell users about out-of-memory errors
Date: Tue, 26 Jan 2010 18:06:40 -0600	[thread overview]
Message-ID: <4B5F8390.5080807@codemonkey.ws> (raw)
In-Reply-To: <1264109098-14373-1-git-send-email-weil@mail.berlios.de>

On 01/21/2010 03:24 PM, Stefan Weil wrote:
> Aborting without an error message when memory is short
> is not helpful, so print the reason for the abort.
>
> Try
> 	qemu -m 1000000
> or
> 	qemu -m 2000 (win32)
>
> to force an out-of-memory error.
>
> v2:
> * Fix error message for win32.
> * Fix error message for posix_memalign.
>
> Thanks to malc for the hints.
>
> Signed-off-by: Stefan Weil<weil@mail.berlios.de>
>    

Applied.  Thanks.

Regards,

Anthony Liguori
> ---
>   osdep.c |   10 +++++++++-
>   1 files changed, 9 insertions(+), 1 deletions(-)
>
> diff --git a/osdep.c b/osdep.c
> index 1310684..9b47066 100644
> --- a/osdep.c
> +++ b/osdep.c
> @@ -52,6 +52,11 @@
>   static void *oom_check(void *ptr)
>   {
>       if (ptr == NULL) {
> +#if defined(_WIN32)
> +        fprintf(stderr, "Failed to allocate memory: %lu\n", GetLastError());
> +#else
> +        fprintf(stderr, "Failed to allocate memory: %s\n", strerror(errno));
> +#endif
>           abort();
>       }
>       return ptr;
> @@ -91,8 +96,11 @@ void *qemu_memalign(size_t alignment, size_t size)
>       int ret;
>       void *ptr;
>       ret = posix_memalign(&ptr, alignment, size);
> -    if (ret != 0)
> +    if (ret != 0) {
> +        fprintf(stderr, "Failed to allocate %zu B: %s\n",
> +                size, strerror(ret));
>           abort();
> +    }
>       return ptr;
>   #elif defined(CONFIG_BSD)
>       return oom_check(valloc(size));
>    

      reply	other threads:[~2010-01-27  0:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-20 21:16 [Qemu-devel] [PATCH] Tell users about out-of-memory errors Stefan Weil
2010-01-20 23:13 ` malc
2010-01-21 21:24   ` Stefan Weil
2010-01-27  0:06     ` Anthony Liguori [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B5F8390.5080807@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=qemu-devel@nongnu.org \
    --cc=weil@mail.berlios.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.