From nobody Mon Feb 9 03:14:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.151.124 as permitted sender) client-ip=170.10.151.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.151.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=1639583588; cv=none; d=zohomail.com; s=zohoarc; b=J27/MkvZquBm0oGPrLDTInsRBLONwD1DKK0a8oqSJ0R4TNP/0PvdF0nC/Kue0iBDFyh0DohehYLe2YfWnkrEF2uBxrCJ6Sfji5fpDq3dgUn1jUN53GIOKNreuGH2OHIWSCM09X64vhc6nPTzr/2i1RilEn4dGYDgXqQlS+lw48s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639583588; 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=7d6sT2PD9n+Lz1qqbR0e3m9mycDkfCwQYjczoQQ6pu4=; b=O0zKHx/89YPmM8SiQPnwgFlq2/A2lM2tCkx3QdHdqEQ4zR6w3Uv/euFiYNmQ3YsFdiWb6IHOs2a8FqJn964z3h4Mslu9fRX/i65dEq+ZXNZRS1xPrDRoV0bNkXoz4hunabpzZ/Z2CSFIUJxfwUtDwXBucFQSjMUIs0CzVhVvRaQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.151.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.151.124]) by mx.zohomail.com with SMTPS id 16395835884381016.8180639014142; Wed, 15 Dec 2021 07:53:08 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-2-oOk8stzhNQCDRHaaLAdljQ-1; Wed, 15 Dec 2021 10:53:03 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 52F3410151E1; Wed, 15 Dec 2021 15:52:58 +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 C6C2F610A7; Wed, 15 Dec 2021 15:52:57 +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 E5E821809CB8; Wed, 15 Dec 2021 15:52:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BFFqsYD009303 for ; Wed, 15 Dec 2021 10:52:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 39EB318A58; Wed, 15 Dec 2021 15:52:54 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.34.247.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9288860CC9 for ; Wed, 15 Dec 2021 15:52:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639583587; 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=7d6sT2PD9n+Lz1qqbR0e3m9mycDkfCwQYjczoQQ6pu4=; b=PLhe/DausNNlQ+r5kS/PIMYL4f0HKG+ALXQ812MaHJRY3RRIsI5JdyK/ytuySa6/WLI69c HrWEO6zy73D1q2PTGithTHZbdYC91dSnhMa27IzOYjCumpuVn9Gveqg6NjxutG2MlPdUe/ q7Xcjiqqfl/IwFqLMXIPLJVls5MCwvo= X-MC-Unique: oOk8stzhNQCDRHaaLAdljQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/3] qemu: Explicitly forbid changing nodeset for strict numatune Date: Wed, 15 Dec 2021 16:52:13 +0100 Message-Id: <13c05a078589d84c14cef7b5772fbde647ee69b2.1639583509.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com 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.12 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 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639583589489100001 Content-Type: text/plain; charset="utf-8" Let's imagine a guest that's configured with strict numatune: For guests with NUMA: Depending on machine type used (see commit v6.4.0-rc1~75) we generate either: 1) -object '{"qom-type":"memory-backend-ram","id":"ram-node0",\ "size":20971520,"host-nodes":[0],"policy":"preferred"}' \ -numa node,nodeid=3D0,cpus=3D0,memdev=3Dram-node0 or 2) -numa node,nodeid=3D0,cpus=3D0,mem=3D20480 Later, when QEMU boots up and cpuset CGroup controller is available we further restrict QEMU there too. But there's a behaviour difference hidden: while in case 1) QEMU is restricted from beginning, in case 2) it is not and thus it may happen that it will allocate memory from different NUMA node and even though CGroup will try to migrate it, it may fail to do so (e.g. because memory is locked). Therefore, one can argue that case 2) is broken. NB, case 2) is exactly what mode 'restrictive' is for. However, in case 1) we are unable to update QEMU with new host-nodes, simply because it's lacking a command to do so. For guests without NUMA: It's very close to case 2) from above. We have commit v7.10.0-rc1~163 that prevents us from outputting host-nodes when generating memory-backend-* for system memory, but that simply allows QEMU to allocate memory anywhere and then relies on CGroups to move it to desired location. Due to all of this, there is no reliable way to change nodeset for mode 'strict'. Let's forbid it. Signed-off-by: Michal Privoznik --- src/qemu/qemu_driver.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e884dde721..0354e1474c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8777,10 +8777,9 @@ qemuDomainSetNumaParamsLive(virDomainObj *vm, size_t i =3D 0; =20 if (virDomainNumatuneGetMode(vm->def->numa, -1, &mode) =3D=3D 0 && - mode !=3D VIR_DOMAIN_NUMATUNE_MEM_STRICT && mode !=3D VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("change of nodeset for running domain requires st= rict or restrictive numa mode")); + _("change of nodeset for running domain requires re= strictive numa mode")); return -1; } =20 @@ -8913,17 +8912,31 @@ qemuDomainSetNumaParameters(virDomainPtr dom, goto endjob; } =20 - if (nodeset && - qemuDomainSetNumaParamsLive(vm, nodeset) < 0) - goto endjob; + if (mode =3D=3D VIR_DOMAIN_NUMATUNE_MEM_STRICT) { + virBitmap *config_nodeset =3D NULL; =20 - if (virDomainNumatuneSet(def->numa, - def->placement_mode =3D=3D - VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC, - -1, mode, nodeset) < 0) - goto endjob; + if (virDomainNumatuneMaybeGetNodeset(def->numa, priv->autoNode= set, + &config_nodeset, -1) < 0) + goto endjob; =20 - qemuDomainSaveStatus(vm); + if (!virBitmapEqual(nodeset, config_nodeset)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("can't change nodeset for strict mode for= running domain")); + goto endjob; + } + } else { + if (nodeset && + qemuDomainSetNumaParamsLive(vm, nodeset) < 0) + goto endjob; + + if (virDomainNumatuneSet(def->numa, + def->placement_mode =3D=3D + VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC, + -1, mode, nodeset) < 0) + goto endjob; + + qemuDomainSaveStatus(vm); + } } =20 if (persistentDef) { --=20 2.32.0