From patchwork Fri Aug 20 15:52:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 1519093 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Teg4Om6N; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GrmP11T8fz9sW5 for ; Sat, 21 Aug 2021 01:52:36 +1000 (AEST) Received: from localhost ([::1]:43258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mH6or-0005LP-Vs for incoming@patchwork.ozlabs.org; Fri, 20 Aug 2021 11:52:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56320) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mH6ob-0005LA-GO for qemu-devel@nongnu.org; Fri, 20 Aug 2021 11:52:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50804) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mH6oZ-0007Nd-Ve for qemu-devel@nongnu.org; Fri, 20 Aug 2021 11:52:17 -0400 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= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-480-GrBgBEvGMgSPisxTUBIRpQ-1; Fri, 20 Aug 2021 11:52:13 -0400 X-MC-Unique: GrBgBEvGMgSPisxTUBIRpQ-1 Received: by mail-wr1-f70.google.com with SMTP id p10-20020adfce0a000000b001572d05c970so803706wrn.21 for ; Fri, 20 Aug 2021 08:52:13 -0700 (PDT) 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=b9T50LnYRu2huw275RGa6fo4ef9fNDQY8oHPKxbPNEfNlRuY2LcULfarPETBLRcmsN rTyNVoO46efZ/G3wl8iJ62ofbbKxIkwe9NJYwA+0YiZRB861gieuewqHkAiFX6HBK6oL eezYyyNNhhUvKx2zUuMt1Kn9mva2+Cn/jpmi1FaavO9tk+x3vjv1ZeQSTfO9W4KuIvCv 0YRWvFCrzLoi9lYrU4E/PQHqi2Lv/oD10It7RfwEP6gODN0YVBG2KfbyMH6YOQoAi41f 6TCI6k2ql7vLnYJmlfpxBoEnrdX1h6Gf7UFJ6T7lIZsXaqTCojO9JA29j8lA1cw1smgn Cy5A== X-Gm-Message-State: AOAM532fzLbBaL7+2kgGONzgG5HFZbN8hEn+DUhSvDT8YAez40qb7C1U 00LbpVrxnU/yoPSDpyFwIF3roJBnJxo55nNefsJu2tD7ckpqcDwTGKAkZ1TUIIE0rdcpijYPejC bdhM3OSFbVz0DNcHrO0V636xNgD4A8s8mQnjbNLwkoHd+5/tm+tuvr6dl+5JfpPbI X-Received: by 2002:a05:600c:21ce:: with SMTP id x14mr4724557wmj.187.1629474732688; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Hildenbrand , Peter Xu , Paolo Bonzini , Igor Mammedov , Bin Meng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 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é 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 = 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;