From nobody Sun Feb 8 06:05:28 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1583962221; cv=none; d=zohomail.com; s=zohoarc; b=RbEeVakqKWFWwBCVV+ZiGGYuBuheRW3ihSRoxY03HcDXfU5UkznbgxDT8YLhG4O/IXT2zZki7DrnBvuaw/cm+SSJHD1T/q+ZfpuaVFchfvbIWNOnS9huJHOK1gB1NfInAupXAff33XQWp6vyhS9GWZ7p/CZtWuSxZlSji+SRHLM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583962221; 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=j4UisPqrvgnLjNKHGZPkSjPuZLEdrAvx/efL4ghFDJo=; b=SaXIw7XHzdQFCb5gQCSmdk+njUdpCaS1PsuG+zBBXoAmgvm3Fle8W/C1T31sryNFleegZWBgYd6GsJf12Sz9sts7mtcZt478WvkRiTbsrlkUBHMmr3wenGNUSaFcSMnLiwGAXWTUcoU3aQJ6H+T5n1j1QozJlVnkduBeq9jTMY0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1583962221189337.21722584379904; Wed, 11 Mar 2020 14:30:21 -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-189-ebNEW8GvMNKyfn7mPCY1BA-1; Wed, 11 Mar 2020 17:30:18 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7AB9B1005F71; Wed, 11 Mar 2020 21:30:11 +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 DAA525D9E5; Wed, 11 Mar 2020 21:30:10 +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 37A6186A29; Wed, 11 Mar 2020 21:30:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02BLU5MS025688 for ; Wed, 11 Mar 2020 17:30:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6EA5910EE6D6; Wed, 11 Mar 2020 21:30:05 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 69F3F10EE78D for ; Wed, 11 Mar 2020 21:30:00 +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-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6D8258BA53D for ; Wed, 11 Mar 2020 21:30:00 +0000 (UTC) Received: from mail-qv1-f54.google.com (mail-qv1-f54.google.com [209.85.219.54]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-451-KrF9WGv7MlOGjhDjEAmWkA-1; Wed, 11 Mar 2020 17:29:57 -0400 Received: by mail-qv1-f54.google.com with SMTP id u17so1613709qvv.7 for ; Wed, 11 Mar 2020 14:29:57 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c6:acda:e3b3:e49e:9034:e20d]) by smtp.gmail.com with ESMTPSA id f93sm11371616qtd.26.2020.03.11.14.29.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Mar 2020 14:29:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583962220; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=j4UisPqrvgnLjNKHGZPkSjPuZLEdrAvx/efL4ghFDJo=; b=JDiH4xdelhd0x8Vwfgwk6XYMfEhG+KEqJaKM8owU9ZRvLA+xdcEpJiHBn/+sNdmpE3kN8N J9EcHVcCBk3PCr4xuzkugM1keVHpk1G645KGkmsT09/gFQQCPm9VMSxznIDlRnj3xwBz6V VkNSIDvtycl6baCvDxPjJGr0NCw1Bpo= X-MC-Unique: ebNEW8GvMNKyfn7mPCY1BA-1 X-MC-Unique: KrF9WGv7MlOGjhDjEAmWkA-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=Z6wBbO6TAUIEdAIwPQSppxpZcWbB+SlUbdHmrBYVLjg=; b=HKq06PyKkqPyLfpgKZ3MkxV5oC6gPxdZbsQd4D7Lc5any7lJu8Cu59/9o90NX9LwnQ dW7ct26lltz3r/7s0LPJKSC5sCXEzHNQgfiwHnmh5HcRK1YySKNmG/7W+CkLUX8QlYAf Po7BBOU/rkw/HyUx9oLPbpFXts4kqbtxOc6sAxBYHyFXgXw1v2T1U/Sc6xvfI18byq97 YivVvcBWORCA1qtLDJI8YRMovB1NAtuEXTXTfNjC9S2dbNmcMFy/0KzDvLj50EUEYVKP z8sfgx78lh1U+T5EX4xT3rNB46rmmqxzHahe5s2uuSIxCF4XQ8sFLC82jU8+I7ekCMVc 8Fuw== X-Gm-Message-State: ANhLgQ2ES16QPr5LWVxHmgQdxHKQQvOGptFGs8cCyFozM1kwVGaz3Y7d 3UmoFZ9VHpmIUTOR27rckhJL7YjUvm8= X-Google-Smtp-Source: ADFU+vvMtle8TQfGbDsnRi7b4SRKhu0a49LcDdIACBmIcJ3/6dKlWE4FOt3U+yo9bsVoaQdwe0AbkQ== X-Received: by 2002:a05:6214:12c1:: with SMTP id s1mr4477172qvv.150.1583962196964; Wed, 11 Mar 2020 14:29:56 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 3/5] conf, qemu: enable NVDIMM support for ppc64 Date: Wed, 11 Mar 2020 18:29:40 -0300 Message-Id: <20200311212942.520394-4-danielhb413@gmail.com> In-Reply-To: <20200311212942.520394-1-danielhb413@gmail.com> References: <20200311212942.520394-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 02BLU5MS025688 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza 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.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Using the 'uuid' element for ppc64 NVDIMM memory added in the previous patch, use it in qemuBuildMemoryDeviceStr() to pass it over to QEMU. Another ppc64 restriction is the necessity of a mem->labelsize, given than ppc64 only support label-area backed NVDIMMs. Finally, we don't want ppc64 NVDIMMs to align up due to the high risk of going beyond the end of file with a 256MiB increment that the user didn't predict. Align it down instead. Signed-off-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 7 +++ src/qemu/qemu_command.c | 7 +++ src/qemu/qemu_domain.c | 47 +++++++++++++++++-- .../memory-hotplug-nvdimm-ppc64.args | 32 +++++++++++++ .../memory-hotplug-nvdimm-ppc64.xml | 5 +- tests/qemuxml2argvtest.c | 4 ++ .../memory-hotplug-nvdimm-ppc64.xml | 5 +- 7 files changed, 102 insertions(+), 5 deletions(-) create mode 100644 tests/qemuxml2argvdata/memory-hotplug-nvdimm-ppc64.args diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3ae6c181c2..7f8018fed2 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16582,6 +16582,13 @@ virDomainMemoryDefParseXML(virDomainXMLOptionPtr x= mlopt, if (virDomainMemoryTargetDefParseXML(node, ctxt, def) < 0) goto error; =20 + if (def->model =3D=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM && + ARCH_IS_PPC64(dom->os.arch) && def->labelsize =3D=3D 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("label size is required for NVDIMM device")); + goto error; + } + if (virDomainDeviceInfoParseXML(xmlopt, memdevNode, &def->info, flags) < 0) goto error; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9e0334a3e7..76f1247329 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3677,6 +3677,13 @@ qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem, if (mem->labelsize) virBufferAsprintf(&buf, "label-size=3D%llu,", mem->labelsize *= 1024); =20 + if (virUUIDIsValid(mem->uuid)) { + char uuidstr[VIR_UUID_STRING_BUFLEN]; + + virUUIDFormat(mem->uuid, uuidstr); + virBufferAsprintf(&buf, "uuid=3D%s,", uuidstr); + } + if (mem->readonly) { if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_NVDIMM_UN= ARMED)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 3d3f796d85..2f420a43cd 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -12418,6 +12418,35 @@ qemuDomainGetMemoryModuleSizeAlignment(const virDo= mainDef *def, } =20 =20 +static void +qemuDomainNVDimmAlignSizePseries(virDomainDefPtr def, + virDomainMemoryDefPtr mem) +{ + /* For NVDIMMs in ppc64 in we want to align down the guest + * visible space, instead of align up, to avoid writing + * beyond the end of file by adding a potential 256MiB + * to the user specified size. + * + * The label-size is mandatory for ppc64 as well, meaning that + * the guest visible space will be target_size-label_size. + * + * Finally, target_size must include label_size. + * + * The above can be summed up as follows: + * + * target_size =3D AlignDown(target_size - label_size) + label_size + */ + unsigned long long ppc64AlignSize =3D qemuDomainGetMemorySizeAlignment= (def); + unsigned long long guestArea =3D mem->size - mem->labelsize; + + /* Align down guest_area. 256MiB is the minimum size. */ + guestArea =3D (guestArea/ppc64AlignSize) * ppc64AlignSize; + guestArea =3D MAX(guestArea, ppc64AlignSize); + + mem->size =3D guestArea + mem->labelsize; +} + + int qemuDomainAlignMemorySizes(virDomainDefPtr def) { @@ -12464,8 +12493,14 @@ qemuDomainAlignMemorySizes(virDomainDefPtr def) =20 /* Align memory module sizes */ for (i =3D 0; i < def->nmems; i++) { - align =3D qemuDomainGetMemoryModuleSizeAlignment(def, def->mems[i]= ); - def->mems[i]->size =3D VIR_ROUND_UP(def->mems[i]->size, align); + if (def->mems[i]->model =3D=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM && + ARCH_IS_PPC64(def->os.arch)) { + qemuDomainNVDimmAlignSizePseries(def, def->mems[i]); + } else { + align =3D qemuDomainGetMemoryModuleSizeAlignment(def, def->mem= s[i]); + def->mems[i]->size =3D VIR_ROUND_UP(def->mems[i]->size, align); + } + hotplugmem +=3D def->mems[i]->size; =20 if (def->mems[i]->size > maxmemkb) { @@ -12494,7 +12529,13 @@ void qemuDomainMemoryDeviceAlignSize(virDomainDefPtr def, virDomainMemoryDefPtr mem) { - mem->size =3D VIR_ROUND_UP(mem->size, qemuDomainGetMemorySizeAlignment= (def)); + if (mem->model =3D=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM && + ARCH_IS_PPC64(def->os.arch)) { + qemuDomainNVDimmAlignSizePseries(def, mem); + } else { + mem->size =3D VIR_ROUND_UP(mem->size, + qemuDomainGetMemorySizeAlignment(def)); + } } =20 =20 diff --git a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-ppc64.args b/test= s/qemuxml2argvdata/memory-hotplug-nvdimm-ppc64.args new file mode 100644 index 0000000000..92e6c538fb --- /dev/null +++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-ppc64.args @@ -0,0 +1,32 @@ +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-ppc64 \ +-name QEMUGuest1 \ +-S \ +-machine pseries,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff,nvdimm=3Don \ +-m size=3D1048576k,slots=3D16,maxmem=3D1099511627776k \ +-realtime mlock=3Doff \ +-smp 2,sockets=3D2,cores=3D1,threads=3D1 \ +-numa node,nodeid=3D0,cpus=3D0-1,mem=3D1024 \ +-object memory-backend-file,id=3Dmemnvdimm0,prealloc=3Dyes,mem-path=3D/tmp= /nvdimm,\ +size=3D537001984 \ +-device nvdimm,node=3D0,label-size=3D131072,\ +uuid=3D49545eb3-75e1-2d0a-acdd-f0294406c99e,memdev=3Dmemnvdimm0,id=3Dnvdim= m0,slot=3D0 \ +-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,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-usb \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x2 diff --git a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-ppc64.xml b/tests= /qemuxml2argvdata/memory-hotplug-nvdimm-ppc64.xml index 59352d3c52..ae5a17d3c8 100644 --- a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-ppc64.xml +++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-ppc64.xml @@ -38,8 +38,11 @@ /tmp/nvdimm - 523264 + 550000 0 +
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 35d413d40b..077f7e7650 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2790,6 +2790,10 @@ mymain(void) DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-align"); DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-pmem"); DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-readonly"); + DO_TEST("memory-hotplug-nvdimm-ppc64", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE= _NVDIMM, + QEMU_CAPS_NUMA, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE, + QEMU_CAPS_OBJECT_MEMORY_RAM, + QEMU_CAPS_OBJECT_MEMORY_FILE); =20 DO_TEST("machine-aeskeywrap-on-caps", QEMU_CAPS_AES_KEY_WRAP, diff --git a/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-ppc64.xml b/tes= ts/qemuxml2xmloutdata/memory-hotplug-nvdimm-ppc64.xml index 59352d3c52..ae5a17d3c8 100644 --- a/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-ppc64.xml +++ b/tests/qemuxml2xmloutdata/memory-hotplug-nvdimm-ppc64.xml @@ -38,8 +38,11 @@ /tmp/nvdimm - 523264 + 550000 0 +
--=20 2.24.1