From nobody Thu Mar 28 12:31:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.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 207.211.31.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=1593209473; cv=none; d=zohomail.com; s=zohoarc; b=E3WQ/SZPEessqRubVm5WzxG79pU7GkElvMFQMpYHnEE7r590gr1IkWpge3iJGkzQc4ZMX/l0AnV5yOHawbPNCldYrCVasO3Z8Sn6ODudXR8ee3e94zdiCIQyEBc48WCjZKRwXswFvr2I+nw1qR4O6e6g4xs5LYUbaEygWQWJq8s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593209473; 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=7vHOg663Yq/QEVQ2XtqRKl0EtY+XfEM9yG1SFF1tMMA=; b=jWBeA0CDTVly67YQqqIerJTHV6/cj1v69VOrLe18dY7SJtKSGnrOkvVWI+BUCJMNZ5Bnrptul9UFquf0ZGwcH3y/0yny75DG3wTAX5DQQojnJc8Xsb64nzoG9a5KBsWHn0FrCrBTWicyn2P1SkT5IbnU0VMrZRHxEEDl2EAL0Is= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.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 [207.211.31.120]) by mx.zohomail.com with SMTPS id 1593209473589803.7175800599475; Fri, 26 Jun 2020 15:11:13 -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-159-iZWOi3NVPlyzdT4qn0KfSg-1; Fri, 26 Jun 2020 18:11:10 -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 51AE710059A2; Fri, 26 Jun 2020 22:11:04 +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 31C518FF97; Fri, 26 Jun 2020 22:11:04 +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 F2A31875BF; Fri, 26 Jun 2020 22:11:03 +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 05QMB26p015677 for ; Fri, 26 Jun 2020 18:11:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id A86D81065681; Fri, 26 Jun 2020 22:11:02 +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 0967D104949D for ; Fri, 26 Jun 2020 22:10:57 +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 4A8ED858F03 for ; Fri, 26 Jun 2020 22:10:57 +0000 (UTC) Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-229-b2M4GUWFPBKqARw2rGPBFA-1; Fri, 26 Jun 2020 18:10:55 -0400 Received: by mail-qk1-f175.google.com with SMTP id e11so10262230qkm.3 for ; Fri, 26 Jun 2020 15:10:54 -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.10.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 15:10:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593209472; 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=7vHOg663Yq/QEVQ2XtqRKl0EtY+XfEM9yG1SFF1tMMA=; b=f31/ewwnEQIX6WNjTsCVonXwSb4yCpZ4A2PG+7rA1BNzR0O6XwERdxaGWMYT+62uWaD3J9 WwxA8X3zeMybHzO+r4GJde4Kg6w+ueKsuNV8qiswP50cKuTPUwMD6NPAYncnMcyVJLGdY1 MwgrcqLL8G0LnQIIV8v4XRXqxcAzGBc= X-MC-Unique: iZWOi3NVPlyzdT4qn0KfSg-1 X-MC-Unique: b2M4GUWFPBKqARw2rGPBFA-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=7vHOg663Yq/QEVQ2XtqRKl0EtY+XfEM9yG1SFF1tMMA=; b=XKBjAkOpjuFrrhEaDFaJ6gnQqm/Jv3/C2Xl7K2f5pxBD+j0rGvvqL+/KZ9x/p7riC8 3uFpxj87QZG2ONWn5IZnRiBS1W04HNIS5tW7IuBgIwFPxHiT9SyrAbZl0a02H3LOSj0T diRgAV9MUHewX28IM6JNhI9zQQuK5vGt43bFkDDyQvHicV2x6xQdXS5TiJKxpRJBdlIX zD0OlijQbocbr6iQ7BACNgHjuY2vbRh9UDM4RXFgF0II8KaEeX7NxPv97t6loPEvcJRI MNFERkcf/A3D1AJpAQdNGl8LxNfPr6W72PLHYsRA4UBAmIypE04+9IuJeOX4cB+OXaU7 PkGg== X-Gm-Message-State: AOAM532oQlM0DxzdwPhsrK1B4HJkjOH0NJN21N/ZGErHxORRsex85z3G snUAKOe40KBcAAu56WlSEwaPb+6L X-Google-Smtp-Source: ABdhPJzm/DUrSF1/123o+JSxxlcKEad1kEbK2ofCN/ID0d4PxmNxLGw4DErsxOcZ9yMFcJkPyIIbrA== X-Received: by 2002:a37:a444:: with SMTP id n65mr4792841qke.289.1593209454359; Fri, 26 Jun 2020 15:10:54 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 1/7] qemu_driver.c: use g_autoptr in qemuDomainGetEmulatorPinInfo() Date: Fri, 26 Jun 2020 19:10:38 -0300 Message-Id: <20200626221044.631749-2-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" Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/qemu/qemu_driver.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a5b38b3d24..d486ce5278 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5427,7 +5427,7 @@ qemuDomainGetEmulatorPinInfo(virDomainPtr dom, int ret =3D -1; int hostcpus; virBitmapPtr cpumask =3D NULL; - virBitmapPtr bitmap =3D NULL; + g_autoptr(virBitmap) bitmap =3D NULL; virBitmapPtr autoCpuset =3D NULL; =20 virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | @@ -5468,7 +5468,6 @@ qemuDomainGetEmulatorPinInfo(virDomainPtr dom, =20 cleanup: virDomainObjEndAPI(&vm); - virBitmapFree(bitmap); return ret; } =20 --=20 2.26.2 From nobody Thu Mar 28 12:31:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.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 207.211.31.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=1593209484; cv=none; d=zohomail.com; s=zohoarc; b=M2MOxYO2huG/uLSHDDHyudMG1alD1pGirsggCGqwQdMXvWHdxm9hWiph4kLU3PHE9CpRnQp+hX2+v+MsU6kSYR+aGK3i8fnpPFkgSAvAiAl80AZokBEqx8YYP04Xw+jN4HoKhk8HRy/hd7b42DMx7cDMQkPQrYIYSwODfELEGnM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593209484; 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=PvHrOuKJT0kXxeHes4TMUHKBdi3qXbG8t1qcRnFZ3EY=; b=jR0t8bD60zonFbcDRqADYlCIQsAwAgXpkFzdUbKPLscIyxcTl+HDt1n7uWTqYqYS9UgJ8ZWahLod5VUo/GTIEbrfPkx+RlkJOKjePr80eLf4iczotOvbcpazUA/8EcWu/r4a0Kz2qWdy3ICGoOP+3zCK9ne9j+kQeVLCZIy6Umk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.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 [207.211.31.120]) by mx.zohomail.com with SMTPS id 1593209484004488.37184045096114; Fri, 26 Jun 2020 15:11:24 -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-351-6wIcqemtMI2M4amP2ORurA-1; Fri, 26 Jun 2020 18:11:20 -0400 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 331E518585C4; Fri, 26 Jun 2020 22:11:15 +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 102E76106A; Fri, 26 Jun 2020 22:11:15 +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 D3ED1104916; Fri, 26 Jun 2020 22:11:14 +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 05QMB2sp015676 for ; Fri, 26 Jun 2020 18:11:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id AE1F312F780; Fri, 26 Jun 2020 22:11:02 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 130A812F786 for ; Fri, 26 Jun 2020 22:10:58 +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 88400800260 for ; Fri, 26 Jun 2020 22:10:58 +0000 (UTC) Received: from mail-qv1-f65.google.com (mail-qv1-f65.google.com [209.85.219.65]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-35-GibghStyO-upPimQBIfO_g-1; Fri, 26 Jun 2020 18:10:56 -0400 Received: by mail-qv1-f65.google.com with SMTP id dp10so5172256qvb.10 for ; Fri, 26 Jun 2020 15:10:56 -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.10.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 15:10:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593209482; 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=PvHrOuKJT0kXxeHes4TMUHKBdi3qXbG8t1qcRnFZ3EY=; b=U6aMFZ7O1h5k6YIjvIIB2U7WUyZzp9ilBfHlFi/zEmVc6J4Teg/xMEWOwvh4jMM44Q0tag mZFQ9bwtf3iXLh4QIrVhQ6eNisIlSBPNIclJqezI+HZfVLAO0Pk7DkVAbfjuj9nZA9V/vg y2iJv46EAj6I7aB9eG7PJv3Ts+e9i88= X-MC-Unique: 6wIcqemtMI2M4amP2ORurA-1 X-MC-Unique: GibghStyO-upPimQBIfO_g-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=PvHrOuKJT0kXxeHes4TMUHKBdi3qXbG8t1qcRnFZ3EY=; b=QeiGUP4VbZLa/GegTONEmE94pmmdL8nMj2AhzQ457yWoA9gNKEhINrMeRGUVcaFIlB 8jpPAVONBuvNYnn7x0DUser9i+SwX0NeQRcoGZ2hDOLVtJ82fx5c0J5Hcqx3fr+PjgAZ wg+o76pW+nnMykE+vIREpQivMqrJ5atMgVNrAPNSitKl3c9XruQqoWucg8W/CPo+E5Sm qO/hxDfc2GGXHOPPMXmL7AW0kPxcRtSLcyi7YyFirV7CVplpyI9Q3ekCj9mE1tWFR0jd ipGug28H7mcBl39HgcmPjmRM5R3skutyC2Ac41Fdu7uDhswabuDt1ogXAKJhD1W2ivT0 FH7A== X-Gm-Message-State: AOAM533dO5VM721rvr3K9QvdxJ9kurBLF+gwDh93TN6+Ve7Gb/U0lby6 C3E/R1hP3L6WdhAx9zJGtFiuTcyz X-Google-Smtp-Source: ABdhPJwe5O6eqT0BAmCT9HAmyX0zpN5/3xw6GVPH+OkEh0j3Ki4ajp1HE7dJWDFCxx4NlBUqn/R7+A== X-Received: by 2002:a05:6214:8f4:: with SMTP id dr20mr5000685qvb.228.1593209455872; Fri, 26 Jun 2020 15:10:55 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 2/7] virhostcpu.c: use g_autoptr in virHostCPUGetMap() Date: Fri, 26 Jun 2020 19:10:39 -0300 Message-Id: <20200626221044.631749-3-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.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.12 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" Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/util/virhostcpu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index 39bbcf8ca8..3023bca831 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -1089,7 +1089,7 @@ virHostCPUGetMap(unsigned char **cpumap, unsigned int *online, unsigned int flags) { - virBitmapPtr cpus =3D NULL; + g_autoptr(virBitmap) cpus =3D NULL; int ret =3D -1; int dummy; =20 @@ -1111,7 +1111,6 @@ virHostCPUGetMap(unsigned char **cpumap, cleanup: if (ret < 0 && cpumap) VIR_FREE(*cpumap); - virBitmapFree(cpus); return ret; } =20 --=20 2.26.2 From nobody Thu Mar 28 12:31:36 2024 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=1593209489; cv=none; d=zohomail.com; s=zohoarc; b=gn1oXMcs17KJDUtGWs8T6GkmKULbQI9e7TISh2Kka2qlqoQR2a9JRd+ZDIlj1O/HWom6FiBRfRfdCsacJb/6POqfTCn1QRPsaMUzOdOXsap+V7wp2rj5MlXxneroxBp5zVDqP6aG/C+HkFvTbODV4r1DA00WYxzZyVChxaAPDM0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593209489; 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=NZ0vZShxg5Utl0JFwccrrxPAovnsYMFb8bomL9Akz2E=; b=b4ipqbe9gPiTCSRUrzYNx7CVjOTiQMUeJqVnY63FRF1GX4LKkNLZQCS5VSLYRWlhfyIjaomIq3VGLTXIY+YIUQxkCClIADnFIAff8PWpLeA6h+PU5anmMjwOfItnSQCFE8cNT6hjN+Mkj51Tm0DT04EpnJWCjrVraCkBdGPAfe4= 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 1593209489028773.8816878856294; Fri, 26 Jun 2020 15:11:29 -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-396-kyje8yTxNieWmkE_wlAYaw-1; Fri, 26 Jun 2020 18:11:22 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5E30FBFC8; Fri, 26 Jun 2020 22:11:17 +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 3FE83612A5; Fri, 26 Jun 2020 22:11:17 +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 0D5EF180954D; Fri, 26 Jun 2020 22:11:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05QMB27A015675 for ; Fri, 26 Jun 2020 18:11:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id A80D72017E80; Fri, 26 Jun 2020 22:11:02 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A339920182A5 for ; Fri, 26 Jun 2020 22:11:00 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (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 79B178007CD for ; Fri, 26 Jun 2020 22:11:00 +0000 (UTC) Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-350-13yLDHrhMj2jH-uedpk0pA-1; Fri, 26 Jun 2020 18:10:58 -0400 Received: by mail-qt1-f193.google.com with SMTP id i3so8614950qtq.13 for ; Fri, 26 Jun 2020 15:10:58 -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.10.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 15:10:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593209485; 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=NZ0vZShxg5Utl0JFwccrrxPAovnsYMFb8bomL9Akz2E=; b=CbRRjweBWwIzlrUTjvKSzUk2w8KqVzIaIZ30WQK+GfBWSdyR+wdtH169iBKZuL+C3shpi7 IdMiXu/rKTZRVn4NQzlBfmoifUEpIyglKbXcbluVzs1E7crZ5Dgdsem/5Ce0TLPRNv+LxC N2opr67ifRb4ZR2bvDi0QpIZVYh4G1s= X-MC-Unique: kyje8yTxNieWmkE_wlAYaw-1 X-MC-Unique: 13yLDHrhMj2jH-uedpk0pA-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=NZ0vZShxg5Utl0JFwccrrxPAovnsYMFb8bomL9Akz2E=; b=qXQIXpdsZZKXmg3s8c/TBk251Mug2lTpSYn/mmp02DKgDd2PGe/toDWELtv69+WbHv 5RrQtE+jcFri71Md62H8YaKN6CXcqBf4BQPIQrCHEMhC+ZGPYtj5cQ2c+GCX3DYnPAWx N0ZS7aehLcQp9vgVvhiBK/U6Bn5Jw4KdQ+9awtMcma+1lHHpyFhrOvF5uE9f4womFw+x UFIkqKZ+lwFpagAmyT/n1I7fD/iUbSs+psqT86moaP9InxMeuJ+FBE+VBu0dEvSkCMqd I/skRmkmnCHdoTBDqoPMreVMH3ABeayU+8ipc6xDI9f8SU/BI0RWW0ELg2lkFd8rCdMR DLqg== X-Gm-Message-State: AOAM533+MwcgTtcjQHU/1sqT0LOzpZ+GgcPo47UA11UovpK10Nd8YBWI KGVN7h+LiIO+dLjHaKdOu+YaTML7 X-Google-Smtp-Source: ABdhPJw9Nw+39Vsw/k9Z4u27Jng5x/llPoh6kUDAm36uJ1OgMbV4wC4rlCEz86Kfsa31D51nLS4OZw== X-Received: by 2002:aed:3fac:: with SMTP id s41mr5005535qth.86.1593209457470; Fri, 26 Jun 2020 15:10:57 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 3/7] virsh-domain.c: modernize virshVcpuinfoInactive() Date: Fri, 26 Jun 2020 19:10:40 -0300 Message-Id: <20200626221044.631749-4-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.4 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.14 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" Use g_auto* in the string and in the bitmap. Remove the cleanup label since it's now unneeded. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- tools/virsh-domain.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 085b88b097..23d41a4ddf 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -6886,16 +6886,15 @@ virshVcpuinfoInactive(vshControl *ctl, int maxcpu, bool pretty) { - unsigned char *cpumaps =3D NULL; + g_autofree unsigned char *cpumaps =3D NULL; size_t cpumaplen; int ncpus; - virBitmapPtr vcpus =3D NULL; + g_autoptr(virBitmap) vcpus =3D NULL; ssize_t nextvcpu =3D -1; - bool ret =3D false; bool first =3D true; =20 if (!(vcpus =3D virshDomainGetVcpuBitmap(ctl, dom, true))) - goto cleanup; + return false; =20 cpumaplen =3D VIR_CPU_MAPLEN(maxcpu); cpumaps =3D vshMalloc(ctl, virBitmapSize(vcpus) * cpumaplen); @@ -6903,7 +6902,7 @@ virshVcpuinfoInactive(vshControl *ctl, if ((ncpus =3D virDomainGetVcpuPinInfo(dom, virBitmapSize(vcpus), cpumaps, cpumaplen, VIR_DOMAIN_AFFECT_CONFIG)) < 0) - goto cleanup; + return false; =20 while ((nextvcpu =3D virBitmapNextSetBit(vcpus, nextvcpu)) >=3D 0) { if (!first) @@ -6918,15 +6917,10 @@ virshVcpuinfoInactive(vshControl *ctl, if (virshVcpuinfoPrintAffinity(ctl, VIR_GET_CPUMAP(cpumaps, cpumaplen, = nextvcpu), maxcpu, pretty) < 0) - goto cleanup; + return false; } =20 - ret =3D true; - - cleanup: - virBitmapFree(vcpus); - VIR_FREE(cpumaps); - return ret; + return true; } =20 =20 --=20 2.26.2 From nobody Thu Mar 28 12:31:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1593209473; cv=none; d=zohomail.com; s=zohoarc; b=SvUon8NMyp5dt4MfyJH7BAcZVDgmLlHKcU3CcOSSF5Jtt3K7t9yXJSJazG8S6jx/xbsxl+G5VVuVhdXFkMYJGmPCBLdYhJ3sWclh/pHOWaqgMRU4bn0hh+6X7krWRqHNti+SKvbdL0SyNCaFdrbyqBitFGg+OyqJKe42jcGWYQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593209473; 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=tDwtzMZlQHXwMMbLqN+IrkaqeO/9dejfByqcoxwzzPg=; b=UJq/f+Xakv2U/khlsZCqfcVSOLgr6usMeNFR590CYO/elF/PO0d/z6XCZlai38PjvMFXQIr6K6QMX+367d8pyjeFSgWoZTN2toHHgIFYkbIndxhbkN5Bi+NGYp+WtoTdvyY2KZrKm85da3vrdNsv7fyhyDvBkmDTyZEpSUgqYaY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1593209473081137.05235927221122; Fri, 26 Jun 2020 15:11:13 -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-475-trwxQxRIPvK0S0Yd2NDKow-1; Fri, 26 Jun 2020 18:11:09 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ED495804002; Fri, 26 Jun 2020 22:11:03 +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 CB40919D61; Fri, 26 Jun 2020 22:11:03 +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 51DB81809543; Fri, 26 Jun 2020 22:11:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05QMB2pr015674 for ; Fri, 26 Jun 2020 18:11:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id A7F8520110C7; Fri, 26 Jun 2020 22:11:02 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9F474201ECD3 for ; Fri, 26 Jun 2020 22:11:02 +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 16D44185A78B for ; Fri, 26 Jun 2020 22:11:02 +0000 (UTC) Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-181-ReoO0atNMkWdWzcubLnUpg-1; Fri, 26 Jun 2020 18:10:59 -0400 Received: by mail-qk1-f196.google.com with SMTP id k18so10229305qke.4 for ; Fri, 26 Jun 2020 15:10:59 -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.10.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 15:10:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593209471; 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=tDwtzMZlQHXwMMbLqN+IrkaqeO/9dejfByqcoxwzzPg=; b=cfDog/9zcs64fqySecFL8ZWXXCq34SnJa/pt3sZrSVrXtjI09rH7U/mjetrDkHZ9lGA9+L u4rj10Oc195AftIRiGjrtdF6lAiA8ZGvQUg3vG0cNZB2ug9D1XoknxNZGOjQTpvKYKunXm gElPqJyg6KXEZE0qUJ+6Vjt1gNFD6eY= X-MC-Unique: trwxQxRIPvK0S0Yd2NDKow-1 X-MC-Unique: ReoO0atNMkWdWzcubLnUpg-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=tDwtzMZlQHXwMMbLqN+IrkaqeO/9dejfByqcoxwzzPg=; b=n661rA2URbDHj5A9j4lsGt7w1SRzrrR/00SfPlB59KkUzaQsV9ppNlE0KNxsNXxZ0O 5Uoa2rEpNHSdl9AEkZcEbW0H5YDKva/3IdCFZwx67Xi7Rps+zCmRIhzjvIxrRP7K8EzR ZkpwCHtR5DVytjiPY7vFO0altlVsM4MsivifvUdku5rmjEZeStwtn29ixDsNPkQlz3LJ k+sRkwcFFQCxTEUdqg0g4yxDf2cCKGpr1zex4ZE6iaG4fXI0f/Xe73PCQ3znKSyDJ6Qb 6AF/4IL72fStr9YQObq+tr1IGgM72G2exlftXhcy+bDmCM/IugVDlNLP9+GzY8jnVk70 O8Xw== X-Gm-Message-State: AOAM532RLzP/ksd0KR8J0Udn9T0hjIYn09Ck6XVgcP51wBBLn1batnWS CmToHgA83zEMlYdMQPS1PuyaG9kz X-Google-Smtp-Source: ABdhPJxoS6t01F3TvOjY5e3atI6LmPVYfjWxR0LHlauuhLaoARLRCPdza1DprtEZX75lhUMu6uNXOw== X-Received: by 2002:ae9:c006:: with SMTP id u6mr4762344qkk.375.1593209458855; Fri, 26 Jun 2020 15:10:58 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 4/7] virsh-domain.c: modernize cmdVcpuinfo() Date: Fri, 26 Jun 2020 19:10:41 -0300 Message-Id: <20200626221044.631749-5-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.4 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.84 on 10.5.11.23 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" Use g_auto* pointers to avoid the need for the cleanup label. The type of the pointer 'virDomainPtr dom' was changed to its alias 'virshDomainPtr' to allow the use of g_autoptr(). Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- tools/virsh-domain.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 23d41a4ddf..cfae42eda9 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -6928,12 +6928,11 @@ static bool cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd) { virDomainInfo info; - virDomainPtr dom; - virVcpuInfoPtr cpuinfo =3D NULL; - unsigned char *cpumaps =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; + g_autofree virVcpuInfoPtr cpuinfo =3D NULL; + g_autofree unsigned char *cpumaps =3D NULL; int ncpus, maxcpu; size_t cpumaplen; - bool ret =3D false; bool pretty =3D vshCommandOptBool(cmd, "pretty"); int n; virshControlPtr priv =3D ctl->privData; @@ -6942,10 +6941,10 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd) return false; =20 if ((maxcpu =3D virshNodeGetCPUCount(priv->conn)) < 0) - goto cleanup; + return false; =20 if (virDomainGetInfo(dom, &info) !=3D 0) - goto cleanup; + return false; =20 cpuinfo =3D vshMalloc(ctl, sizeof(virVcpuInfo)*info.nrVirtCpu); cpumaplen =3D VIR_CPU_MAPLEN(maxcpu); @@ -6955,13 +6954,12 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd) cpuinfo, info.nrVirtCpu, cpumaps, cpumaplen)) < 0) { if (info.state !=3D VIR_DOMAIN_SHUTOFF) - goto cleanup; + return false; =20 vshResetLibvirtError(); =20 /* for offline VMs we can return pinning information */ - ret =3D virshVcpuinfoInactive(ctl, dom, maxcpu, pretty); - goto cleanup; + return virshVcpuinfoInactive(ctl, dom, maxcpu, pretty); } =20 for (n =3D 0; n < ncpus; n++) { @@ -6979,19 +6977,13 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd) =20 if (virshVcpuinfoPrintAffinity(ctl, VIR_GET_CPUMAP(cpumaps, cpumap= len, n), maxcpu, pretty) < 0) - goto cleanup; + return false; =20 if (n < (ncpus - 1)) vshPrint(ctl, "\n"); } =20 - ret =3D true; - - cleanup: - VIR_FREE(cpumaps); - VIR_FREE(cpuinfo); - virshDomainFree(dom); - return ret; + return true; } =20 /* --=20 2.26.2 From nobody Thu Mar 28 12:31:36 2024 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=1593209493; cv=none; d=zohomail.com; s=zohoarc; b=mIs6Vvx83sjvr+KUcJ/q9g38xccHTMpDbXTe4kQMPafvqKtdaMkkiSOxAOyr3xEVJbjh+fwtSAyseYPvmu1rQl4xBfo1ZX7Sif10YfeG6wL9h0PYvWV7//2oBf0oPG6mAY2cFL+jh3qM05L3pVXPs7ZmjFabACBYOvrHN0P+7P4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593209493; 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=Dwk1q8zU5qgN5Xih1CGdig4KvEQdHCCxv6On2z5sztk=; b=bjLakuijncH6JF0aIgEtn5Y9xZFnMgsxdwQA/Fy9PTzDwXs7gwnsxq6YQIPpR8udxn4FQPGRuXpy/mEuYQPJnsR42n97Ej64HQD1qPOLntmQhqwo3bftIz2/e3z4AKImNfv6mvEeGkpS/ahIBOhxB5/xj2JXK2ChoZxVWb8VDHc= 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 1593209493254343.9691770311397; Fri, 26 Jun 2020 15:11:33 -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-268-ByY4lJJ_MOWqP2X-QABYjQ-1; Fri, 26 Jun 2020 18:11:29 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EAAE3BFD1; Fri, 26 Jun 2020 22:11: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 82E46612BA; Fri, 26 Jun 2020 22:11: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 57418875BF; Fri, 26 Jun 2020 22:11:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05QMB3wn015694 for ; Fri, 26 Jun 2020 18:11:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6CCE020110C7; Fri, 26 Jun 2020 22:11:03 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 68F6B20182A5 for ; Fri, 26 Jun 2020 22:11:03 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.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 4EE6C8007C8 for ; Fri, 26 Jun 2020 22:11:03 +0000 (UTC) Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-442-HHqihAQSOnC8OkmU2bWexA-1; Fri, 26 Jun 2020 18:11:01 -0400 Received: by mail-qk1-f176.google.com with SMTP id 80so10231458qko.7 for ; Fri, 26 Jun 2020 15:11:00 -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.10.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 15:10:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593209492; 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=Dwk1q8zU5qgN5Xih1CGdig4KvEQdHCCxv6On2z5sztk=; b=dYIxfako9NcEyaCtFJHSkytiELhF+sVw785drKHE1lFEWPED4owstChjFt1s8Un0UkWcp6 hv9ToIREhJK+YLOX13a4Atek+9c1Nu2z7qXFbEvDJoL2rNKg2vTULzDzo/B1kzuCy+crD6 6ucKjvs3753oomo5GRxkUy7ANNSL3mc= X-MC-Unique: ByY4lJJ_MOWqP2X-QABYjQ-1 X-MC-Unique: HHqihAQSOnC8OkmU2bWexA-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=Dwk1q8zU5qgN5Xih1CGdig4KvEQdHCCxv6On2z5sztk=; b=hPvvJ8Xn45MFAeYnwNQpbMIyHEc/DUsPJv59KjJ3kYdAVmNRTXHzZLcTTvt/YSpTq5 ZvBtThSq2aCr4E7ibB/OQ9rfOMbx4HGgW0n5D+t9TBmJXG6YOd9ykPI8shjt1LDlNm+L 6AYTsfQ4F7HnG1YqooEY+9uvMk8ymkFKH6gI+iCJGGU6I6dL/zl2XlSS18V+mfVIzsC+ f2kjV1tFU2TfqANcXlocVkONele4rrvHPDRR+RW2PD1IZQQiliRKe3LSLArSk8GzInP2 9dvJMX/lC66cjZm2naWESEnCEUKDPNA9T/3nnP5bgEtD+gFGa4ej3KQOL2JK/D8OI2we 4FIQ== X-Gm-Message-State: AOAM532O3wo6eL+j7+r57o9GsEdPTVQQreERrfYzFv0sij7zdmr9uP/3 Bwa+9SMhP1fWZLKmEQntaF/qnnFH X-Google-Smtp-Source: ABdhPJw5wYcCZz8U7H6dIH7LLU3/oHWPZWDm49gjdKbP3qGia4z/2KBjKBeBzmKcyMlDSKPK4AtxpQ== X-Received: by 2002:a05:620a:2282:: with SMTP id o2mr4768193qkh.402.1593209460315; Fri, 26 Jun 2020 15:11:00 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 5/7] virhostcpu.c: refactor virHostCPUParseCountLinux() Date: Fri, 26 Jun 2020 19:10:42 -0300 Message-Id: <20200626221044.631749-6-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.4 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.14 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" This function reads the string in sysfspath/cpu/present and parses it manually to retrieve the number of present CPUs. virHostCPUGetPresentBitmap() reads and parses the same file, using a more robust parser via virBitmapParseUnlimited(), but returns a bitmap. Let's drop all the manual parsing done here and simply return the size of the resulting bitmap from virHostCPUGetPresentBitmap(). Given that no more parsing is being done manually in the function, rename it to virHostCPUCountLinux(). Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/util/virhostcpu.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index 3023bca831..615250d05d 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -856,33 +856,17 @@ virHostCPUGetStatsLinux(FILE *procstat, } =20 =20 -/* Determine the number of CPUs (maximum CPU id + 1) from a file containing - * a list of CPU ids, like the Linux sysfs cpu/present file */ +/* Determine the number of CPUs (maximum CPU id + 1) present in + * the host. */ static int -virHostCPUParseCountLinux(void) +virHostCPUCountLinux(void) { - char *str =3D NULL; - char *tmp; - int ret =3D -1; + g_autoptr(virBitmap) present =3D virHostCPUGetPresentBitmap(); =20 - if (virFileReadValueString(&str, "%s/cpu/present", SYSFS_SYSTEM_PATH) = < 0) + if (!present) return -1; =20 - tmp =3D str; - do { - if (virStrToLong_i(tmp, &tmp, 10, &ret) < 0 || - !strchr(",-", *tmp)) { - virReportError(VIR_ERR_NO_SUPPORT, - _("failed to parse %s"), str); - ret =3D -1; - goto cleanup; - } - } while (*tmp++ && *tmp); - ret++; - - cleanup: - VIR_FREE(str); - return ret; + return virBitmapSize(present); } #endif =20 @@ -1031,7 +1015,7 @@ int virHostCPUGetCount(void) { #if defined(__linux__) - return virHostCPUParseCountLinux(); + return virHostCPUCountLinux(); #elif defined(__FreeBSD__) || defined(__APPLE__) return virHostCPUGetCountAppleFreeBSD(); #else --=20 2.26.2 From nobody Thu Mar 28 12:31:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.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 207.211.31.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=1593209484; cv=none; d=zohomail.com; s=zohoarc; b=Ab6boAmIidlbh99YuU6t0uktM68jcRxmIWeslDANToxYZto4kCFcxdm0kMt0biwDG27p4LcjJCWVtHBwDtsRdIQLawsveu4qJaZgtjEhatj6AetZr3XlouWLWzxZRlPdbyrzyj45mbn5QsD7MuaCly4IDNG8GYsige2uHkI/e/I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593209484; 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=k5xHGan138AcKXcpqBja9m+giQvmODWGp8LpDevEMIM=; b=KWdsgQ+nZ65zT/HHSxfeLQodU91DtMvtcbvb9cHXludq6Q5P+U3RgT7KcEPCe/NJhxinpeiXZOM3qxJDWoflGyxLlwk+rwx/ZzT2fegYqd9mEfvsbrDgcMSJMvJc+JFbaQd4STyV+W+NIU10CnTGT3Rt5eNgVX2igS1GjZzuk8M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.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 [207.211.31.120]) by mx.zohomail.com with SMTPS id 1593209484116122.55272633769096; Fri, 26 Jun 2020 15:11:24 -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-273-QicSVuMXO6i0P-qIANhLsw-1; Fri, 26 Jun 2020 18:11:20 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 07A121005513; Fri, 26 Jun 2020 22:11:15 +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 D8B4119C58; Fri, 26 Jun 2020 22:11:14 +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 AA1F8104903; Fri, 26 Jun 2020 22:11:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05QMB56o015737 for ; Fri, 26 Jun 2020 18:11:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7D0F820110C7; Fri, 26 Jun 2020 22:11:05 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 78F312029F6F for ; Fri, 26 Jun 2020 22:11:05 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (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 5E1BE185A797 for ; Fri, 26 Jun 2020 22:11:05 +0000 (UTC) Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-478-sx-etTTKPgC5oP0kevbVJA-1; Fri, 26 Jun 2020 18:11:02 -0400 Received: by mail-qt1-f193.google.com with SMTP id e12so8640374qtr.9 for ; Fri, 26 Jun 2020 15:11:02 -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.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 15:11:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593209482; 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=k5xHGan138AcKXcpqBja9m+giQvmODWGp8LpDevEMIM=; b=Dkf2pvxvKdvEl+NlO482nngwwqJAF7QHrZ0cV5JiZbwJdNanMQeYCq3AfiZMMIVPKUxHN7 7JkAdLBuxe0/vvd+Ge+yfn+T3tUmicSJONOu/SR+9385XbV72ueKGIOML6dZv/qPaKkLMR eFnogmVMHPjdytRX2z6jI40ueH2v7JY= X-MC-Unique: QicSVuMXO6i0P-qIANhLsw-1 X-MC-Unique: sx-etTTKPgC5oP0kevbVJA-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=k5xHGan138AcKXcpqBja9m+giQvmODWGp8LpDevEMIM=; b=f5ITnsZHm48Y7YzGnAwCy8SuJgNsc125MrOvLn/zHVSQU8Y36VGSg1qmJrRMm1HP7+ cTS0Zt3eDaxWirzom/BnL1XERQzyqim+TEyxOYmS6a7yA4jxbcPg82iE/nU3kpLncT+n GePa4YnSqRQD0pn/mkK0Grw1Dp3AJZD8FZaj4K5aEFJlHdE+G/XQoA1Qei+KrE5CroaS 0XBwsa7BhzEhs+EPjT5P7OqN2IPoAVOdHnjqOkfqLrveNjsQ0kgcMSaSYsafI/S0tQnJ CZyTKtjll7I+DD8fAIbDpAHZJw30yHRnZsmMLWeIpQKp87Zc3DYg/h//QnZmCGboFUHZ 2sXQ== X-Gm-Message-State: AOAM5303LVbTP8PBT6pD9sVHL9vHge1s1w2id3IsXZqhk8UseOapJD9q HdiCowO5osadkWuRJBU78l0z070p X-Google-Smtp-Source: ABdhPJw+pSt+wQx2QTslSwj51WvYoEzE0fIgg1hsLM0HWQoVP1/ahOal/S+lBgNRR9tLcWXfYARdVw== X-Received: by 2002:ac8:4892:: with SMTP id i18mr5154917qtq.344.1593209461860; Fri, 26 Jun 2020 15:11:01 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 6/7] virhostcpu.c: introduce virHostCPUGetAvailableCPUsBitmap() Date: Fri, 26 Jun 2020 19:10:43 -0300 Message-Id: <20200626221044.631749-7-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.4 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.84 on 10.5.11.23 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 idea is to have a function that calls virHostCPUGetOnlineBitmap() but, instead of returning NULL if the host does not have CPU offlining capabilities, fall back to a bitmap containing all present CPUs. Next patch will use this helper in two other places. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/libvirt_private.syms | 1 + src/util/virhostcpu.c | 30 ++++++++++++++++++++++++++++++ src/util/virhostcpu.h | 2 ++ 3 files changed, 33 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index ae0e253ab9..f120e200cb 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2211,6 +2211,7 @@ virHookPresent; =20 =20 # util/virhostcpu.h +virHostCPUGetAvailableCPUsBitmap; virHostCPUGetCount; virHostCPUGetInfo; virHostCPUGetKVMMaxVCPUs; diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index 615250d05d..8ca67e357d 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -1099,6 +1099,36 @@ virHostCPUGetMap(unsigned char **cpumap, } =20 =20 +/* virHostCPUGetAvailableCPUsBitmap(): + * + * Returns a virBitmap object with all available host CPUs. + * + * This is a glorified wrapper of virHostCPUGetOnlineBitmap() + * that, instead of returning NULL when 'ifndef __linux__' and + * the caller having to handle it outside the function, returns + * a virBitmap with all the possible CPUs in the host, up to + * virHostCPUGetCount(). */ +virBitmapPtr +virHostCPUGetAvailableCPUsBitmap(void) +{ + g_autoptr(virBitmap) bitmap =3D NULL; + + if (!(bitmap =3D virHostCPUGetOnlineBitmap())) { + int hostcpus; + + if ((hostcpus =3D virHostCPUGetCount()) < 0) + return NULL; + + if (!(bitmap =3D virBitmapNew(hostcpus))) + return NULL; + + virBitmapSetAll(bitmap); + } + + return g_steal_pointer(&bitmap); +} + + #if HAVE_LINUX_KVM_H && defined(KVM_CAP_PPC_SMT) =20 /* Get the number of threads per subcore. diff --git a/src/util/virhostcpu.h b/src/util/virhostcpu.h index 48b1431ca4..d07503857e 100644 --- a/src/util/virhostcpu.h +++ b/src/util/virhostcpu.h @@ -43,6 +43,8 @@ int virHostCPUGetStats(int cpuNum, bool virHostCPUHasBitmap(void); virBitmapPtr virHostCPUGetPresentBitmap(void); virBitmapPtr virHostCPUGetOnlineBitmap(void); +virBitmapPtr virHostCPUGetAvailableCPUsBitmap(void); + int virHostCPUGetCount(void); int virHostCPUGetThreadsPerSubcore(virArch arch) G_GNUC_NO_INLINE; =20 --=20 2.26.2 From nobody Thu Mar 28 12:31:36 2024 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 Reviewed-by: Michal Privoznik ---------------------- 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