From nobody Fri Apr 26 18:14:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1631712090; cv=none; d=zohomail.com; s=zohoarc; b=GW18/BRPt0AnGzFlqh3RMQrl1fvA/kugb6FN0ji0jWZINwj1IE9hScf0iBOflEd167yza0n3/pcOu36zMIwGlyIXZ+TDng08xeg8Kk7KSGFE1mFnZq4sgBZ/byHKVoA4G4Xmu4mtcV6no+q/PYTARxggjWoMiwAaeP/9v3r3Wgg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631712090; 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=pdzn82iHDOyLq26lV1SMzHQaGtu4eRI31dxKONndd6Q=; b=QuwqQMp8EfpXl0snyO+ESlvpGyocQmKoEcM6EW/fFtVe6HfPyoSjUbqnulmVFr91xdvkOzQ94v35vWrOuOPsWnRqINNFY7vKKxUcTK9utYvN8jgYTHFR5GqT72DccLq1OjWuA6Ga1YVBpO0fm3Q8PJEKC8y/2QViUdpwm0+dl8g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1631712090489443.2610463149132; Wed, 15 Sep 2021 06:21:30 -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-483-TwwOksxCPx21ZWLxrGH7RA-1; Wed, 15 Sep 2021 09:21:27 -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 BAE60802C8F; Wed, 15 Sep 2021 13:21:21 +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 C1BE57A5CF; Wed, 15 Sep 2021 13:21:20 +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 EC1C7180142F; Wed, 15 Sep 2021 13:21:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18FDLFhx016290 for ; Wed, 15 Sep 2021 09:21:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id CEC14781ED; Wed, 15 Sep 2021 13:21:15 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3239777F29 for ; Wed, 15 Sep 2021 13:21:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631712089; 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=pdzn82iHDOyLq26lV1SMzHQaGtu4eRI31dxKONndd6Q=; b=DcUx7U/+oHh62usdi/c5aeSG5UlnVuLOKaa++N7f/ML0zU9yktF5G7pEKI4CuzdakFjIhf ZlWoud3ZDI4iWGeda7p/p1LVxtf+htI/TjXrdELgVHU8tq9fryBgkwvG2UVMD1MeuHy0R5 s3AblS/ffUMa4CGHpNZ7j0AFJEoTJfI= X-MC-Unique: TwwOksxCPx21ZWLxrGH7RA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/2] virshDomainGetVcpuBitmap: Return bitmap when taking the fallback path Date: Wed, 15 Sep 2021 15:21:11 +0200 Message-Id: <15d20065605282564726c494843f0f7b3f724645.1631711739.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.13 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: 1631712091630100001 Content-Type: text/plain; charset="utf-8" In case the specific VCPU states are not present in the XML we were taking a fallback code path just noting that all cpus of the VM are enabled. This was broken by a mistake in a recent refactor where a 'goto cleanup' was mistakenly replaced by a 'return NULL'. This broke reporting of cpus and also caused a memory leak. Return the fallback cpu map. Fixes: bd1f40fe7d4 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2004429 Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko Reviewed-by: Pavel Hrdina --- tools/virsh-domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index e5bd1fdd75..f5a3e1accc 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -6710,7 +6710,7 @@ virshDomainGetVcpuBitmap(vshControl *ctl, for (i =3D 0; i < curvcpus; i++) ignore_value(virBitmapSetBit(ret, i)); - return NULL; + return ret; } for (i =3D 0; i < nnodes; i++) { --=20 2.31.1 From nobody Fri Apr 26 18:14:33 2024 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=1631712155; cv=none; d=zohomail.com; s=zohoarc; b=FCgl59UyYszE1PJ0UN56fTMIvswx5splnyg6zGQXgao0vgHyHZKwtcKgC4oFCoHT7z217E6IJhSBd5NCLaW+PkF3u8PIGBw08NZ32qaYZP+NbwrzOhOHpts1KO5y20rSnsIAJzHLgbJgnSbFUnvhosYdeh9VQ+xTyl7sdbIBsWY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631712155; 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=Fp9tOAyS9ZoYLesEFFd1TvkeNgUcy3tpGIaC3Q48XYM=; b=ZwnaRqnIejdjsiQuVytWSmlCWLLjttnFyNRmi5iVrQSxwdIhKAUfdUCKclFs+tQHMKhhSdNpUszopT9q1c1Ukh86Qpg9IhqelQ9rvyc5+gXr8UDfNCEqpuHtbtl/bn8U48rcGL0VFnOmfP+0KJyMl2WaARLCohFPwxbdTFDwJFU= 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 1631712155991142.04050581521562; Wed, 15 Sep 2021 06:22:35 -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-312-Cg2zBMNJM8SuHE_SS9h0yQ-1; Wed, 15 Sep 2021 09:21:43 -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 2F2A283DD17; Wed, 15 Sep 2021 13:21:37 +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 09A095E253; Wed, 15 Sep 2021 13:21:37 +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 C535C180142F; Wed, 15 Sep 2021 13:21:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18FDLGrX016301 for ; Wed, 15 Sep 2021 09:21:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id E830277F29; Wed, 15 Sep 2021 13:21:16 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 44C6D7A5CF for ; Wed, 15 Sep 2021 13:21:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631712155; 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=Fp9tOAyS9ZoYLesEFFd1TvkeNgUcy3tpGIaC3Q48XYM=; b=ciPfFdly4B0WreBhWvGivrxOm7oPECgZO9rYPx9t4XHfBGOx9owO7Dqko2OcObdujmclcN 4MsmTVQa17IppTUEddols6ZFZXaHdUpRnhzab6baAQ/J9nMzz3QXezAyeqdCsRHjgUKMti M2P27cdnAsv36blDj1tf/G3rKfyav5A= X-MC-Unique: Cg2zBMNJM8SuHE_SS9h0yQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/2] virshDomainGetVcpuBitmap: Refactor cleanup Date: Wed, 15 Sep 2021 15:21:12 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.14 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: 1631712159108100001 Content-Type: text/plain; charset="utf-8" Rename the temp variable that is being returned and use automatic pointer clearing for it. Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko Reviewed-by: Pavel Hrdina --- tools/virsh-domain.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index f5a3e1accc..4d328d2174 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -6677,7 +6677,7 @@ virshDomainGetVcpuBitmap(vshControl *ctl, bool inactive) { unsigned int flags =3D 0; - virBitmap *ret =3D NULL; + g_autoptr(virBitmap) cpumap =3D NULL; g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; g_autofree xmlNodePtr *nodes =3D NULL; @@ -6703,14 +6703,14 @@ virshDomainGetVcpuBitmap(vshControl *ctl, if (curvcpus =3D=3D 0) curvcpus =3D maxvcpus; - ret =3D virBitmapNew(maxvcpus); + cpumap =3D virBitmapNew(maxvcpus); if ((nnodes =3D virXPathNodeSet("/domain/vcpus/vcpu", ctxt, &nodes)) <= =3D 0) { /* if the specific vcpu state is missing provide a fallback */ for (i =3D 0; i < curvcpus; i++) - ignore_value(virBitmapSetBit(ret, i)); + ignore_value(virBitmapSetBit(cpumap, i)); - return ret; + return g_steal_pointer(&cpumap); } for (i =3D 0; i < nnodes; i++) { @@ -6723,16 +6723,15 @@ virshDomainGetVcpuBitmap(vshControl *ctl, continue; if (STREQ(online, "yes")) - ignore_value(virBitmapSetBit(ret, vcpuid)); + ignore_value(virBitmapSetBit(cpumap, vcpuid)); } - if (virBitmapCountBits(ret) !=3D curvcpus) { + if (virBitmapCountBits(cpumap) !=3D curvcpus) { vshError(ctl, "%s", _("Failed to retrieve vcpu state bitmap")); - virBitmapFree(ret); return NULL; } - return ret; + return g_steal_pointer(&cpumap); } --=20 2.31.1