From nobody Thu Mar 28 12:02:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1619686929; cv=none; d=zohomail.com; s=zohoarc; b=ejv2Sy5+FomMGUN6GXfXBoHXPJNlviG+cA0VizrFtmad5KxTBGFBL2F0Uq1EJzO6zOQfsg0L3B4D5L+HlAO0Zv71B5vPGc2mKnPZCh+fH96AsJHzPqIy4GI0/CwHn11ElTBkR+w+xIa4W8VWgZ+fgEcc6oX7b8hY9VWz2J4R6FM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619686929; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=J1wgs5rfhNB/KoMddGZouXipXiEaE3LL71Ha7HxoBMo=; b=cuWIyF00ShzbxfECKUoM9HpmUQGPJdoCKqHvL02XUF4FxL0S7D1BlZlkLqxH4qC+xUwUeGXR1FfKHMPs+ouxWrwja5XE2LxY4qnLcrf9P0h8KddW7+ZqGeBrlyq/78sxeruhY1ukHLTOOMBGrUj8ZFUbR+gEBpHJOlzvy0DwF08= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1619686929958916.8521358302324; Thu, 29 Apr 2021 02:02:09 -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-464-ZZjbYYFSPuaEMo7Q0EG0LA-1; Thu, 29 Apr 2021 05:02:05 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C72CE501E0; Thu, 29 Apr 2021 09:02:00 +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 A02EE5C1A3; Thu, 29 Apr 2021 09:02:00 +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 664CC44A5C; Thu, 29 Apr 2021 09:02:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13T90EUi002637 for ; Thu, 29 Apr 2021 05:00:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4150E20BDB36; Thu, 29 Apr 2021 09:00:14 +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 3C7A320BDB3B for ; Thu, 29 Apr 2021 09:00:14 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (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 21199185A7B8 for ; Thu, 29 Apr 2021 09:00:14 +0000 (UTC) Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-176-CMHyIopxMXCvpEXr0s35Hg-1; Thu, 29 Apr 2021 05:00:10 -0400 Received: by mail-pg1-f169.google.com with SMTP id q10so46661817pgj.2 for ; Thu, 29 Apr 2021 02:00:10 -0700 (PDT) Received: from C02D383UML85.bytedance.net ([139.177.225.251]) by smtp.gmail.com with ESMTPSA id b140sm1896684pfb.98.2021.04.29.02.00.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Apr 2021 02:00:08 -0700 (PDT) X-MC-Unique: ZZjbYYFSPuaEMo7Q0EG0LA-1 X-MC-Unique: CMHyIopxMXCvpEXr0s35Hg-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:in-reply-to :references:mime-version:content-transfer-encoding; bh=J1wgs5rfhNB/KoMddGZouXipXiEaE3LL71Ha7HxoBMo=; b=Lohodsv9fkUKdi+GHF/L4YiwvoOiz8JvoXtqNBz1Ii9NeApRiWxUg4VxDZdHgjLat8 YPQkx/00BsJquIEz2mjWvocmkU3O4dLs1JU2ukGCC3sPBkXbAiANc3oGSa2NeJxhXynG 7U/Dcx9VZKVRityd/1uD+KIGtQhpCpqJukW/Fs4gV4Fo7KbIdMAIyCdGUvhVZmzkDYPO zgdfvR8i4RRTkxocqKztcSLqmsCB09+Rz+f/1curCovylsxoyeOnYE5E2+OT7Lyxz5en 18GLaeCDgumlTDSXfx8YkjCmuXDnGWHn1F86+GXcwCfnHkDUA4+duB0CDCP6G5vbJh2Y n4kg== X-Gm-Message-State: AOAM5308jECFRIJ956tTbhJHbnTLexiFBN9dIH3Juh7NP088ystZrc3c lj/aaYQ8L06PaX0e+Ag/YE2kXp7sC4o1KXMX X-Google-Smtp-Source: ABdhPJxDTBSjiWDe2CwBh0kBJWI7h8iHMwGUOZDnFqYlHHs0xYuupd2K+z9PGwBwvcbw/ZRb/4ni8g== X-Received: by 2002:a63:31cb:: with SMTP id x194mr7603789pgx.290.1619686809219; Thu, 29 Apr 2021 02:00:09 -0700 (PDT) From: Zhiyong Ye To: libvir-list@redhat.com Subject: [PATCHv2] qemu: add support for max-ram-below-4g option Date: Thu, 29 Apr 2021 16:59:52 +0800 Message-Id: <20210429085952.20096-3-yezhiyong@bytedance.com> In-Reply-To: <20210429085952.20096-1-yezhiyong@bytedance.com> References: <20210429085952.20096-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.6 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.16 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" The 'below4g' attribute added in 'memory' element can be used to specify the low memory area, which allows to get a larger PCI I/O window below 4G when reduce it to a smaller value, and when raise value allows legacy non-PAE guests to have as much memory as possible in the 32bit address space below 4G. It does not share the ``unit`` parameter with the actual memory size and its unit defaults to "KiB". Signed-off-by: Zhiyong Ye Signed-off-by: zhenwei pi Signed-off-by: zhangruien --- docs/formatdomain.rst | 10 ++++-- docs/schemas/domaincommon.rng | 5 +++ src/conf/domain_conf.c | 6 ++++ src/conf/domain_conf.h | 3 ++ src/conf/domain_validate.c | 13 ++++++++ src/qemu/qemu_command.c | 4 +++ tests/qemuxml2argvdata/memory-below4g.args | 29 ++++++++++++++++ tests/qemuxml2argvdata/memory-below4g.xml | 26 +++++++++++++++ tests/qemuxml2argvtest.c | 1 + tests/qemuxml2xmloutdata/memory-below4g.xml | 37 +++++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 11 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/memory-below4g.args create mode 100644 tests/qemuxml2argvdata/memory-below4g.xml create mode 100644 tests/qemuxml2xmloutdata/memory-below4g.xml diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 1b9b221611..fd074a224e 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -940,8 +940,14 @@ Memory Allocation `NUMA <#elementsCPU>`__ is configured for the guest the ``memory`` elem= ent can be omitted. In the case of crash, optional attribute ``dumpCore`` c= an be used to control whether the guest memory should be included in the gene= rated - coredump or not (values "on", "off"). ``unit`` :since:`since 0.9.11` , - ``dumpCore`` :since:`since 0.10.2 (QEMU only)` + coredump or not (values "on", "off"). Besides, the optional ``below4g`` + attribute can be used to specify the low memory area, which allows to g= et a + larger PCI I/O window below 4G when reduce it to a smaller value, and w= hen + raise value allows legacy non-PAE guests to have as much memory as poss= ible + in the 32bit address space below 4G. It does not share the ``unit`` par= ameter + with the actual memory size and its unit defaults to "KiB". ``unit`` : + since:`since 0.9.11` , ``dumpCore`` : since:`since 0.10.2 (QEMU only)`, + ``below4g`` :since:`since 7.3.0 (QEMU only)`. ``maxMemory`` The run time maximum memory allocation of the guest. The initial memory specified by either the ```` element or the NUMA cell size diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index a2e5c50c1d..8f2ac1ad33 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -643,6 +643,11 @@ + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a72d58f488..272fcd894e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -19786,6 +19786,10 @@ virDomainDefParseMemory(virDomainDef *def, &def->mem.max_memory, false, false) < 0) goto error; =20 + if (virDomainParseMemory("./memory[1]/@below4g", NULL, 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 +28848,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/conf/domain_validate.c b/src/conf/domain_validate.c index 686b9e8d16..afa9e2e821 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -1384,6 +1384,19 @@ virDomainDefMemtuneValidate(const virDomainDef *def) } } =20 + if (mem->max_ram_below_4g && + mem->max_ram_below_4g < 1024) { + virReportError(VIR_ERR_XML_DETAIL, "%s", + _("maximum memory size below the 4GiB boundary must= be " + "greater than or equal to 1MiB")); + return -1; + } else if (mem->max_ram_below_4g > 4 * 1024 * 1024) { + virReportError(VIR_ERR_XML_DETAIL, "%s", + _("maximum memory size below the 4GiB boundary must= be " + "less than or equal to 4GiB")); + return -1; + } + return 0; } =20 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 diff --git a/tests/qemuxml2argvdata/memory-below4g.args b/tests/qemuxml2arg= vdata/memory-below4g.args new file mode 100644 index 0000000000..f55386a2a2 --- /dev/null +++ b/tests/qemuxml2argvdata/memory-below4g.args @@ -0,0 +1,29 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-QEMUGuest1 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-i386 \ +-name QEMUGuest1 \ +-S \ +-machine pc,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff,max-ram-below-4g= =3D112197632 \ +-m 214 \ +-realtime mlock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-QEMUGuest1/moni= tor.sock,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-usb \ +-drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ +-device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 diff --git a/tests/qemuxml2argvdata/memory-below4g.xml b/tests/qemuxml2argv= data/memory-below4g.xml new file mode 100644 index 0000000000..a843ef72a2 --- /dev/null +++ b/tests/qemuxml2argvdata/memory-below4g.xml @@ -0,0 +1,26 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 214 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i386 + + + +
+ + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index f0efe98d7e..d26455d36c 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1055,6 +1055,7 @@ mymain(void) driver.config->dumpGuestCore =3D true; DO_TEST("machine-core-off", NONE); driver.config->dumpGuestCore =3D false; + DO_TEST("memory-below4g", NONE); DO_TEST("machine-smm-opt", QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_DEVICE_PCI_BRIDGE, diff --git a/tests/qemuxml2xmloutdata/memory-below4g.xml b/tests/qemuxml2xm= loutdata/memory-below4g.xml new file mode 100644 index 0000000000..44f58fc93b --- /dev/null +++ b/tests/qemuxml2xmloutdata/memory-below4g.xml @@ -0,0 +1,37 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i386 + + + + +
+ + +
+ + +
+ + + + +