From nobody Sun Feb 8 03:32:59 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.124 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=1607044016; cv=none; d=zohomail.com; s=zohoarc; b=BySojNSsj8Aw3NVRwFrtlSkfJMi21r2MByTiP6fDiq4QYOVXLL/52xK4WJkrwc4uL9DI5rM/jzTaWoQhpj/i7BPet+VRztcrCYHv5FzKhA4a/Vv3F8mWFrO3r5Jwa2P+tdQl91pNw9uRIN6b8q7EfoPP0QEsnB4bxiaO3+GiBf4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607044016; 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=c5vK2rwRavo9RTospaXkfYMOJFvYmPA+oKOXNbnOZe8=; b=Svu6VOYliziDVerzchcSTz8z12RFxglxzMDcTuzv/o02vz0UuJ6JoGoQQU/moIspjGvMksUrm4NuRQgdmsa3+Ezb9Car1bFsErhSrbJqOLD9CpTEpUvsR+9+URrFzXJYWSxxKgCBdCXaPKvU8mQva34so7Tg7lEpyUoucynBBxs= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 160704401663063.604302240804714; Thu, 3 Dec 2020 17:06:56 -0800 (PST) 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-450-bgvfmTZVNtyZQLdbqS8nUA-1; Thu, 03 Dec 2020 20:06:52 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5C5531005D50; Fri, 4 Dec 2020 01:06:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 36DC51A8A0; Fri, 4 Dec 2020 01:06:44 +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 031A61809CA0; Fri, 4 Dec 2020 01:06:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B415vxX026448 for ; Thu, 3 Dec 2020 20:05:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id 833532026D3E; Fri, 4 Dec 2020 01:05:57 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7CDC52027144 for ; Fri, 4 Dec 2020 01:05:57 +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 64B188007DF for ; Fri, 4 Dec 2020 01:05:57 +0000 (UTC) Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-247-lSRO82NVP9yYAXtS05S5ow-1; Thu, 03 Dec 2020 20:05:53 -0500 Received: by mail-qv1-f51.google.com with SMTP id k3so2027636qvz.4; Thu, 03 Dec 2020 17:05:53 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id z133sm3600542qka.20.2020.12.03.17.05.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2020 17:05:52 -0800 (PST) X-MC-Unique: bgvfmTZVNtyZQLdbqS8nUA-1 X-MC-Unique: lSRO82NVP9yYAXtS05S5ow-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=c5vK2rwRavo9RTospaXkfYMOJFvYmPA+oKOXNbnOZe8=; b=CyNSEpvBpUOtTqK4uAMOWRxNV1N93l6hGVzQceh1n1WIXs8uf8GZzDQonHTDRvB1th lBtqtzbvulZhTz4v2eYukmlUP9Fwv1fgVVjlsaRWYtx4fjBiZ2gBqLAOdCXQvF6/SFWo +Bq8nTeYohn4zKNZwsk4cAAHgM3POdBqkGe+ZlnUebF00j9MpGV90CSDEiTvrL2dB3Xm Ik9F3UWqn4lt8TDIxnGjNiq7v2C7H/Oahe6PbsS3HodqAuso68PVwewnSJhksivrwNpu 0tWwlk7s2REjzXM1si4XG9dKNxsHWJmbzP66oA1HcQ5aUGZIWAlBU1GSHl5F++9Wkque uIwQ== X-Gm-Message-State: AOAM532wY8L1cuGLyUE49c6YiJcdovdDNGdvkWH1O2r7moTxdso8a/m+ N9s1BKYX0XUtfZv19kJQtxdTDpuhrHTlCg== X-Google-Smtp-Source: ABdhPJyp35tXYhN5cl/4chgV3pBnKZvrLnAu2xE9y+50citkNlZUK7l4L+Bg8Hx46vxUk8Ju7J+5cA== X-Received: by 2002:a0c:ba86:: with SMTP id x6mr2167938qvf.21.1607043952654; Thu, 03 Dec 2020 17:05:52 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 5/5] qemu_domain.c: align all pSeries mem modules when PARSE_ABI_UPDATE Date: Thu, 3 Dec 2020 22:05:29 -0300 Message-Id: <20201204010529.325244-6-danielhb413@gmail.com> In-Reply-To: <20201204010529.325244-1-danielhb413@gmail.com> References: <20201204010529.325244-1-danielhb413@gmail.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.4 X-loop: libvir-list@redhat.com Cc: Michal Privoznik , 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.84 on 10.5.11.23 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" qemuDomainAlignMemorySizes() has an operation order problem. We are calculating 'initialmem' without aligning the memory modules first. Since we're aligning the dimms afterwards this can create inconsistencies in the end result. x86 has alignment of 1-2MiB and it's not severely impacted by it, but pSeries works with 256MiB alignment and the difference is noticeable. This is the case of the existing 'memory-hotplug-ppc64-nonuma' test. The test consists of a 2GiB (aligned value) guest with 2 ~520MiB dimms, both unaligned. 'initialmem' is calculated by taking total_mem and subtracting the dimms size (via virDomainDefGetMemoryInitial()), which wil give us 2GiB - 520MiB - 520MiB, ending up with a little more than an 1GiB of 'initialmem'. Note that this value is now unaligned, and will be aligned up via VIR_ROUND_UP(), and we'll end up with 'initialmem' of 1GiB + 256MiB. Given that the dimms are aligned later on, the end result for QEMU is that the guest will have a 'mem' size of 1310720k, plus the two 512 MiB dimms, exceeding in 256MiB the desired 2GiB memory and currentMemory specified in the XML. Existing guests can't be fixed without breaking ABI, but we have code already in place to align pSeries NVDIMM modules for new guests. Let's extend it to align all pSeries mem modules. A new test, 'memory-hotplug-ppc64-nonuma-abi-update', a copy of the existing 'memory-hotplug-ppc64-nonuma', was added to demonstrate the result for new pSeries guests. For the same unaligned XML mentioned above, after applying this patch: - starting QEMU mem size without PARSE_ABI_UPDATE: -m size=3D1310720k,slots=3D16,maxmem=3D4194304k \ (no changes) - starting QEMU mem size with PARSE_ABI_UPDATE: -m size=3D1048576k,slots=3D16,maxmem=3D4194304k \ (size fixed) Reviewed-by: Michal Privoznik Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrea Bolognani --- src/qemu/qemu_domain.c | 14 +++++-- ...emory-hotplug-ppc64-nonuma-abi-update.args | 29 ++++++++++++++ ...memory-hotplug-ppc64-nonuma-abi-update.xml | 1 + tests/qemuxml2argvtest.c | 7 ++++ ...memory-hotplug-ppc64-nonuma-abi-update.xml | 38 +++++++++++++++++++ tests/qemuxml2xmltest.c | 7 ++++ 6 files changed, 92 insertions(+), 4 deletions(-) create mode 100644 tests/qemuxml2argvdata/memory-hotplug-ppc64-nonuma-abi-= update.args create mode 120000 tests/qemuxml2argvdata/memory-hotplug-ppc64-nonuma-abi-= update.xml create mode 100644 tests/qemuxml2xmloutdata/memory-hotplug-ppc64-nonuma-ab= i-update.xml diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 5fff7d312d..e7f82d42ed 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5395,10 +5395,16 @@ qemuDomainMemoryDefPostParse(virDomainMemoryDefPtr = mem, virArch arch, * later on by qemuDomainAlignMemorySizes() to contemplate existing * guests as well. */ if (parseFlags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE) { - if (ARCH_IS_PPC64(arch) && - mem->model =3D=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM && - qemuDomainNVDimmAlignSizePseries(mem) < 0) - return -1; + if (ARCH_IS_PPC64(arch)) { + unsigned long long ppc64MemModuleAlign =3D 256 * 1024; + + if (mem->model =3D=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM) { + if (qemuDomainNVDimmAlignSizePseries(mem) < 0) + return -1; + } else { + mem->size =3D VIR_ROUND_UP(mem->size, ppc64MemModuleAlign); + } + } } =20 return 0; diff --git a/tests/qemuxml2argvdata/memory-hotplug-ppc64-nonuma-abi-update.= args b/tests/qemuxml2argvdata/memory-hotplug-ppc64-nonuma-abi-update.args new file mode 100644 index 0000000000..ac741b80c0 --- /dev/null +++ b/tests/qemuxml2argvdata/memory-hotplug-ppc64-nonuma-abi-update.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-ppc64 \ +-name QEMUGuest1 \ +-S \ +-machine pseries,accel=3Dkvm,usb=3Doff,dump-guest-core=3Doff \ +-m size=3D1048576k,slots=3D16,maxmem=3D4194304k \ +-realtime mlock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-object memory-backend-ram,id=3Dmemdimm0,size=3D536870912 \ +-device pc-dimm,memdev=3Dmemdimm0,id=3Ddimm0,slot=3D0 \ +-object memory-backend-ram,id=3Dmemdimm1,size=3D536870912 \ +-device pc-dimm,memdev=3Dmemdimm1,id=3Ddimm1,slot=3D1 \ +-uuid 49545eb3-75e1-2d0a-acdd-f0294406c99e \ +-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 diff --git a/tests/qemuxml2argvdata/memory-hotplug-ppc64-nonuma-abi-update.= xml b/tests/qemuxml2argvdata/memory-hotplug-ppc64-nonuma-abi-update.xml new file mode 120000 index 0000000000..03410026cc --- /dev/null +++ b/tests/qemuxml2argvdata/memory-hotplug-ppc64-nonuma-abi-update.xml @@ -0,0 +1 @@ +memory-hotplug-ppc64-nonuma.xml \ No newline at end of file diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index a9bd210ca3..7c9dc0e641 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -3005,6 +3005,13 @@ mymain(void) DO_TEST("memory-hotplug-ppc64-nonuma", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE= _PC_DIMM, QEMU_CAPS_NUMA, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE, QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE); + DO_TEST_FULL("memory-hotplug-ppc64-nonuma-abi-update", + ARG_PARSEFLAGS, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE, + ARG_QEMU_CAPS, + QEMU_CAPS_KVM, QEMU_CAPS_DEVICE_PC_DIMM, + QEMU_CAPS_NUMA, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE, + QEMU_CAPS_OBJECT_MEMORY_RAM, + QEMU_CAPS_OBJECT_MEMORY_FILE); DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm"); DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-access"); DO_TEST_CAPS_LATEST("memory-hotplug-nvdimm-label"); diff --git a/tests/qemuxml2xmloutdata/memory-hotplug-ppc64-nonuma-abi-updat= e.xml b/tests/qemuxml2xmloutdata/memory-hotplug-ppc64-nonuma-abi-update.xml new file mode 100644 index 0000000000..4edb786e6f --- /dev/null +++ b/tests/qemuxml2xmloutdata/memory-hotplug-ppc64-nonuma-abi-update.xml @@ -0,0 +1,38 @@ + + QEMUGuest1 + 49545eb3-75e1-2d0a-acdd-f0294406c99e + 4194304 + 2097152 + 2097152 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-ppc64 + + + + + + + + + + 524288 + +
+ + + + 524288 + +
+ + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 18faea2b33..1968be6782 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1232,6 +1232,13 @@ mymain(void) DO_TEST("memory-hotplug-ppc64-nonuma", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE= _PC_DIMM, QEMU_CAPS_NUMA, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE, QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE); + DO_TEST_FULL("memory-hotplug-ppc64-nonuma-abi-update", WHEN_BOTH, + ARG_PARSEFLAGS, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE, + ARG_QEMU_CAPS, + QEMU_CAPS_KVM, QEMU_CAPS_DEVICE_PC_DIMM, + QEMU_CAPS_NUMA, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE, + QEMU_CAPS_OBJECT_MEMORY_RAM, + QEMU_CAPS_OBJECT_MEMORY_FILE, QEMU_CAPS_LAST); DO_TEST("memory-hotplug", NONE); DO_TEST("memory-hotplug-dimm", QEMU_CAPS_DEVICE_PC_DIMM); DO_TEST("memory-hotplug-nvdimm", QEMU_CAPS_DEVICE_NVDIMM); --=20 2.26.2