From nobody Mon Feb 9 03:58:25 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1687438795; cv=none; d=zohomail.com; s=zohoarc; b=MgVXz7YWJmwhp7K6dnS+hU/qG6+68GeFrdn2g1DVBaSpor8C6755dAh/y57iP4mYS2yEqKNyMXw23hdkeELXWM/t5V+rU9ezEqLCHyDaacZs3Z39zab7/RhG3Pc/P7WV5QWN2qCNfTx9XghE0Rh3SmfJrtdoZ31tspt9Bl+4Q2A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687438795; h=Content-Type:Content-Transfer-Encoding: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=vNxaZqiJvfYQy+XE0oKNc+QSrB6wRecvav7opcp5oAc=; b=IiiY3gun42B8u0v8Hudw8Ky514ChCFzhyU3iSEB6vh0EXFn93S19bojgJ8ZTFGYvh/KK9kj2XGK35NamFFhbAfXmviI4faxXUrOZifGj+RNguKmkjfX8hN+QT/6FP5MojewsFXDDmdo/MuAbgHQNU9TQwu4OuJPxAeA43qRtqCI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1687438795806284.05354149338484; Thu, 22 Jun 2023 05:59:55 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-333-wSW8DdphPMaMq4lfEWhh1Q-1; Thu, 22 Jun 2023 08:59:51 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A3D141064AF8; Thu, 22 Jun 2023 12:59:47 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id E464E40C2063; Thu, 22 Jun 2023 12:59:46 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 32B031946588; Thu, 22 Jun 2023 12:59:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 37F371946587 for ; Thu, 22 Jun 2023 12:58:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 15196C478C6; Thu, 22 Jun 2023 12:58:30 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F9CEC1ED97 for ; Thu, 22 Jun 2023 12:58:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687438794; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=vNxaZqiJvfYQy+XE0oKNc+QSrB6wRecvav7opcp5oAc=; b=dzEBu7EhnMzNsLpVUyzdrqXkgHf7aL0TzMtzrcbK0/kPSH6LGGv0at09F1wSseOM7J8IBY xAX1YaIXQuE5BN5m0QIM9v4msdwTO8Y3VfS24wGy3GKjtxLMkSEYUSlL+5zUex0ELBOprH bzWhPIv5JkJbd+oGk2PLuFqdsk01wgc= X-MC-Unique: wSW8DdphPMaMq4lfEWhh1Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/4] conf: Allow omitting 'slots' attribute of Date: Thu, 22 Jun 2023 14:58:20 +0200 Message-Id: <9c783b29603f4b04fc3a461774ce2b0562c46a13.1687436914.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1687438797380100001 Content-Type: text/plain; charset="utf-8" Memory slots are required only for DIMM-like devices, but the maximum memory address space is relevant also for other non-DIMM memory devices such as virtio-mem. Allow configurations where no slots are added. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 13 ++++++++++--- src/conf/domain_postparse.c | 5 ++--- src/conf/schemas/domaincommon.rng | 8 +++++--- .../memory-hotplug-virtio-mem.x86_64-latest.args | 2 +- .../qemuxml2argvdata/memory-hotplug-virtio-mem.xml | 2 +- .../memory-hotplug-virtio-pmem.x86_64-5.2.0.args | 2 +- .../memory-hotplug-virtio-pmem.x86_64-latest.args | 2 +- .../qemuxml2argvdata/memory-hotplug-virtio-pmem.xml | 2 +- 8 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0edb1bda9d..1fde53ff4c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -27416,9 +27416,16 @@ virDomainDefFormatInternalSetRootName(virDomainDef= *def, return -1; if (virDomainDefHasMemoryHotplug(def)) { - virBufferAsprintf(buf, - "%llu\n", - def->mem.memory_slots, def->mem.max_memory); + g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) contentBuf =3D VIR_BUFFER_INITIALIZER; + + if (def->mem.memory_slots > 0) + virBufferAsprintf(&attrBuf, " slots=3D'%u'", def->mem.memory_s= lots); + + virBufferAddLit(&attrBuf, " unit=3D'KiB'"); + virBufferAsprintf(&contentBuf, "%llu", def->mem.max_memory); + + virXMLFormatElementInternal(buf, "maxMemory", &attrBuf, &contentBu= f, false, false); } virBufferAddLit(buf, "mem.cur_balloon =3D=3D 0) def->mem.cur_balloon =3D virDomainDefGetMemoryTotal(def); - if ((def->mem.max_memory || def->mem.memory_slots) && - !(def->mem.max_memory && def->mem.memory_slots)) { + if (def->mem.max_memory =3D=3D 0 && def->mem.memory_slots > 0) { virReportError(VIR_ERR_XML_ERROR, "%s", - _("both maximum memory size and memory slot count m= ust be specified")); + _("maximum memory size must be specified when speci= fying number of memory slots")); return -1; } diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index c1725bb511..4b595fd066 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -721,9 +721,11 @@ - - - + + + + + diff --git a/tests/qemuxml2argvdata/memory-hotplug-virtio-mem.x86_64-latest= .args b/tests/qemuxml2argvdata/memory-hotplug-virtio-mem.x86_64-latest.args index 7309fea2ff..607ce9b0e8 100644 --- a/tests/qemuxml2argvdata/memory-hotplug-virtio-mem.x86_64-latest.args +++ b/tests/qemuxml2argvdata/memory-hotplug-virtio-mem.x86_64-latest.args @@ -13,7 +13,7 @@ XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGue= st1/.config \ -machine pc,usb=3Doff,dump-guest-core=3Doff,acpi=3Doff \ -accel kvm \ -cpu qemu64 \ --m size=3D2095104k,slots=3D1,maxmem=3D1099511627776k \ +-m size=3D2095104k,maxmem=3D1099511627776k \ -overcommit mem-lock=3Doff \ -smp 2,sockets=3D2,dies=3D1,cores=3D1,threads=3D1 \ -object '{"qom-type":"memory-backend-ram","id":"ram-node0","size":21453864= 96}' \ diff --git a/tests/qemuxml2argvdata/memory-hotplug-virtio-mem.xml b/tests/q= emuxml2argvdata/memory-hotplug-virtio-mem.xml index 6220ab4c82..c578209d8a 100644 --- a/tests/qemuxml2argvdata/memory-hotplug-virtio-mem.xml +++ b/tests/qemuxml2argvdata/memory-hotplug-virtio-mem.xml @@ -1,7 +1,7 @@ QEMUGuest1 c7a5fdbd-edaf-9455-926a-d65c16db1809 - 1099511627776 + 1099511627776 8388608 8388608 2 diff --git a/tests/qemuxml2argvdata/memory-hotplug-virtio-pmem.x86_64-5.2.0= .args b/tests/qemuxml2argvdata/memory-hotplug-virtio-pmem.x86_64-5.2.0.args index e28dd339e9..fc42f9b108 100644 --- a/tests/qemuxml2argvdata/memory-hotplug-virtio-pmem.x86_64-5.2.0.args +++ b/tests/qemuxml2argvdata/memory-hotplug-virtio-pmem.x86_64-5.2.0.args @@ -13,7 +13,7 @@ XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGue= st1/.config \ -machine pc-i440fx-5.2,usb=3Doff,dump-guest-core=3Doff \ -accel kvm \ -cpu qemu64 \ --m size=3D2095104k,slots=3D16,maxmem=3D1099511627776k \ +-m size=3D2095104k,maxmem=3D1099511627776k \ -overcommit mem-lock=3Doff \ -smp 2,sockets=3D2,dies=3D1,cores=3D1,threads=3D1 \ -object memory-backend-ram,id=3Dram-node0,size=3D2145386496 \ diff --git a/tests/qemuxml2argvdata/memory-hotplug-virtio-pmem.x86_64-lates= t.args b/tests/qemuxml2argvdata/memory-hotplug-virtio-pmem.x86_64-latest.ar= gs index bd8343c15e..9bbde420a9 100644 --- a/tests/qemuxml2argvdata/memory-hotplug-virtio-pmem.x86_64-latest.args +++ b/tests/qemuxml2argvdata/memory-hotplug-virtio-pmem.x86_64-latest.args @@ -13,7 +13,7 @@ XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGue= st1/.config \ -machine pc,usb=3Doff,dump-guest-core=3Doff,acpi=3Doff \ -accel kvm \ -cpu qemu64 \ --m size=3D2095104k,slots=3D16,maxmem=3D1099511627776k \ +-m size=3D2095104k,maxmem=3D1099511627776k \ -overcommit mem-lock=3Doff \ -smp 2,sockets=3D2,dies=3D1,cores=3D1,threads=3D1 \ -object '{"qom-type":"memory-backend-ram","id":"ram-node0","size":21453864= 96}' \ diff --git a/tests/qemuxml2argvdata/memory-hotplug-virtio-pmem.xml b/tests/= qemuxml2argvdata/memory-hotplug-virtio-pmem.xml index 21b90e4d8a..a8b22dd3c5 100644 --- a/tests/qemuxml2argvdata/memory-hotplug-virtio-pmem.xml +++ b/tests/qemuxml2argvdata/memory-hotplug-virtio-pmem.xml @@ -1,7 +1,7 @@ QEMUGuest1 c7a5fdbd-edaf-9455-926a-d65c16db1809 - 1099511627776 + 1099511627776 2095104 2095104 2 --=20 2.40.1