From: Bin Meng <bin.meng@processmission.com>
To: QEMU <qemu-devel@nongnu.org>
Cc: "Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Bin Meng" <bmeng.cn@gmail.com>, "Peter Xu" <peterx@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@mailo.com>
Subject: [PATCH v2 1/1] system/physmem: Improve guest memory allocation failure error message
Date: Sat, 22 Aug 2026 20:27:08 +0800 [thread overview]
Message-ID: <20260822122710.3731595-2-bin.meng@processmission.com> (raw)
In-Reply-To: <20260822122710.3731595-1-bin.meng@processmission.com>
From: Philippe Mathieu-Daudé <philmd@redhat.com>
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
Slightly improve the error message, displaying the memory size
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>
Reviewed-by: Peter Xu <peterx@redhat.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Bin Meng <bin.meng@processmission.com>
---
Changes in v2:
- Rebase onto current master
- Update the source path from softmmu/physmem.c to system/physmem.c
- Fix a typo in the commit message
- Collect Peter Xu's Reviewed-by and Bin Meng's Tested-by
system/physmem.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/system/physmem.c b/system/physmem.c
index 362a00f76c..89ce6479f1 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -2171,8 +2171,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);
error_setg_errno(errp, errno,
- "cannot set up guest memory '%s'",
+ "Cannot set up %s of guest memory '%s'",
+ size_s,
memory_region_name(new_block->mr));
qemu_mutex_unlock_ramlist();
return;
--
2.53.0
next prev parent reply other threads:[~2026-08-22 12:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-22 12:27 [PATCH v2 0/1] system/physmem: Improve guest memory allocation failure diagnostics Bin Meng
2026-08-22 12:27 ` Bin Meng [this message]
2026-08-24 19:24 ` [PATCH v2 1/1] system/physmem: Improve guest memory allocation failure error message Peter Xu
2026-08-24 21:20 ` 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=20260822122710.3731595-2-bin.meng@processmission.com \
--to=bin.meng@processmission.com \
--cc=bmeng.cn@gmail.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@mailo.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 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.