From nobody Sun Feb 8 05:40:58 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1593209488; cv=none; d=zohomail.com; s=zohoarc; b=TOY0Q1/v7BUQ1fWPYup7rdMMQm+wV0o9XgoPGPm7XhTedftVAeGiemI5JTfUCxZ2UDVr+pSolmXvT18rY42AJ1mdzeUFIbyjbhtp0AI9r0D6FDlnFVCWtZo/kS0CIvWHoL0WPj3xe5Yv3RHPK5AYIc8OdpAn8oqtLgTdIU9goCc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593209488; 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=U4qaBofujN+Ku7K89YuzlE2r4GtWjKacoIoD5uDl5yo=; b=LV3b01VFq6+sW+jHO3Iynnmw5TIBYOLBIzQ+KkA2Ib0T2/+OEWO8zddwxKQzJyXlnrfU5RVPWJD68qL+Y9mbJUDiVEq9sF1WKoIyCHsaYnQwixT8RLJDb+AxLFN++6DSbT5ifpVD5V337Emsazwf+4xaeP3mUseGlkPIJ2uujac= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1593209488407886.3424619354198; Fri, 26 Jun 2020 15:11:28 -0700 (PDT) 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-468-GJizTsCQO7SfJol4YE3CdA-1; Fri, 26 Jun 2020 18:11:23 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 86E65107ACF4; Fri, 26 Jun 2020 22:11:18 +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 666C18FF97; Fri, 26 Jun 2020 22:11:18 +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 385531809563; Fri, 26 Jun 2020 22:11:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05QMB8cq015819 for ; Fri, 26 Jun 2020 18:11:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id E50F8104949F; Fri, 26 Jun 2020 22:11:07 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E096D1049499 for ; Fri, 26 Jun 2020 22:11:07 +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 C6CE4858F07 for ; Fri, 26 Jun 2020 22:11:07 +0000 (UTC) Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-177-uUUA3gFCOYioIh1sIPuBpQ-1; Fri, 26 Jun 2020 18:11:04 -0400 Received: by mail-qv1-f48.google.com with SMTP id m9so5198577qvx.5 for ; Fri, 26 Jun 2020 15:11:04 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:4951:b792:3278:7364:91bd]) by smtp.gmail.com with ESMTPSA id v10sm7159090qtk.14.2020.06.26.15.11.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 15:11:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593209486; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=U4qaBofujN+Ku7K89YuzlE2r4GtWjKacoIoD5uDl5yo=; b=Aye17hHJ2jtmljAaeVb8NLMIDAZa44XWV5BnAZLsPp370DtkeUVg+rHDwsT3qYQCQXB7rd uUsSu3GIU1+oz1bDaj087Jneue+oKSFkB78LsY++5B9S1RUXyTVGCy953HiZLsMnZGm6vg bhtNPg43dwWKSyusen5/bznopT+h2Sk= X-MC-Unique: GJizTsCQO7SfJol4YE3CdA-1 X-MC-Unique: uUUA3gFCOYioIh1sIPuBpQ-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=U4qaBofujN+Ku7K89YuzlE2r4GtWjKacoIoD5uDl5yo=; b=pWVkNj5hOL15Yx8ImFLC+caDYxb+Bo73Q1Vv6cAuvwK6KxUS0oARk0JC04caP7yuY8 zuqycX0WHrNJJhHsStTgvZAMo3GdcxludiuvJDyeRDRDPQG6AKPdNKIL6zNSkkcI0O7e MssDNQvuLkkgAtJzCox8VK6QvkWgV55liaxJoO9JT9JMPVS8eTvSQfcI4EstuAnBisxc RGN3+q7BT/xIv8nagl7j2jjmGUtO/zVINvntFX0FrwFz7Y90/D1walbvCZST6nadjcIn ZFvhL1qxlZHQ0C/9yQzdkqxnd/bNHOp4SVwi1S1Q7nhmt0Y6YRiJC4qB2gNkEepN059W dD2Q== X-Gm-Message-State: AOAM531EgSjkZqBciTQ5/utRtEq9u5xwM/G1HHEyacIkHQV3fW0VQHJL XQL5eiDt1ucirNrxf6cLPQQe/BY5 X-Google-Smtp-Source: ABdhPJzGDompVVHs02r7EDH75D7Loo8iKKYl+RD+wO650LiE2twjKmsYLl8H3EROMfNq+F8L8LGi6Q== X-Received: by 2002:a05:6214:8d1:: with SMTP id da17mr5306767qvb.62.1593209463473; Fri, 26 Jun 2020 15:11:03 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 7/7] conf, qemu: consider available CPUs in vcpupin/emulatorpin output Date: Fri, 26 Jun 2020 19:10:44 -0300 Message-Id: <20200626221044.631749-8-danielhb413@gmail.com> In-Reply-To: <20200626221044.631749-1-danielhb413@gmail.com> References: <20200626221044.631749-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 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.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The output of vcpupin and emulatorpin for a domain with vcpu placement=3D'static' is based on a default bitmap that contains all possible CPUs in the host, regardless of the CPUs being offline or not. E.g. for a Linux host with this CPU setup (from lscpu): On-line CPU(s) list: 0,8,16,24,32,40,(...),184 Off-line CPU(s) list: 1-7,9-15,17-23,25-31,(...),185-191 And a domain with this configuration: 1 'virsh vcpupin' will return the following: $ sudo ./run tools/virsh vcpupin vcpupin_test VCPU CPU Affinity ---------------------- 0 0-191 This is benign by its own, but can make the user believe that all CPUs from the 0-191 range are eligible for pinning. Which can lead to situations like this: $ sudo ./run tools/virsh vcpupin vcpupin_test 0 1 error: Invalid value '1' for 'cpuset.cpus': Invalid argument This is exarcebated by the fact that 'virsh vcpuinfo' considers only available host CPUs in the 'CPU Affinity' field: $ sudo ./run tools/virsh vcpuinfo vcpupin_test (...) CPU Affinity: y-------y-------y-------(...) This patch changes the default bitmap of vcpupin and emulatorpin, in the case of domains with static vcpu placement, to all available CPUs instead of all possible CPUs. Aside from making it consistent with the behavior of 'vcpuinfo', users will now have one less incentive to try to pin a vcpu in an offline CPU. https://bugzilla.redhat.com/show_bug.cgi?id=3D1434276 Signed-off-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 4 +--- src/qemu/qemu_driver.c | 7 +------ 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 31ba78b950..6f95023aaf 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2089,11 +2089,9 @@ virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def, if (hostcpus < 0) return -1; =20 - if (!(allcpumap =3D virBitmapNew(hostcpus))) + if (!(allcpumap =3D virHostCPUGetAvailableCPUsBitmap())) return -1; =20 - virBitmapSetAll(allcpumap); - for (i =3D 0; i < maxvcpus && i < ncpumaps; i++) { virDomainVcpuDefPtr vcpu =3D virDomainDefGetVcpu(def, i); virBitmapPtr bitmap =3D NULL; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d486ce5278..22f0313394 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5425,7 +5425,6 @@ qemuDomainGetEmulatorPinInfo(virDomainPtr dom, virDomainDefPtr def; bool live; int ret =3D -1; - int hostcpus; virBitmapPtr cpumask =3D NULL; g_autoptr(virBitmap) bitmap =3D NULL; virBitmapPtr autoCpuset =3D NULL; @@ -5442,9 +5441,6 @@ qemuDomainGetEmulatorPinInfo(virDomainPtr dom, if (!(def =3D virDomainObjGetOneDefState(vm, flags, &live))) goto cleanup; =20 - if ((hostcpus =3D virHostCPUGetCount()) < 0) - goto cleanup; - if (live) autoCpuset =3D QEMU_DOMAIN_PRIVATE(vm)->autoCpuset; =20 @@ -5456,9 +5452,8 @@ qemuDomainGetEmulatorPinInfo(virDomainPtr dom, autoCpuset) { cpumask =3D autoCpuset; } else { - if (!(bitmap =3D virBitmapNew(hostcpus))) + if (!(bitmap =3D virHostCPUGetAvailableCPUsBitmap())) goto cleanup; - virBitmapSetAll(bitmap); cpumask =3D bitmap; } =20 --=20 2.26.2