From nobody Sun Feb 8 14:56:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1629474736; cv=none; d=zohomail.com; s=zohoarc; b=nEDZzGGZgvZ2rZYuaef2kNuySKcbXhJANsUbhFPK4lapKSYVouAoNugm84dXIKu4whOpcDwgpZVS5AL35uR0LHpQoh5nUlksmaq8EPI08TUfuhjhZODhi/ko0bdnvauWtPwii+t2Kgqgv2KZCHGAk1bCpUSTQKMy0iNu2bv4gjk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629474736; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=JyvK/4+u0ni2k4EpGGoUzxSNQskts9xhrmwBcCNWJFA=; b=TE3o5pUUfvvaLOTS9mLDf9k3DlnQxSICyJKYuKu3pX5B25AJElaVE2XlfMqy/CKpcNkB1K52AvYUW1UIYSyAKt9FaBm9mgP/1Yv4Xbvn0Trzn/IX/+ZPmIjIX0ob0RUSU3w6vcRw7pe/6Hm2ePUkRHaDIcffHVH+XrZz7dIbkOI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 16294747360345.408949782179548; Fri, 20 Aug 2021 08:52:16 -0700 (PDT) Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-449-ycsnG5JmPXir87rWk-QfaQ-1; Fri, 20 Aug 2021 11:52:14 -0400 Received: by mail-wr1-f69.google.com with SMTP id a9-20020a0560000509b029015485b95d0cso2994971wrf.5 for ; Fri, 20 Aug 2021 08:52:13 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.. (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id l2sm6163811wrx.2.2021.08.20.08.52.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Aug 2021 08:52:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629474735; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JyvK/4+u0ni2k4EpGGoUzxSNQskts9xhrmwBcCNWJFA=; b=Teg4Om6NrA517ssgGdxUb66zTtNs2lgyo/soWW8kf3kkXaSnz97ppQ7cq9xqEROR8gComV 5nynncQebUoNHtbUWKRnOpJHDROSLUpGGhkMEP2O6bjw9ZbmJOkjfU4znVTAxd5WfdHZo+ I9eiFQoIOD2UTjP5yW1S+nrinGWfcNE= X-MC-Unique: ycsnG5JmPXir87rWk-QfaQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=JyvK/4+u0ni2k4EpGGoUzxSNQskts9xhrmwBcCNWJFA=; b=RKRfd5SQyE6Ad/9KaEBwvXLRxZHfFXkWtEnGuxg0556qxkBo9gTniJO65GAI0inVTm 2eTjE1C4WBNjRtOGBxb7Sskvmm7Xx04xgFO9jQB2Ny9Dg2NskdLtUFT6U2RcBO67kxTV 4AfeGHriIM++9Nyw3qyOjhGwFHC3nNnMb7i28B+QpIqajHrO8buXeFPxLnekO+a4DiJp nDJvWyrk3DrsYl+ruDg+LtQ6GSBaST0lKMiFVOWEJqNlEVDJ4JStwOsuwJi/OIJVHYAo yPbltFuW6nYMqt+OG0XiIkwfdQk2iePtvmAnKNkTvTgZqjBqGsKkZDriVhwF+MFZc0jj Qmqg== X-Gm-Message-State: AOAM530i2rcmWiJrl4OI4ioSCXP5JdNDAE+/MEVJpsSmTGUsmcmEVOaQ poCglY3J5pOKiCA9UipGSTayChJVOaJJ2CvOQ/V8FDbC28c9FytYYRVLIbOLUEqQyQcWCwFroxV NkXKbxfbvYCkDug== X-Received: by 2002:a05:600c:21ce:: with SMTP id x14mr4724580wmj.187.1629474732969; Fri, 20 Aug 2021 08:52:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCA+O25wQBlacZxERuhJsXx7iKFrV8+hpeoFCPdQkXxx06eAFgZLbBTC44Fj1QxpUUZFC3uA== X-Received: by 2002:a05:600c:21ce:: with SMTP id x14mr4724539wmj.187.1629474732459; Fri, 20 Aug 2021 08:52:12 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Igor Mammedov , Paolo Bonzini , Peter Xu , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Bin Meng Subject: [PATCH] softmmu/physmem: Improve guest memory allocation failure error message Date: Fri, 20 Aug 2021 17:52:11 +0200 Message-Id: <20210820155211.3153137-1-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1629474738056100001 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 me= mory Slighly 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 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Xu Tested-by: Bin Meng --- 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 =3D size_to_str(new_block->max_len= gth); 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; --=20 2.31.1