From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24245C4338F for ; Fri, 20 Aug 2021 16:03:36 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id BE62F61221 for ; Fri, 20 Aug 2021 16:03:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BE62F61221 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:33254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mH6zW-0001HQ-SK for qemu-devel@archiver.kernel.org; Fri, 20 Aug 2021 12:03:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mH6wd-0005zc-FH for qemu-devel@nongnu.org; Fri, 20 Aug 2021 12:00:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56608) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mH6wb-0005qo-Ot for qemu-devel@nongnu.org; Fri, 20 Aug 2021 12:00:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629475232; 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: in-reply-to:in-reply-to:references:references; bh=j5dSjhlNUq6u7o7NicB0F+lvfhsc3TR9zM+HrOXIAM8=; b=LXb/MP/c1koK5uQZrRFedm4SetcImIXOZy9Mr3zDGBgHAqLpmNs1QFSsqgN7YXIJagiNSu uF3OWPPR3OigcGn1Au1SRLJY/beQ7LA+lbEeYFiFvWcvr+Y+GsoqtqZZYgolLZxaC18GF4 eRJcjTx7+TEWgoZ1N796akMv1KvPq6s= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-218-difx53MOOnKR5DQXyCztOQ-1; Fri, 20 Aug 2021 12:00:28 -0400 X-MC-Unique: difx53MOOnKR5DQXyCztOQ-1 Received: by mail-wm1-f71.google.com with SMTP id c2-20020a7bc8420000b0290238db573ab7so4979545wml.5 for ; Fri, 20 Aug 2021 09:00:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=j5dSjhlNUq6u7o7NicB0F+lvfhsc3TR9zM+HrOXIAM8=; b=NRsmlFYuUH+w/pOrmxbqUDfoqIOpqrHefRYYlyQaKCWZsYYjGneDdK/WIIVfmPmVOP YVpfB68G+V0ZwkZtV6Zl5txlKYjE7gfeEWN1DLez8mgB3nT0ypmlC3kTeNy0OXDF+4ul 5VHEpw7FOCDTbTNjgpYocsg/2ESm1oZ3Zu97UwQZB8lkaJhna94RJTmDwoxiyPIyW3WA StStvXI8vbmtlhmPP/nvaO3ysXyEIVsAjoprSIPja5OvRM9imRWgDLVEzZ41Rqw4TEOb vHiABpC+6ZYW4dWnAXo16SUKuIzJwQueR1Svp/oQTP6++TZb4MGI2dQuYzTrQbPxBKpJ 46uw== X-Gm-Message-State: AOAM531ADfJDZraO4m9rbf7Ms5/wNMIY4nOVyC96qyDR3NspJU4hyPqd oQ6cGS+pk9mnTd4WX/lwCjTMCJtZ8Y85eXSaCV3efZ3JKZFmDwWOr7FIyjmKvvqqHTKIEHpFO1B 14OOHscHc19O0Ja4= X-Received: by 2002:adf:e10c:: with SMTP id t12mr11016482wrz.36.1629475227519; Fri, 20 Aug 2021 09:00:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCOP0PqlKVauRQCwETx1mf27IS9+3Gha50vLreXaf5LPqfr3FyPO6/oo3q3pVWJIeDfuEgLw== X-Received: by 2002:adf:e10c:: with SMTP id t12mr11016467wrz.36.1629475227401; Fri, 20 Aug 2021 09:00:27 -0700 (PDT) Received: from [192.168.1.36] (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id e4sm6365082wrw.74.2021.08.20.09.00.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 Aug 2021 09:00:26 -0700 (PDT) Subject: Re: [PATCH] softmmu/physmem: Improve guest memory allocation failure error message To: David Hildenbrand , qemu-devel@nongnu.org, "Dr. David Alan Gilbert" References: <20210820155211.3153137-1-philmd@redhat.com> <20a53e29-ba23-fe0d-f961-63d0b5ca9a89@redhat.com> From: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= Message-ID: Date: Fri, 20 Aug 2021 18:00:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20a53e29-ba23-fe0d-f961-63d0b5ca9a89@redhat.com> 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-Language: en-US Content-Transfer-Encoding: 8bit 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: -49 X-Spam_score: -5.0 X-Spam_bar: ----- X-Spam_report: (-5.0 / 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, NICE_REPLY_A=-1.49, 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: Igor Mammedov , Bin Meng , Peter Xu , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 8/20/21 5:53 PM, David Hildenbrand wrote: > On 20.08.21 17:52, Philippe Mathieu-Daudé wrote: >> 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é >> --- >>   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; >> > > IIRC, ram blocks might not necessarily be used for guest memory ... or > is my memory wrong? No clue, this error message was already here. No problem to change s/guest/block/ although.