From nobody Sat Feb 7 09:30:16 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1704369336457954.4981916850669; Thu, 4 Jan 2024 03:55:36 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 5B43B176B; Thu, 4 Jan 2024 06:55:35 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 78FA71815; Thu, 4 Jan 2024 06:52:43 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 440FA176B; Thu, 4 Jan 2024 06:52:33 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 24FB61768 for ; Thu, 4 Jan 2024 06:52:32 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-75-G7Flt3gKPgGNTuU3nwVS7g-1; Thu, 04 Jan 2024 06:52:30 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EE578185A780 for ; Thu, 4 Jan 2024 11:52:29 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.226.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 994632166B31 for ; Thu, 4 Jan 2024 11:52:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: G7Flt3gKPgGNTuU3nwVS7g-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 1/4] conf: Introduce dynamicMemslots attribute for virtio-mem Date: Thu, 4 Jan 2024 12:52:23 +0100 Message-ID: <38e5697fedf49079a99320bcd8fb2e5d18262ec6.1704369029.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: GJFOCLWIJS64UQSDYSOCJDCWUPSOTECQ X-Message-ID-Hash: GJFOCLWIJS64UQSDYSOCJDCWUPSOTECQ X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1704369338272100001 Introduced in v8.2.0-rc0~74^2~2, QEMU now allows setting .dynamic-memslots attribute for virtio-mem-pci devices. When turned on, it allows memory exposed to guest to be split into multiple memslots and thus smaller memory footprint (see the original commit for detailed explanation). Therefore, introduce new attribute which will control that QEMU knob. Signed-off-by: Michal Privoznik --- docs/formatdomain.rst | 6 ++++++ src/conf/domain_conf.c | 18 +++++++++++++++++- src/conf/domain_conf.h | 1 + src/conf/schemas/domaincommon.rng | 5 +++++ .../memory-hotplug-virtio-mem.xml | 2 +- 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 96e03a3807..57974de9f4 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -8395,6 +8395,12 @@ Example: usage of the memory devices The ``node`` subelement configures the guest NUMA node to attach the me= mory to. The element shall be used only if the guest has NUMA nodes configur= ed. =20 + For ``virtio-mem`` optional attribute ``dynamicMemslots`` can be specif= ied + (accepted values "yes"/"no") which allows hypervisor to spread memory i= nto + multiple memory slots (allocate them dynamically based on the amount of + memory exposed to the guest), resulting in smaller memory footprint. + :since:`Since 10.0.0 and QEMU 8.2.0` + The following optional elements may be used: =20 ``label`` diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 82672b30a0..c53e72210c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13499,6 +13499,10 @@ virDomainMemoryTargetDefParseXML(xmlNodePtr node, &def->target.virtio_mem.requestedsize, fa= lse, false) < 0) return -1; =20 + if (virXMLPropTristateBool(node, "dynamicMemslots", VIR_XML_PROP_N= ONE, + &def->target.virtio_mem.dynamicMemslots= ) < 0) + return -1; + addrNode =3D virXPathNode("./address", ctxt); addr =3D &def->target.virtio_mem.address; break; @@ -21174,6 +21178,12 @@ virDomainMemoryDefCheckABIStability(virDomainMemor= yDef *src, src->target.virtio_mem.address); return false; } + + if (src->target.virtio_mem.dynamicMemslots !=3D dst->target.virtio= _mem.dynamicMemslots) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Target memory device 'dynamicMemslots' prope= rty doesn't match source memory device")); + return false; + } break; =20 case VIR_DOMAIN_MEMORY_MODEL_DIMM: @@ -25375,6 +25385,7 @@ virDomainMemoryTargetDefFormat(virBuffer *buf, unsigned int flags) { g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); + g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; =20 virBufferAsprintf(&childBuf, "%llu\n", def->= size); if (def->targetNode >=3D 0) @@ -25414,6 +25425,11 @@ virDomainMemoryTargetDefFormat(virBuffer *buf, if (def->target.virtio_mem.address) virBufferAsprintf(&childBuf, "
\n", def->target.virtio_mem.address); + + if (def->target.virtio_mem.dynamicMemslots) { + virBufferAsprintf(&attrBuf, " dynamicMemslots=3D'%s'", + virTristateBoolTypeToString(def->target.virt= io_mem.dynamicMemslots)); + } break; =20 case VIR_DOMAIN_MEMORY_MODEL_SGX_EPC: @@ -25423,7 +25439,7 @@ virDomainMemoryTargetDefFormat(virBuffer *buf, break; } =20 - virXMLFormatElement(buf, "target", NULL, &childBuf); + virXMLFormatElement(buf, "target", &attrBuf, &childBuf); } =20 static int diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 14901b37ba..6e45b7fb6e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2674,6 +2674,7 @@ struct _virDomainMemoryDef { unsigned long long currentsize; /* kibibytes, valid for an act= ive domain only and parsed */ unsigned long long address; /* address where memory is mapped = */ + virTristateBool dynamicMemslots; } virtio_mem; struct { } sgx_epc; diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index f318c06797..08c408e138 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -7260,6 +7260,11 @@ =20 + + + + + diff --git a/tests/qemuxml2argvdata/memory-hotplug-virtio-mem.xml b/tests/q= emuxml2argvdata/memory-hotplug-virtio-mem.xml index c578209d8a..359ece7a77 100644 --- a/tests/qemuxml2argvdata/memory-hotplug-virtio-mem.xml +++ b/tests/qemuxml2argvdata/memory-hotplug-virtio-mem.xml @@ -60,7 +60,7 @@ 1-3 2048 - + 2097152 0 2048 --=20 2.41.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org