From nobody Sun Feb 8 18:43:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1678812845; cv=none; d=zohomail.com; s=zohoarc; b=n8DOOpV3Jrcdp8BU/+17Dchx8Xy5RaLgd8+bapfD0gcQATeWDfrzfqH901UqloHsH8Reg4jL0M5egl2IYPASzcgVQ0k235qztSC9H/P/cvMVbsKvPgZNyGsWo/KAFjtq2M7RpktAHABst7MRY/e23tazPWyAw1rYbmC8Qd8ou0M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678812845; 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=E1HqZi0tR5VgUFE3qzBQ9+GOTooDDJ6sHCUlUc7t/0M=; b=fFCtn0qLe4F5nT53CsDMDQ0txX0Vc7RTh8KoN7YLcCNDg7ZD5dUeFY4Utdj7Ay2R7V3CZZ/c4Xsave3/LahLOzrEVZ0VknCp1mBogU5tPbJBiSD2xZIa1HB69N8uqXvuOSP+Cx4z4FozPAtdD+sYTgAEOZCtKg1yHA3V8XJWUT4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 16788128452189.180366231177686; Tue, 14 Mar 2023 09:54:05 -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-606-RyQXXNQuOBiMf3WR1gkIUQ-1; Tue, 14 Mar 2023 12:53:12 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E4826100F83D; Tue, 14 Mar 2023 16:53:06 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF9FD140EBF4; Tue, 14 Mar 2023 16:53:06 +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 4BAE319465B9; Tue, 14 Mar 2023 16:53:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C322F19465B7 for ; Tue, 14 Mar 2023 16:52:58 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 462232166B32; Tue, 14 Mar 2023 16:52:36 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id E06F42166B26 for ; Tue, 14 Mar 2023 16:52:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678812844; 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=E1HqZi0tR5VgUFE3qzBQ9+GOTooDDJ6sHCUlUc7t/0M=; b=Vty2zuZHyHmQMUW7DihRQeoXYyttU5Tc5vgE4AXERfFDWhtRzjtJSzCE0ajPEoMEZNwxu9 r05jzwoBPYkzv3jzX7g9gVNhgyvu5QrvuoGqiTvZ8g1QOMEVz8poK/FU+MHTfYVDgrbimn nf+9+dgdtCtDUJyH8bxHvX/tRWHnxUU= X-MC-Unique: RyQXXNQuOBiMf3WR1gkIUQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 08/15] qemu: Move cpuset preference evaluation into a separate function Date: Tue, 14 Mar 2023 17:52:22 +0100 Message-Id: <911ce0ca1a492d015e7dc9b3060a58ea7d3f29f5.1678812657.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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.7 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: 1678812846395100001 Content-Type: text/plain; charset="utf-8"; x-default="true" The set of if()-s that determines the preference in cpumask used for setting things like emulatorpin, vcpupin, etc. is going to be re-used. Separate it out into a function. You may think that this changes behaviour, but qemuProcessPrepareDomainNUMAPlacement() ensures that priv->autoCpuset is set for VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO. Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani --- src/qemu/qemu_domain.c | 18 ++++++++++++++++++ src/qemu/qemu_domain.h | 5 +++++ src/qemu/qemu_process.c | 9 ++------- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0feab09bee..3d41d9e90f 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -12451,3 +12451,21 @@ qemuDomainStartupCleanup(virDomainObj *vm) for (i =3D 0; i < vm->def->ndisks; i++) qemuDomainCleanupStorageSourceFD(vm->def->disks[i]->src); } + + +virBitmap * +qemuDomainEvaluateCPUMask(const virDomainDef *def, + virBitmap *cpumask, + virBitmap *autoCpuset) +{ + if (cpumask) { + return cpumask; + } else if (autoCpuset && + def->placement_mode =3D=3D VIR_DOMAIN_CPU_PLACEMENT_MODE_AU= TO) { + return autoCpuset; + } else if (def->cpumask) { + return def->cpumask; + } + + return NULL; +} diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 9bcc5e1380..e230e9777b 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1133,3 +1133,8 @@ qemuDomainSchedCoreStart(virQEMUDriverConfig *cfg, =20 void qemuDomainSchedCoreStop(qemuDomainObjPrivate *priv); + +virBitmap * +qemuDomainEvaluateCPUMask(const virDomainDef *def, + virBitmap *cpumask, + virBitmap *autoCpuset); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index be418ad8e6..18b7781cbb 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2571,13 +2571,8 @@ qemuProcessSetupPid(virDomainObj *vm, } =20 /* Infer which cpumask shall be used. */ - if (cpumask) { - use_cpumask =3D cpumask; - } else if (vm->def->placement_mode =3D=3D VIR_DOMAIN_CPU_PLACEMENT_MOD= E_AUTO) { - use_cpumask =3D priv->autoCpuset; - } else if (vm->def->cpumask) { - use_cpumask =3D vm->def->cpumask; - } else { + if (!(use_cpumask =3D qemuDomainEvaluateCPUMask(vm->def, + cpumask, priv->autoCpuse= t))) { /* You may think this is redundant, but we can't assume libvirtd * itself is running on all pCPUs, so we need to explicitly set * the spawned QEMU instance to all pCPUs if no map is given in --=20 2.39.2