Commit 9224a0666b for qemu.org

commit 9224a0666b0612048e4f9ffb15c368d5167fa3ff
Author: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Date:   Sat Aug 22 20:27:08 2026 +0800

    system/physmem: Improve guest memory allocation failure error message

    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>
    Link: https://lore.kernel.org/r/20260822122710.3731595-2-bin.meng@processmission.com
    Cc: Paolo Bonzini <pbonzini@redhat.com>
    Cc: Peter Xu <peterx@redhat.com>
    Cc: "Philippe Mathieu-Daudé" <philmd@mailo.com>
    Signed-off-by: Peter Xu <peterx@redhat.com>

diff --git a/system/physmem.c b/system/physmem.c
index a4a6a4710c..bd5f41cb02 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;