* [PATCH v2 0/1] system/physmem: Improve guest memory allocation failure diagnostics
@ 2026-08-22 12:27 Bin Meng
2026-08-22 12:27 ` [PATCH v2 1/1] system/physmem: Improve guest memory allocation failure error message Bin Meng
0 siblings, 1 reply; 4+ messages in thread
From: Bin Meng @ 2026-08-22 12:27 UTC (permalink / raw)
To: QEMU; +Cc: Paolo Bonzini, Peter Xu, Philippe Mathieu-Daudé
This revives Philippe Mathieu-Daudé's patch from 2021. The original
posting and discussion are available at:
https://lore.kernel.org/r/20210820155211.3153137-1-philmd@redhat.com
When host memory allocation fails, QEMU reports the affected memory
region and host error, but not the size of the failed allocation. This
makes accidental requests harder to spot. In particular, a bare value
passed to '-m' is interpreted as MiB, so a user expecting bytes can
unintentionally request tens of TiB.
The patch adds the human-readable RAMBlock size to the existing error.
This does not try to explain host-specific overcommit, cgroup, or NUMA
policy. It provides the most useful portable fact available at the
failure site and makes both user mistakes and support reports easier
to diagnose.
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
Philippe Mathieu-Daudé (1):
system/physmem: Improve guest memory allocation failure error message
system/physmem.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
---
base-commit: eea8fe61b8be8f3016e522e6af24924a0266ca95
branch: virt
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/1] system/physmem: Improve guest memory allocation failure error message
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
2026-08-24 19:24 ` Peter Xu
2026-08-24 21:20 ` Philippe Mathieu-Daudé
0 siblings, 2 replies; 4+ messages in thread
From: Bin Meng @ 2026-08-22 12:27 UTC (permalink / raw)
To: QEMU
Cc: Philippe Mathieu-Daudé, Bin Meng, Peter Xu, Paolo Bonzini,
Philippe Mathieu-Daudé
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
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2 1/1] system/physmem: Improve guest memory allocation failure error message
2026-08-22 12:27 ` [PATCH v2 1/1] system/physmem: Improve guest memory allocation failure error message Bin Meng
@ 2026-08-24 19:24 ` Peter Xu
2026-08-24 21:20 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 4+ messages in thread
From: Peter Xu @ 2026-08-24 19:24 UTC (permalink / raw)
To: Bin Meng
Cc: QEMU, Philippe Mathieu-Daudé, Bin Meng, Paolo Bonzini,
Philippe Mathieu-Daudé
On Sat, Aug 22, 2026 at 08:27:08PM +0800, Bin Meng wrote:
> 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
queued, thanks.
--
Peter Xu
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/1] system/physmem: Improve guest memory allocation failure error message
2026-08-22 12:27 ` [PATCH v2 1/1] system/physmem: Improve guest memory allocation failure error message Bin Meng
2026-08-24 19:24 ` Peter Xu
@ 2026-08-24 21:20 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-08-24 21:20 UTC (permalink / raw)
To: Bin Meng, QEMU
Cc: Philippe Mathieu-Daudé, Bin Meng, Peter Xu, Paolo Bonzini,
Philippe Mathieu-Daudé
On 22/8/26 14:27, Bin Meng wrote:
> 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
Thanks! :)
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
>
> system/physmem.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-08-24 21:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-22 12:27 [PATCH v2 0/1] system/physmem: Improve guest memory allocation failure diagnostics Bin Meng
2026-08-22 12:27 ` [PATCH v2 1/1] system/physmem: Improve guest memory allocation failure error message Bin Meng
2026-08-24 19:24 ` Peter Xu
2026-08-24 21:20 ` Philippe Mathieu-Daudé
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.