From nobody Fri Apr 26 22:33:50 2024 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=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1619343332; cv=none; d=zohomail.com; s=zohoarc; b=TIRFxUpfOhT+k3aYnwcuO+YhGfduOgTO32/NTF6PoUEW2swP9ngEsBwvS99166zebfCZkjY1Tct+H+P4iAKLyjXd4pD14GC2n7kry2VAB1Iafmmz/Fh4Fb2y9U1coS7gZec+RgV3Pvq3RxGm/62foGPBkmDA79ZDIxokNHfyrb0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619343332; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=SMedNkocoxpnXj4mrw+G5UKxfLxEMgT9iZ4zV3ACjiU=; b=CBIxMlxCI9dUPULHz91Xiz0uJ0YwS0/rWxU+6ysdFfeRpeJFRIkHkXZAqNAJTcHySMJko9idqrnlvkUHMr/JkyBV+VD/zvaEE8uan0gpuV1jycTngAA1wGH9VVfQYkjt/oD1nF2LlOfgh7Buw8pt7MrbMb9hXGqw6gfMGAy0ZY4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: 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 161934333203948.82363978234355; Sun, 25 Apr 2021 02:35:32 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-261-cZiX5zz8NeWwtcRWEyT4JQ-1; Sun, 25 Apr 2021 05:35:26 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 79B8C81746D; Sun, 25 Apr 2021 09:35:18 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 83B9F60BE5; Sun, 25 Apr 2021 09:35:16 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 34B4889DC; Sun, 25 Apr 2021 09:35:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13P9XkvN001897 for ; Sun, 25 Apr 2021 05:33:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4E53F111144A; Sun, 25 Apr 2021 09:33:46 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 49F251111449 for ; Sun, 25 Apr 2021 09:33:43 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C28C2185A7A7 for ; Sun, 25 Apr 2021 09:33:43 +0000 (UTC) Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-58-4CqMHvW0M_Cmp-67Fu-Y7w-1; Sun, 25 Apr 2021 05:33:41 -0400 Received: by mail-pj1-f53.google.com with SMTP id kb13-20020a17090ae7cdb02901503d67f0beso6378678pjb.0 for ; Sun, 25 Apr 2021 02:33:41 -0700 (PDT) Received: from C02D383UML85.bytedance.net ([139.177.225.235]) by smtp.gmail.com with ESMTPSA id q25sm8217968pfs.152.2021.04.25.02.33.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Apr 2021 02:33:39 -0700 (PDT) X-MC-Unique: cZiX5zz8NeWwtcRWEyT4JQ-1 X-MC-Unique: 4CqMHvW0M_Cmp-67Fu-Y7w-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=SMedNkocoxpnXj4mrw+G5UKxfLxEMgT9iZ4zV3ACjiU=; b=e2otxMrw/eqb5sKeOKEolVY+vuJB51v37EDo9LE9nLcvzvenZsK4IqM+HsZfFwv++R JxtJGHMPuxWHXvHdNguaiOa8b4J580x8P0Ymdqag9bSXE2NXmYGstMCWOsuWMSbN8DXY 0PH69xPcfitCSyq4As1YT5hjIOmZJgurxE2LANWhlA884ICe+y0N0x801wznQTewqaH9 UAOMes0IlTkPqvXJ63dM0yZr9VSdnfhvPW+gPCTUQUblyjJNknr2ca2Cd4vYW+yXSKXL gnQogGXORlXnxtcbruNa29T1cfgtcGuBhen9dAQ21gzy7/QYSui0atgN58hTzg+Y3iQM 4Bjg== X-Gm-Message-State: AOAM532or7yXw/wdF8kxM+NINiGYhXEcnBzPAOx76g6v5ylwaWst6JUj IQKiM8wY51kPPfeHle3LWkjOP42RnCJuNEaV X-Google-Smtp-Source: ABdhPJxMyguS45otk5r5kmKOZ5y3v96ZNDjaIBkCw1vwmHA7J/EYI2l80bEkUOic2QYJ0JqGUDHeZA== X-Received: by 2002:a17:90b:3511:: with SMTP id ls17mr8051811pjb.209.1619343219953; Sun, 25 Apr 2021 02:33:39 -0700 (PDT) From: Zhiyong Ye To: libvir-list@redhat.com Subject: [PATCH] qemu: add support for max-ram-below-4g option Date: Sun, 25 Apr 2021 17:33:31 +0800 Message-Id: <20210425093331.46153-1-yezhiyong@bytedance.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Zhiyong Ye , zhangruien , zhenwei pi X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Limit the amount of ram below 4G. This can increase the address space used by PCI devices below 4G and it can be used by adding attributes in XML like this: ... 4096 ... Signed-off-by: Zhiyong Ye Signed-off-by: zhenwei pi Signed-off-by: zhangruien --- src/conf/domain_conf.c | 19 +++++++++++++++++++ src/conf/domain_conf.h | 3 +++ src/qemu/qemu_command.c | 4 ++++ 3 files changed, 26 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a72d58f488..c211a69ed1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4720,6 +4720,19 @@ virDomainDefPostParseMemory(virDomainDef *def, return -1; } =20 + if (def->mem.max_ram_below_4g && + def->mem.max_ram_below_4g < (1ULL << 10)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("maximum memory size below the 4GiB boundary is t= oo small, " + "BIOS may not work with less than 1MiB")); + return -1; + } else if (def->mem.max_ram_below_4g > (1ULL << 22)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("maximum memory size below the 4GiB boundary must= be " + "less than or equal to 4GiB")); + return -1; + } + return 0; } =20 @@ -19786,6 +19799,10 @@ virDomainDefParseMemory(virDomainDef *def, &def->mem.max_memory, false, false) < 0) goto error; =20 + if (virDomainParseMemory("./memory[1]/@below4g", "./memory[1]/@unit", = ctxt, + &def->mem.max_ram_below_4g, false, true) < 0) + goto error; + if (virXPathUInt("string(./maxMemory[1]/@slots)", ctxt, &def->mem.memo= ry_slots) =3D=3D -2) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Failed to parse memory slot count")); @@ -28844,6 +28861,8 @@ virDomainDefFormatInternalSetRootName(virDomainDef = *def, if (def->mem.dump_core) virBufferAsprintf(buf, " dumpCore=3D'%s'", virTristateSwitchTypeToString(def->mem.dump_core= )); + if (def->mem.max_ram_below_4g > 0) + virBufferAsprintf(buf, " below4g=3D'%llu'", def->mem.max_ram_below= _4g); virBufferAsprintf(buf, " unit=3D'KiB'>%llu\n", virDomainDefGetMemoryTotal(def)); =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 4838687edf..a939d43e93 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2597,6 +2597,9 @@ struct _virDomainMemtune { unsigned long long max_memory; /* in kibibytes */ unsigned int memory_slots; /* maximum count of RAM memory slots */ =20 + /* maximum memory below the 4GiB boundary (32bit boundary) */ + unsigned long long max_ram_below_4g; /* in kibibytes */ + bool nosharepages; bool locked; int dump_core; /* enum virTristateSwitch */ diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index be93182092..c69ad781e6 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6961,6 +6961,10 @@ qemuBuildMachineCommandLine(virCommand *cmd, cfg->dumpGuestCore ? "on" : "off"); } =20 + if (def->mem.max_ram_below_4g > 0) + virBufferAsprintf(&buf, ",max-ram-below-4g=3D%llu", + def->mem.max_ram_below_4g * 1024); + if (def->mem.nosharepages) virBufferAddLit(&buf, ",mem-merge=3Doff"); =20 --=20 2.24.3 (Apple Git-128)