From nobody Fri Apr 19 05:25:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1605729572; cv=none; d=zohomail.com; s=zohoarc; b=I0QRZgAlKQBb48hGROAmHNdSca31R1m/0b6smXloeRB5xX8q2zXXKlaRUHSEwR+x3eaa7G4SI5X9s6ar7jGN4cb6DLPAS0EKaAXlEwqcXHnQT3U0sSCz1LMN35YM35QlovSF8bz69s6uwjxUN/1PGPmaG8m5abLswnXfTsFbzVI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605729572; 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=llNkXIIvt8k/xS4gQJwsI5dcWIZcqftmHRGkm/GNSkU=; b=IAvOSlGCCfG068u4ZI0cQbwIBaeUvQYO/JnmTWrPs4XMSOQHgMT52LsG+Xm81UMWE8Ln5ZWUxEu0iI2SEe2qIAW4sWgnRCeE+N9P/ckdgRjD2cEfZHctDvRgPg6/lDt2tQULKpe2TuM3lM9bD0nu5h5sWK04waiHvMCGzbK+H54= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1605729572205496.27666293324376; Wed, 18 Nov 2020 11:59:32 -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-519-VCrBlFUXMTyeHl5MTaa0KA-1; Wed, 18 Nov 2020 14:59:27 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A8F93884E4D; Wed, 18 Nov 2020 19:59:19 +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 7CD9A5D6A8; Wed, 18 Nov 2020 19:59:19 +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 1EB8A8C7A1; Wed, 18 Nov 2020 19:59:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0AIJx1Im021617 for ; Wed, 18 Nov 2020 14:59:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3DD01A37C0; Wed, 18 Nov 2020 19:59:01 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3884BA9A13 for ; Wed, 18 Nov 2020 19:59:01 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (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 13008811E98 for ; Wed, 18 Nov 2020 19:59:01 +0000 (UTC) Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-395-V-rMiA6KPG-hIBnR3kmj4w-1; Wed, 18 Nov 2020 14:58:58 -0500 Received: by mail-qk1-f179.google.com with SMTP id r7so3102576qkf.3 for ; Wed, 18 Nov 2020 11:58:58 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c7:d88a:482:7c39:5cca:96f6]) by smtp.gmail.com with ESMTPSA id n21sm7022757qke.21.2020.11.18.11.58.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2020 11:58:57 -0800 (PST) X-MC-Unique: VCrBlFUXMTyeHl5MTaa0KA-1 X-MC-Unique: V-rMiA6KPG-hIBnR3kmj4w-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=llNkXIIvt8k/xS4gQJwsI5dcWIZcqftmHRGkm/GNSkU=; b=peQdFrixKAKjxdGGe0lcgCV3DuIeNzaecQmIJvdZISgfFsn08fHb0IvfGdwVTWbtAM l2jMgR4nRbot/GPmggYyf+TUc1de9rs4NkEFCIovISONpF3v7rI7sudWebq5Jur1KNls aPln4RuOg7IBq1Tp5MvHGvfURHql7iTSsKET/iHoM1H3qfDo5WA4QOvxaNLpKudD+0Fv kvRH26iKARnPRyKJpN1Ff0x9dhh6/lXM4wf0yHU846cWg/9V2NcjFedRX+pZYTbsXNPA jfdhcHWFlJwiSg7PIh8wMBcmWG1l45vgmmigUQ5htXZ35yLqpangcyLsBBw7+VuSNti2 mzYg== X-Gm-Message-State: AOAM532QZmVjFJMOcPmsU/2b8PgeaNu/K3ChENCwbX4TUGzjkF87oRQ1 DQNv6lWJiGbdeKvAfdAfBaEI/AcvDG5LRA== X-Google-Smtp-Source: ABdhPJx+87KC5QJmN1q0n52rxaTZxaaNUYi5plIxuQCkQE1wsY1UI7+efNqxU+VtibQ6mTfZxuOnkQ== X-Received: by 2002:a05:620a:1087:: with SMTP id g7mr6522387qkk.457.1605729537716; Wed, 18 Nov 2020 11:58:57 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 6/6] qemu_domain.c: align all pSeries mem modules when PARSE_ABI_UPDATE Date: Wed, 18 Nov 2020 16:58:34 -0300 Message-Id: <20201118195834.1187381-7-danielhb413@gmail.com> In-Reply-To: <20201118195834.1187381-1-danielhb413@gmail.com> References: <20201118195834.1187381-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.79 on 10.11.54.5 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.15 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) Signed-off-by: Daniel Henrique Barboza --- src/qemu/qemu_domain.c | 14 ++++-- ...emory-hotplug-ppc64-nonuma-abi-update.args | 34 ++++++++++++++ ...memory-hotplug-ppc64-nonuma-abi-update.xml | 32 +++++++++++++ tests/qemuxml2argvtest.c | 7 +++ ...memory-hotplug-ppc64-nonuma-abi-update.xml | 45 +++++++++++++++++++ tests/qemuxml2xmltest.c | 7 +++ 6 files changed, 135 insertions(+), 4 deletions(-) create mode 100644 tests/qemuxml2argvdata/memory-hotplug-ppc64-nonuma-abi-= update.args create mode 100644 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 b9eb54a11c..a16ec9ac58 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5354,10 +5354,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 && - virDomainNVDimmAlignSizePseries(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 (virDomainNVDimmAlignSizePseries(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..78406f7f04 --- /dev/null +++ b/tests/qemuxml2argvdata/memory-hotplug-ppc64-nonuma-abi-update.args @@ -0,0 +1,34 @@ +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 \ +-kernel /media/ram/uImage \ +-initrd /media/ram/ramdisk \ +-append 'root=3D/dev/ram rw console=3DttyS0,115200' \ +-usb \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x2 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 100644 index 0000000000..7c68cd6aa2 --- /dev/null +++ b/tests/qemuxml2argvdata/memory-hotplug-ppc64-nonuma-abi-update.xml @@ -0,0 +1,32 @@ + + QEMUGuest1 + 49545eb3-75e1-2d0a-acdd-f0294406c99e + 4194304 + 2097152 + 2097152 + 1 + + hvm + /media/ram/uImage + /media/ram/ramdisk + root=3D/dev/ram rw console=3DttyS0,115200 + + + destroy + restart + destroy + + /usr/bin/qemu-system-ppc64 + + + + 523264 + + + + + 524287 + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 174294c0f1..dabf00a53a 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..832c4cea27 --- /dev/null +++ b/tests/qemuxml2xmloutdata/memory-hotplug-ppc64-nonuma-abi-update.xml @@ -0,0 +1,45 @@ + + QEMUGuest1 + 49545eb3-75e1-2d0a-acdd-f0294406c99e + 4194304 + 2097152 + 2097152 + 1 + + hvm + /media/ram/uImage + /media/ram/ramdisk + root=3D/dev/ram rw console=3DttyS0,115200 + + + + destroy + restart + destroy + + /usr/bin/qemu-system-ppc64 + +
+ + + + + + +
+ + + + + 524288 + +
+ + + + 524288 + +
+ + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 595a897a70..f20616fdac 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1246,6 +1246,13 @@ mymain(void) QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE, QEMU_CAPS_DEVICE_NVDIMM, QEMU_CAPS_LAST); + 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); =20 DO_TEST("net-udp", NONE); =20 --=20 2.26.2