From nobody Sun Feb 8 22:07:49 2026 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 --- 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