From nobody Thu May 2 06:55:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1568637942; cv=none; d=zoho.com; s=zohoarc; b=htGt2tU3LHFZkDXnBafD0P8oQN2MJgth1CApT7v2SgoIfbCdu0uDRcGMKVM5vT3ttJC+Er34MlTZIHARxkmel1FJkxwo5iV136oQALwPveSW6T/XVZ5Ed3UHMZJBTnsV9WhpojWaT4WPyPHJqLbjJJjXBHG2GtH49EWTutozvas= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568637942; 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:ARC-Authentication-Results; bh=Alu4aJ70TjmcRkd5CilOc/indw8jUx7md3j+6tVhVzs=; b=QCN2l2ESwGIu+bx97LK5Mu91rfIJuvAYK8ee4kLsiadDhE7wxZHQCnw6K2DaU7/IG4IfkjZtWg1h6IxxI3uWOLjjlGjEEWaWjnAWEsXK1LJMF+MV9TYDSejQFWeKjhv000rtXDhkbur0yod2M8s9SosLsV65FRSYEfokGLk2c7g= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1568637942705181.0002490355339; Mon, 16 Sep 2019 05:45:42 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F373B1DD3; Mon, 16 Sep 2019 12:45:40 +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 C09BC6012A; Mon, 16 Sep 2019 12:45:40 +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 47DB34E58A; Mon, 16 Sep 2019 12:45:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8GCjcxf026027 for ; Mon, 16 Sep 2019 08:45:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4D6F55D9E1; Mon, 16 Sep 2019 12:45:38 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id C3F6E5D9DC for ; Mon, 16 Sep 2019 12:45:37 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 16 Sep 2019 14:45:32 +0200 Message-Id: <11842e9b533e98da289e691af0c9b8e6328e8eba.1568637841.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/5] virsh: Allow using VIR_AUTOPTR for releasing virDomainPtr in virsh 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.71]); Mon, 16 Sep 2019 12:45:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" I opted to alias the 'virDomainType' to 'virshDomain' so that it's obvious in all cases that this is a virsh-only construct. This is also somewhat consistent with virsh's use of 'virshDomainFree' wrapper for the freeing function which actually accepts NULL. Signed-off-by: Peter Krempa Reviewed-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- tools/virsh-util.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/virsh-util.h b/tools/virsh-util.h index 9005aa9d36..7fdd39dd12 100644 --- a/tools/virsh-util.h +++ b/tools/virsh-util.h @@ -39,8 +39,11 @@ virshCommandOptDomain(vshControl *ctl, const vshCmd *cmd, const char **name); +typedef virDomain virshDomain; + void virshDomainFree(virDomainPtr dom); +VIR_DEFINE_AUTOPTR_FUNC(virshDomain, virshDomainFree); void virshDomainCheckpointFree(virDomainCheckpointPtr chk); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 06:55:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1568637950; cv=none; d=zoho.com; s=zohoarc; b=Q4cQR1fqWKAEJbENJ5z6BpwCaxLhOHq8xfSY8YEcB+BoQgFihqSC6BE3gkJEMGeWz1Ny6hzQKCV0pomxmZtEJGSPsmHexzLfNrGd6kNWV6Im9+sK9tX5KFBmW6q391sfMgE4+N8Luhi/ooy+6+dPoT/oAXyESepketLXCrThOws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568637950; 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:ARC-Authentication-Results; bh=yPdqDuwLu2CU40uuWo2AMwVXriSE33MrqOHNgrC785A=; b=W2HFKx6Z6sJIx1wRBpPfFj3UZVUGK23+taRnuPcZJsLp52K6rB2BDuD9Ie60ysYLCUbE89OjsnIU/4uBISCn6yO/924++9fDP0Gp/TSvKs56m0U0Sm90kYVdLpqFETwRvV25xxb5MaA5UJrBnHhEHZEGuNwKSyki8gkrj2VYnao= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1568637950874464.63611527447995; Mon, 16 Sep 2019 05:45:50 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 315AB76FF; Mon, 16 Sep 2019 12:45:49 +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 0D7B21001B11; Mon, 16 Sep 2019 12:45:49 +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 C6ADD4EA64; Mon, 16 Sep 2019 12:45:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8GCjdJX026032 for ; Mon, 16 Sep 2019 08:45:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1A44E5D9E1; Mon, 16 Sep 2019 12:45:39 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 985C95D9DC for ; Mon, 16 Sep 2019 12:45:38 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 16 Sep 2019 14:45:33 +0200 Message-Id: <764245db9d26a21494f00b09e7d2a686c0f508be.1568637841.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/5] virsh: demonstrate use of VIR_AUTOPTR(virshDomain) on 'send-process-signal' 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 16 Sep 2019 12:45:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Refactor the command code to use the new type. Signed-off-by: Peter Krempa Reviewed-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- tools/virsh-domain.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 3d26e81b22..9015c43ba2 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -8834,8 +8834,7 @@ static int getSignalNumber(vshControl *ctl, const cha= r *signame) static bool cmdSendProcessSignal(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; - bool ret =3D false; + VIR_AUTOPTR(virshDomain) dom =3D NULL; const char *signame; long long pid_value; int signum; @@ -8844,24 +8843,20 @@ cmdSendProcessSignal(vshControl *ctl, const vshCmd = *cmd) return false; if (vshCommandOptLongLong(ctl, cmd, "pid", &pid_value) < 0) - goto cleanup; + return false; if (vshCommandOptStringReq(ctl, cmd, "signame", &signame) < 0) - goto cleanup; + return false; if ((signum =3D getSignalNumber(ctl, signame)) < 0) { vshError(ctl, _("malformed signal name: %s"), signame); - goto cleanup; + return false; } if (virDomainSendProcessSignal(dom, pid_value, signum, 0) < 0) - goto cleanup; - - ret =3D true; + return false; - cleanup: - virshDomainFree(dom); - return ret; + return true; } /* --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 06:55:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1568637944; cv=none; d=zoho.com; s=zohoarc; b=HXy+oiA3ylQI6wqNqr36TSessgIxzCtg9khNL6CZZsYuaElX3LydsxKdreSBa5XXLviX1RVSzsduwluVpMfk9F9siZvnlueJFXNrOorSl5D1ZwCVaNC4QtxkhDtKn0ZuqMsywiasT3OnGv+xu/cbIq5fxTBYdvrfQfB9KGicDAc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568637944; 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:ARC-Authentication-Results; bh=IsqkCTftS51ELCSF4EhN7uM5xsceqWG0vQK4WWvb1F0=; b=LC/biEATAMK5Fz7kusuYUo7VJvVF6WncZEkA4M1rkhsOrXTe7MVLAXDlt06JZEEkx4y5BnHfTDCfLwRUW0VPxbJCmnFWDQJjINzmvqshuICLRsLupTGKCO4atEAMm9SPkUFpELYv/iBm5YUuHqu7O6BkCPHQpsDsygGl8td8j38= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 156863794406242.165875424048295; Mon, 16 Sep 2019 05:45:44 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 56FAF86E86F; Mon, 16 Sep 2019 12:45:42 +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 2A330196AE; Mon, 16 Sep 2019 12:45:42 +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 E7E414E58B; Mon, 16 Sep 2019 12:45:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8GCjdxk026042 for ; Mon, 16 Sep 2019 08:45:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id DDD2F5D9E1; Mon, 16 Sep 2019 12:45:39 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6812F5D9DC for ; Mon, 16 Sep 2019 12:45:39 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 16 Sep 2019 14:45:34 +0200 Message-Id: <17b3e667b00e7311b0d1d59a527041b3f4efb271.1568637841.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/5] virsh: Use virshDomain type in 'inject-nmi' 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: , Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.68]); Mon, 16 Sep 2019 12:45:42 +0000 (UTC) Content-Type: text/plain; charset="utf-8" With a nice side-effect of fixing alignment. Signed-off-by: Peter Krempa Reviewed-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- tools/virsh-domain.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 9015c43ba2..9913d703ec 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -8645,17 +8645,15 @@ static const vshCmdOptDef opts_inject_nmi[] =3D { static bool cmdInjectNMI(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; - bool ret =3D true; + VIR_AUTOPTR(virshDomain) dom =3D NULL; if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; if (virDomainInjectNMI(dom, 0) < 0) - ret =3D false; + return false; - virshDomainFree(dom); - return ret; + return true; } /* --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 06:55:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1568637951; cv=none; d=zoho.com; s=zohoarc; b=R0AiIfwM5v0Xk1KxTScmqw/Egu1EqVFkqfDx85mcEdFODZLC/P2BEeKceTL+Owi16sCbFJDN6nF2Gbyy+kxk6f/MamTpAwbvt2ClVZ74GuiMRgBJQD2/lPK0XJsQd02Lf5UXSjzwPT5IOGQB76RXjHg1WNSFQiiLjesVI+oGRjY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568637951; 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:ARC-Authentication-Results; bh=ZfOr5Wvz0vyNzyZVNAv7eIbAlvL51je33MHj152Dp+U=; b=WPDQ8diHKIS10FVax3gnmfeDIrs845f6g3dRbGnUJ1ONGgR7ESg0ThCTYJtySdGenCwrZWjAt9ytjjNJtvVDElHiImZXrGoZBXphaVjgJVrrkXwryBtJlaS0CIw8yhSGG9mwsLG4FMMDNT5TeMTRPB7fzoipHcDwXyMT2HE/Ot4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1568637951050759.127168436298; Mon, 16 Sep 2019 05:45:51 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 31BF21DB7; Mon, 16 Sep 2019 12:45:49 +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 0ED585D9DC; Mon, 16 Sep 2019 12:45:49 +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 C59371802216; Mon, 16 Sep 2019 12:45:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8GCjePE026050 for ; Mon, 16 Sep 2019 08:45:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id C38295DA21; Mon, 16 Sep 2019 12:45:40 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 379305D9DC for ; Mon, 16 Sep 2019 12:45:40 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 16 Sep 2019 14:45:35 +0200 Message-Id: <4b07036c40d517fcc8233f5ae8bc318db7ef06b3.1568637841.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/5] virsh: Use VIR_AUTO machinery in cmdQemuMonitorCommand 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: , Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.71]); Mon, 16 Sep 2019 12:45:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- tools/virsh-domain.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 9913d703ec..8c24935938 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -9506,14 +9506,13 @@ static const vshCmdOptDef opts_qemu_monitor_command= [] =3D { static bool cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; - bool ret =3D false; - char *monitor_cmd =3D NULL; - char *result =3D NULL; + VIR_AUTOPTR(virshDomain) dom =3D NULL; + VIR_AUTOFREE(char *) monitor_cmd =3D NULL; + VIR_AUTOFREE(char *) result =3D NULL; unsigned int flags =3D 0; const vshCmdOpt *opt =3D NULL; virBuffer buf =3D VIR_BUFFER_INITIALIZER; - virJSONValuePtr pretty =3D NULL; + VIR_AUTOPTR(virJSONValue) pretty =3D NULL; VSH_EXCLUSIVE_OPTIONS("hmp", "pretty"); @@ -9527,7 +9526,7 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *= cmd) if (virBufferError(&buf)) { vshError(ctl, "%s", _("Failed to collect command")); - goto cleanup; + return false; } monitor_cmd =3D virBufferContentAndReset(&buf); @@ -9535,7 +9534,7 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *= cmd) flags |=3D VIR_DOMAIN_QEMU_MONITOR_COMMAND_HMP; if (virDomainQemuMonitorCommand(dom, monitor_cmd, &result, flags) < 0) - goto cleanup; + return false; if (vshCommandOptBool(cmd, "pretty")) { char *tmp; @@ -9549,16 +9548,7 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd = *cmd) } } vshPrint(ctl, "%s\n", result); - - ret =3D true; - - cleanup: - VIR_FREE(result); - VIR_FREE(monitor_cmd); - virJSONValueFree(pretty); - virshDomainFree(dom); - - return ret; + return true; } /* --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 06:55:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1568637956; cv=none; d=zoho.com; s=zohoarc; b=HuxggNG4+E0qoDQpOfPRvkoC6nOgITw528DtzW7za6XYPcJOxmhKYzTjIb6F5E4ejoJtH2wyZxEuykSRdsjgaV0DNG1RmkeuUdYUNrpUuuLw+UrPlMJDHHhMxVo4lUnVSJgH8cuEMkXrjx5OhABva3nDogsXy2EJvE/md/Vf/9U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568637956; 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:ARC-Authentication-Results; bh=1/PHSONI4SUlBP6WE9DCN2RXxQ8Kf8pFEZkG0cMN8Bw=; b=gQooGrfd9LsJsUbFqNW3NdP1y08oZkmIMHEuBl2KQLDUtH+tFEIPpFEMp1blk7xtm91uuSiC82eY9qJHgI2hMeBIdbZ9ZFOBlbF6KRL5vfY98koCOFrV6J6xYvYd5/d9Rdcfcsk08HUSNLQXuPMynV2sjX3XK0/iptncaOaMckY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1568637956615363.9510832615449; Mon, 16 Sep 2019 05:45:56 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id E5899309BDBC; Mon, 16 Sep 2019 12:45:53 +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 BE7F55F7C0; Mon, 16 Sep 2019 12:45:53 +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 8081D180BA99; Mon, 16 Sep 2019 12:45:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8GCjfOJ026057 for ; Mon, 16 Sep 2019 08:45:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 911FA5D9E2; Mon, 16 Sep 2019 12:45:41 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B6C45D9E1 for ; Mon, 16 Sep 2019 12:45:40 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 16 Sep 2019 14:45:36 +0200 Message-Id: <11164729b9038e77be733e5ffa64505074e80d80.1568637841.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/5] virsh: Don't open-code virJSONStringReformat in cmdQemuMonitorCommand 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: , Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 16 Sep 2019 12:45:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- tools/virsh-domain.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 8c24935938..fbfdc09c0d 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -9512,7 +9512,6 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *= cmd) unsigned int flags =3D 0; const vshCmdOpt *opt =3D NULL; virBuffer buf =3D VIR_BUFFER_INITIALIZER; - VIR_AUTOPTR(virJSONValue) pretty =3D NULL; VSH_EXCLUSIVE_OPTIONS("hmp", "pretty"); @@ -9538,8 +9537,7 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *= cmd) if (vshCommandOptBool(cmd, "pretty")) { char *tmp; - pretty =3D virJSONValueFromString(result); - if (pretty && (tmp =3D virJSONValueToString(pretty, true))) { + if ((tmp =3D virJSONStringReformat(result, true))) { VIR_FREE(result); result =3D tmp; virTrimSpaces(result, NULL); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list