From nobody Tue May 14 00:12:51 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=1620631859; cv=none; d=zohomail.com; s=zohoarc; b=kLTJ/Ngnzeos/n+F8Xh9gPYdr7zuIQKrT5aVqVNwwRQMteDpLTqa2psHmyhoubg0a0/xPTXd+l5j/NIAu+zQJG+osaZh3bzOVmikiBjZ8hy2qKavmCSD0bKsytQeb2mUrNHjndiO66SzlAX56nK1hjaMHClnZyi0pTZ1hTdpGtg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620631859; 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=UEBIEEhZMPSmMEj3VJXNVzH8v88GvJdpUAuV+EdDtec=; b=FaJsmDgZWiFLpp7ucLLjmizSfvPHeK+viNoUY8nv2ePBZuPlDzvnelTnFOYK9tdslAC6bHqGLMI2TfRQYzNi7Iv8Ma0mglk3QVNstwKmQxO1KDsbTUIN/jqRfbOly5JVrmW4O2ePtZnQ4q6N92xgZE/XU+gxMhvk3SXry3prbxk= 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 1620631859367451.58755407604804; Mon, 10 May 2021 00:30:59 -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-582-4KlX_BpDOP-xY5Pt-6myjQ-1; Mon, 10 May 2021 03:30:53 -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 B0638803621; Mon, 10 May 2021 07:30:48 +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 3265B5F9B0; Mon, 10 May 2021 07:30:48 +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 C814944A63; Mon, 10 May 2021 07:30:47 +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 14A7UjHv010122 for ; Mon, 10 May 2021 03:30:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id C3B6C2155C44; Mon, 10 May 2021 07:30:45 +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 BFA722155C47 for ; Mon, 10 May 2021 07:30:40 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.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 DFFDF1857F2A for ; Mon, 10 May 2021 07:30:39 +0000 (UTC) Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-443-YYSKlIPFNy-WbSIhiTQDCg-1; Mon, 10 May 2021 03:30:37 -0400 Received: by mail-pg1-f174.google.com with SMTP id y32so12646989pga.11 for ; Mon, 10 May 2021 00:30:37 -0700 (PDT) Received: from C02D383UML85.bytedance.net ([139.177.225.251]) by smtp.gmail.com with ESMTPSA id j16sm11017059pgh.69.2021.05.10.00.30.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 May 2021 00:30:35 -0700 (PDT) X-MC-Unique: 4KlX_BpDOP-xY5Pt-6myjQ-1 X-MC-Unique: YYSKlIPFNy-WbSIhiTQDCg-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=UEBIEEhZMPSmMEj3VJXNVzH8v88GvJdpUAuV+EdDtec=; b=ChLmU3FDr7fPlkYeXFHo1cEZYnXL6YMMg7VHiJpujHhSuo6DrVWJ5k7TXJTuKjikVV Mk4t8Iilmx+K6GKCTCeZtZoBiB7F0WwSq4+ItkLC9JSWYLziZ5rt22mV1kPFWIZ2CIoZ Hyi/cm1JzRObfD8eDJuxLpxYPQ3lYWhiLYXd2EyLuTW8U472N3tsASfyxoZKcwRZ35/L A8MJtJqkIA8oopGmeBgaOOH++s0CQsXYdkdhogZVFepLHLZ8NdGjz9v0m1XNf7kGwYgP 70Jjd105p5qtC8lXEpWxeLHIl6DtMczIVlU3krjMxcCeEMypqlrKyHZD2aaaADzuUF/w MvFg== X-Gm-Message-State: AOAM531wYMECpASwHbSrZ09YLAZn1YPuFTOmk7QLT7RjjH90LDfKFW9J sU8i9pex9nQH6dEXcOkGh+FO/CjNPy+MjxQH X-Google-Smtp-Source: ABdhPJxbVx4eM/HpFNQQFUe5eMcrNqpUgoaD9W5yYhAHCMzmZzh0pmoo73Dz9TLbtiBM1mCx9I4vCQ== X-Received: by 2002:a63:1352:: with SMTP id 18mr23268503pgt.11.1620631836095; Mon, 10 May 2021 00:30:36 -0700 (PDT) From: Zhiyong Ye To: libvir-list@redhat.com Subject: [PATCH v3 1/1] qemu: add support for max-ram-below-4g option Date: Mon, 10 May 2021 15:30:13 +0800 Message-Id: <20210510073014.35578-2-yezhiyong@bytedance.com> In-Reply-To: <20210510073014.35578-1-yezhiyong@bytedance.com> References: <20210510073014.35578-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: pkrempa@redhat.com, zhenwei pi , jinqi@redhat.com, Zhiyong Ye , zhangruien 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 | 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 e8632e4d73..c586d633d1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -18922,6 +18922,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")); @@ -21928,6 +21932,15 @@ virDomainMemtuneCheckABIStability(const virDomainD= 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 @@ -27980,6 +27993,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 2d5462bb55..12de9ec235 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2598,6 +2598,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 d6c5308ef0..3ab4ceefd5 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..141e001802 --- /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=3D0x2 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..716071f3d3 --- /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 + + + + +
+ + +
+ + +
+ + + + +