From: Bin Meng <bmeng.cn@gmail.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
Peter Xu <peterx@redhat.com>,
David Hildenbrand <david@redhat.com>
Subject: Re: [PATCH] softmmu/physmem: Improve guest memory allocation failure error message
Date: Sat, 21 Aug 2021 18:01:26 +0800 [thread overview]
Message-ID: <CAEUhbmXP7=0j10Kf3w1DsPb-ByCTv+dSGbF=0ARQXd44soyv6A@mail.gmail.com> (raw)
In-Reply-To: <20210820155211.3153137-1-philmd@redhat.com>
On Fri, Aug 20, 2021 at 11:52 PM Philippe Mathieu-Daudé
<philmd@redhat.com> wrote:
>
> When Linux refuses to overcommit a seriously wild allocation we get:
>
> $ qemu-system-i386 -m 40000000
> qemu-system-i386: cannot set up guest memory 'pc.ram': Cannot allocate memory
>
> Slighly improve the error message, displaying the memory size
typo: Slightly
> requested (in case the user didn't expect unspecified memory size
> unit is in MiB):
>
> $ qemu-system-i386 -m 40000000
> qemu-system-i386: Cannot set up 38.1 TiB of guest memory 'pc.ram': Cannot allocate memory
>
> Reported-by: Bin Meng <bmeng.cn@gmail.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> softmmu/physmem.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/softmmu/physmem.c b/softmmu/physmem.c
> index 2e18947598e..2f300a9e79b 100644
> --- a/softmmu/physmem.c
> +++ b/softmmu/physmem.c
> @@ -1982,8 +1982,10 @@ static void ram_block_add(RAMBlock *new_block, Error **errp)
> &new_block->mr->align,
> shared, noreserve);
> if (!new_block->host) {
> + g_autofree char *size_s = size_to_str(new_block->max_length);
Does g_autofree work with every compiler we support?
Looks it only applies to GCC and clang?
https://www.gitmemory.com/issue/linuxwacom/libwacom/142/518787578
> error_setg_errno(errp, errno,
> - "cannot set up guest memory '%s'",
> + "Cannot set up %s of guest memory '%s'",
> + size_s,
Nice improvement!
> memory_region_name(new_block->mr));
> qemu_mutex_unlock_ramlist();
> return;
Tested-by: Bin Meng <bmeng.cn@gmail.com>
next prev parent reply other threads:[~2021-08-21 10:03 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-20 15:52 [PATCH] softmmu/physmem: Improve guest memory allocation failure error message Philippe Mathieu-Daudé
2021-08-20 15:53 ` David Hildenbrand
2021-08-20 16:00 ` Philippe Mathieu-Daudé
2021-08-20 16:40 ` Igor Mammedov
2021-08-20 16:59 ` Philippe Mathieu-Daudé
2021-08-20 17:13 ` Peter Maydell
2021-08-23 8:38 ` David Hildenbrand
2021-08-23 9:23 ` Peter Maydell
2021-08-23 9:29 ` David Hildenbrand
2021-08-23 10:12 ` Philippe Mathieu-Daudé
2021-08-23 10:24 ` David Hildenbrand
2021-08-23 10:34 ` Philippe Mathieu-Daudé
2021-08-23 19:27 ` David Hildenbrand
2021-08-24 8:37 ` Dr. David Alan Gilbert
2021-08-24 8:53 ` David Hildenbrand
2021-08-24 11:42 ` Igor Mammedov
2021-08-20 20:31 ` Peter Xu
2021-08-21 10:01 ` Bin Meng [this message]
2021-08-21 10:41 ` Peter Maydell
2021-08-21 13:32 ` Philippe Mathieu-Daudé
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='CAEUhbmXP7=0j10Kf3w1DsPb-ByCTv+dSGbF=0ARQXd44soyv6A@mail.gmail.com' \
--to=bmeng.cn@gmail.com \
--cc=david@redhat.com \
--cc=imammedo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).