From nobody Fri Dec 19 16:08:25 2025 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=1678274106; cv=none; d=zohomail.com; s=zohoarc; b=N0SI6xiT+UdYbyRRsuQ1GVJ9ZA5Ak2WnVKtfYOZxA7CEI1g+bZ3j8SsH40/oWXQQ1+JO0xbgVNGAHiwnxXc7htclxxgiOgtNmqU+ReJf32hUnscnUKCKwcxsq5ikB/Ud5kBTje6fNGrE1/unbWw55JllwkTqd600Ye6ZUpbBQ7Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678274106; 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=JVW6YIcDVva8RkATlxZJPiOu2F2VYKXGkfmJ9R2D/aw=; b=K58xYBogn2i2xpCDZLzOPe328VwHp0+Snpq/aA6ZXk1aiX8j6rmuVumJq8/29bI5/94RS1Taeda8zMmpjXUy6lp/mcYOBYz2Tm66vdB5SHOhKVJgI6eaRSbX74zsDw3p1UXKK2+WTKczgbIIpOnJX3x9IsjZqIkWnyBpCa3UloQ= 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 1678274106612809.3447645016993; Wed, 8 Mar 2023 03:15:06 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-652-oIXuIWJ1P4y8_ZTzBkQG7Q-1; Wed, 08 Mar 2023 06:14:52 -0500 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 5C5D53C0F237; Wed, 8 Mar 2023 11:14:50 +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 33F3A1402646; Wed, 8 Mar 2023 11:14:50 +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 0BB7819465B3; Wed, 8 Mar 2023 11:14:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8C21119465B1 for ; Wed, 8 Mar 2023 11:14:48 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 632F11121330; Wed, 8 Mar 2023 11:14:48 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 05ECA112132D for ; Wed, 8 Mar 2023 11:14:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678274105; 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=JVW6YIcDVva8RkATlxZJPiOu2F2VYKXGkfmJ9R2D/aw=; b=YcxnnhC/QibLiEO1I4Z7bBy7mTPW/PBZheNjijaNwcLIjh+KRVcAPbHAoNPchuz8pUhBRc hbb+TbxwcIkaMz+GoolsUd2fpt6Cmp126ZSakNUXayw8r/obbNQh/SW3zA4oUGflQOEfQe mljZxuD0xUjP9oIpSHLadZX71mLg8e8= X-MC-Unique: oIXuIWJ1P4y8_ZTzBkQG7Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 08/14] qemu: Move cpuset preference evaluation into a separate function Date: Wed, 8 Mar 2023 12:14:35 +0100 Message-Id: <396008fc7b71e0c8868c3203ab53c79c5d484c7a.1678274036.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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: 1678274108107100001 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 aa567f652a..f99a9614e9 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -12442,3 +12442,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 550397ee50..5ca5fa416c 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1132,3 +1132,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 9a612ca443..2f6378b549 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