From nobody Fri May 17 14:56:35 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=1620289751; cv=none; d=zohomail.com; s=zohoarc; b=KI65koX2f8v7n+cBZQ/+18gxwOz4fopVsxeKCscbCR79G23Rfuy/lStIpz1cV82SFpaMAnRn1C8aZVGQVf/coYD8WeOpFTJri6UbPUUCHepm80nvVs0XnyLLmyjP7JzkaxKgMlSk3ZKflUBGzEZjURPmyBL5iOjdZVXE38XO08E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620289751; 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=ZvoKW8afmHc4wdMAZgyDWNzDHJ0ibE9mIQm0Vl5DY20=; b=lCcQJfsxS+egocWjnJnMBdBEFb00lqI+7EhtvCC+mXbybg79VR7nwVjMNL00i7QoW07DdmNLTiREdMFI4fNHN61wuadbDHvIdPt8eUD145HD7+JRQLPOo5QAAiLbwNX8o6OdsY8mh8rBAlfwAXK+IbxRsO5zKv6I0URLLqXXRsQ= 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 1620289751165746.2827406307674; Thu, 6 May 2021 01:29:11 -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-268-3N9RZLoQPgq66AeuVFFO4A-1; Thu, 06 May 2021 04:29:06 -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 3844A107ACE6; Thu, 6 May 2021 08:29:02 +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 B68D670580; Thu, 6 May 2021 08:29:01 +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 61AC355351; Thu, 6 May 2021 08:29:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1468Sw6C018972 for ; Thu, 6 May 2021 04:28:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 23FA720D7E1C; Thu, 6 May 2021 08:28:58 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1F3362039D4D for ; Thu, 6 May 2021 08:28:55 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (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 135808007AC for ; Thu, 6 May 2021 08:28:55 +0000 (UTC) Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-311-PdNGLDQRNXiim4rDVyHedw-1; Thu, 06 May 2021 04:28:53 -0400 Received: by mail-pl1-f178.google.com with SMTP id a11so3014498plh.3 for ; Thu, 06 May 2021 01:28:53 -0700 (PDT) Received: from C02D383UML85.bytedance.net ([139.177.225.235]) by smtp.gmail.com with ESMTPSA id d16sm1387572pgk.34.2021.05.06.01.28.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 May 2021 01:28:51 -0700 (PDT) X-MC-Unique: 3N9RZLoQPgq66AeuVFFO4A-1 X-MC-Unique: PdNGLDQRNXiim4rDVyHedw-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=ZvoKW8afmHc4wdMAZgyDWNzDHJ0ibE9mIQm0Vl5DY20=; b=P02SrTMIgLqVZaCe6UypEEVNf9JM0Rkd84p4l68JTuVUSnUTF5nYbBnLKvao/6sr6s 4gOnP+rtpDZuG8bg6B1m90mWH21CTZoenk8ZxY4Ux/eK5Rf0baE8UEZjcL9NwyBk+15F XstByP32hPRWzltURyCHCp2EUbVRMoeVsgRtCdsxu72Gep/GMkLiMdj10Y+A38hbphmW DZJEV+jOlG1IRE2UeFvcfdGi45w1elTnL4avJXc0PKAlxKVvhK4OV+0B+NJZ0PwJtWsv SUG5z7LazmYMSsmqG9YxPFN270qmTQNaHjmry5CAp3UpgABDSLpwH6lGx1QqimgtOUfo kLGQ== X-Gm-Message-State: AOAM531JtQ94QQ3kNAdF232UjwCWEGq/JSROX5FWwCn2/XHQlQLI7Hzz L2P13QrYNKzseuypq0zUtjEIXQ8HZcOscqT1 X-Google-Smtp-Source: ABdhPJzNGhzbDhoAYrDE7x0kPMUxXXemxSrtRa42tBgKijJRKr8VpxBuvA5D5Jzxm5d2Gurze+tDQw== X-Received: by 2002:a17:90a:fb98:: with SMTP id cp24mr3313100pjb.24.1620289731693; Thu, 06 May 2021 01:28:51 -0700 (PDT) From: Zhiyong Ye To: libvir-list@redhat.com Subject: [PATCH v2 1/1] qemu: add support for max-ram-below-4g option Date: Thu, 6 May 2021 16:28:21 +0800 Message-Id: <20210506082822.77288-2-yezhiyong@bytedance.com> In-Reply-To: <20210506082822.77288-1-yezhiyong@bytedance.com> References: <20210506082822.77288-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.4 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" 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 | 15 ++++++++++++ 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, 142 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 fa5c14febc..a71a716f5b 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 77105e6a07..8573967c4b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -19239,6 +19239,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")); @@ -22374,6 +22378,15 @@ virDomainIOMMUDefCheckABIStability(virDomainIOMMUD= ef *src, return false; } =20 + if (src->mem.max_ram_below_4g !=3D dst->mem.max_ram_below_4g) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain maximum memory below the 4GiB boun= dary " + "'%llu' doesn't match source '%llu'"), + dst->mem.max_ram_below_4g, + src->mem.max_ram_below_4g); + return false; + } + return true; } =20 @@ -28297,6 +28310,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 95d0516279..d0418eb9ed 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 ca2265cc90..97c65a6bf1 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6849,6 +6849,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 a9dafe226e..131ebde9e4 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 + + + + +
+ + +
+ + +
+ + + + +