From nobody Wed May 14 07:01:45 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526914864389391.23205926453477; Mon, 21 May 2018 08:01:04 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2D139C1217E2; Mon, 21 May 2018 15:01: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 3FADF977D5; Mon, 21 May 2018 15:01: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 A91A34CAA7; Mon, 21 May 2018 15:01: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 w4LF0vkI018116 for ; Mon, 21 May 2018 11:00:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9BBDA215CDA7; Mon, 21 May 2018 15:00:57 +0000 (UTC) Received: from caroline (unknown [10.43.2.67]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5DD5B215CDAA for ; Mon, 21 May 2018 15:00:57 +0000 (UTC) Received: from caroline.brq.redhat.com (caroline.usersys.redhat.com [127.0.0.1]) by caroline (Postfix) with ESMTP id 667AF120022 for ; Mon, 21 May 2018 17:00:56 +0200 (CEST) From: Martin Kletzander To: libvir-list@redhat.com Date: Mon, 21 May 2018 17:00:51 +0200 Message-Id: <30454d50d4748d2430f0fc14db9acedb8258030c.1526913931.git.mkletzan@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/5] conf, schema, docs: Add support for TSEG size setting 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 21 May 2018 15:01:03 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" TSEG (Top of Memory Segment) is one of many regions that SMM (System Manage= ment Mode) can occupy. This one, however is special, because a) most of the SMM= code lives in TSEG nowadays and b) QEMU just (well, some time ago) added support= for so called 'extended' TSEG. The difference to the TSEG implemented in real = q35's MCH (Memory Controller Hub) is that it can have any size from 1 MiB up to 6= 5534 MiB in 1 MiB increments. But more about that in the QEMU patch. Signed-off-by: Martin Kletzander Reviewed-by: John Ferlan --- docs/formatdomain.html.in | 39 +++++++++++++++++++ docs/schemas/domaincommon.rng | 5 +++ src/conf/domain_conf.c | 60 ++++++++++++++++++++++++++++- src/conf/domain_conf.h | 1 + tests/genericxml2xmlindata/tseg.xml | 23 +++++++++++ tests/genericxml2xmltest.c | 2 + 6 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 tests/genericxml2xmlindata/tseg.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 403b638bd4bd..39ebfe398bd7 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1897,6 +1897,9 @@ <ioapic driver=3D'qemu'/> <hpt resizing=3D'required'/> <vmcoreinfo state=3D'on'/> + <smm state=3D'on'> + <tseg unit=3D'MiB'>48</tseg> + </smm> </features> ... =20 @@ -2056,6 +2059,42 @@ off, default on) enable or disable System Management Mode. Since 2.1.0 + + Optional sub-element tseg can be used to specify the + amount of memory dedicated to SMM TSEG. The size can be specifie= d as a + value of that element, optional attribute unit can = be + used to specify the unit of the aforementioned value (defaults to + 'MiB'). + + This value is configurable due to the fact that the calculation = cannot + be done right with the guarantee that it will work correctly. F= or + QEMU TSEG was disabled up to and including pc-q35-2.9 (it + does not make sense fo any other machine type than q35). + From pc-q35-2.10 the default value was changed to 1= 6 MiB. + That should suffice for up to 272 VCPUs, 5 GiB guest RAM in tota= l, no + hotplug memory range, and 32 GiB of 64-bit PCI MMIO aperture. O= r for + 48 VCPUs, with 1TB of guest RAM, no hotplug DIMM range, and 32GB= of + 64-bit PCI MMIO aperture. The values may also vary based on the = loader + the VM is using. + + Additional size might be needed for significantly higher VCPU co= unts + or increased address space (that can be memory, maxMemory, 64-bi= t PCI + MMIO aperture size; roughly 8 MiB of TSEG per 1 TiB of address s= pace) + which can also be rounded up. + + Due to the nature of this setting being similar to "how much RAM + should the guest have" users are advised to either consult the + documentation of the guest OS or loader (if there is any), or te= st + this by trial-and-error changing the value until the VM boots + successfully. Yet another guiding value for users might be the = fact + that 48 MiB should be enough for pretty large guests (240 VCPUs = and + 4TB guest RAM), but it is on purpose not set as default as 48 Mi= B of + unavailable RAM might be too much for small guests (e.g. with 51= 2 MiB + of RAM). + + See Memory Allocation + for more details about the unit attribute. + Since 4.5.0 (QEMU only)
ioapic
Tune the I/O APIC. Possible values for the diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 71ac3d079c32..664ec79933f0 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4785,6 +4785,11 @@ + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3689ac0a82ce..6a4f8243183d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -19647,6 +19647,16 @@ virDomainDefParseXML(xmlDocPtr xml, VIR_FREE(nodes); } =20 + if (def->features[VIR_DOMAIN_FEATURE_SMM] =3D=3D VIR_TRISTATE_SWITCH_O= N && + virDomainParseScaledValue("string(./features/smm/tseg)", + "string(./features/smm/tseg/@unit)", + ctxt, + &def->tseg_size, + 1024 * 1024, /* Defaults to mebibytes */ + ULLONG_MAX, + false) < 0) + goto error; + if ((n =3D virXPathNodeSet("./features/capabilities/*", ctxt, &nodes))= < 0) goto error; =20 @@ -21741,6 +21751,23 @@ virDomainDefFeaturesCheckABIStability(virDomainDef= Ptr src, } } =20 + /* smm */ + if (src->features[VIR_DOMAIN_FEATURE_SMM] =3D=3D VIR_TRISTATE_SWITCH_O= N && + src->tseg_size !=3D dst->tseg_size) { + const char *unit_src, *unit_dst; + unsigned long long short_size_src =3D virFormatIntPretty(src->tseg= _size, + &unit_src); + unsigned long long short_size_dst =3D virFormatIntPretty(dst->tseg= _size, + &unit_dst); + + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Size of SMM TSEG size differs: " + "source: '%llu %s', destination: '%llu %s'"), + short_size_src, unit_src, + short_size_dst, unit_dst); + return false; + } + return true; } =20 @@ -27059,7 +27086,6 @@ virDomainDefFormatInternal(virDomainDefPtr def, case VIR_DOMAIN_FEATURE_PMU: case VIR_DOMAIN_FEATURE_PVSPINLOCK: case VIR_DOMAIN_FEATURE_VMPORT: - case VIR_DOMAIN_FEATURE_SMM: switch ((virTristateSwitch) def->features[i]) { case VIR_TRISTATE_SWITCH_LAST: case VIR_TRISTATE_SWITCH_ABSENT: @@ -27076,6 +27102,38 @@ virDomainDefFormatInternal(virDomainDefPtr def, =20 break; =20 + case VIR_DOMAIN_FEATURE_SMM: + switch ((virTristateSwitch) def->features[i]) { + case VIR_TRISTATE_SWITCH_LAST: + case VIR_TRISTATE_SWITCH_ABSENT: + break; + + case VIR_TRISTATE_SWITCH_ON: + virBufferAddLit(buf, "tseg_size) { + virBufferAddLit(buf, "/>\n"); + } else { + const char *unit; + unsigned long long short_size =3D virFormatIntPret= ty(def->tseg_size, + = &unit); + + virBufferAddLit(buf, ">\n"); + virBufferAdjustIndent(buf, 2); + virBufferAsprintf(buf, "%llu\n", + unit, short_size); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } + + break; + + case VIR_TRISTATE_SWITCH_OFF: + virBufferAddLit(buf, "\n"); + break; + } + + break; + case VIR_DOMAIN_FEATURE_APIC: if (def->features[i] =3D=3D VIR_TRISTATE_SWITCH_ON) { virBufferAddLit(buf, " + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + + 48 + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c index d8270a6cae82..daad6e0f78d8 100644 --- a/tests/genericxml2xmltest.c +++ b/tests/genericxml2xmltest.c @@ -141,6 +141,8 @@ mymain(void) DO_TEST_FULL("cachetune-colliding-types", false, true, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); =20 + DO_TEST("tseg"); + virObjectUnref(caps); virObjectUnref(xmlopt); =20 --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list