From nobody Mon Feb 9 06:48:43 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1575623508; cv=none; d=zohomail.com; s=zohoarc; b=FDrwGJD5Bgqker/K+1jK1gPSrqmbeMPvHHUni7Vgqyo7H+bq8KPhadzzWm+ZNnjpXppxKGattaAOUUqPBT4Ls0R5/Bpu4SbNUdnQl3nW9D3pyesp+zUc5LcTKTy39vq9MqqUtJFaWLH4KF0JDfOE2puU8+27inBL9y9hvS3W828= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575623508; 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=F0E7h12GtBjJTzyu6utB1qtyqiubXk/IydPMJ/SZde8=; b=YWRQXHZQziaR45bw/8EqAx15vPCO6WRrMiZg3Lm7IxaCJmWGZDxhtFVNyMtSZl3gw+z7rdoeO4k3DMj9gqGeC1KLtLSIIiD70Q4CT+kcDWWKafa2iUJM5ctdBAmhbuq82owV1uQ+5T+7mUo81uxeif+wEGU1I6pEEo7TesimU60= 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=pass 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 1575623508022583.4351075633615; Fri, 6 Dec 2019 01:11:48 -0800 (PST) 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-289-oPLbxGAzOdOZL7JXGjSL4g-1; Fri, 06 Dec 2019 04:11:45 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 39F0A107ACC4; Fri, 6 Dec 2019 09:11:39 +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 E5FD86013B; Fri, 6 Dec 2019 09:11:38 +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 62BA265D3C; Fri, 6 Dec 2019 09:11:38 +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 xB69BZmr025254 for ; Fri, 6 Dec 2019 04:11:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id D723E694A4; Fri, 6 Dec 2019 09:11:35 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3885467E52; Fri, 6 Dec 2019 09:11:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575623506; 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=F0E7h12GtBjJTzyu6utB1qtyqiubXk/IydPMJ/SZde8=; b=UiQM7TKVVsWn1Rq4/E3VsGQpmUOsGSKnnh/lIsvKT52ZTK8XxNLzEaJ2Q/dE4yjTXkjX3t V0geVw7RC8uVzH5IebunGQ+3NeaxNPlwG0S8b4qOu3Njn2gNq3ni6pmaBHXkXsfjg352MU K5/N24sygUOycFTJsxGABgcYZ2hCH4M= From: Pavel Mores To: libvir-list@redhat.com Date: Fri, 6 Dec 2019 10:11:28 +0100 Message-Id: <20191206091129.16909-3-pmores@redhat.com> In-Reply-To: <20191206091129.16909-1-pmores@redhat.com> References: <20191206091129.16909-1-pmores@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Pavel Mores Subject: [libvirt] [PATCH 2/3] qemu: use g_autofree instead of VIR_FREE in qemuMonitorTextCreateSnapshot() 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.11 X-MC-Unique: oPLbxGAzOdOZL7JXGjSL4g-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" While at bugfixing, convert the whole function to the new-style memory allocation handling. Signed-off-by: Pavel Mores Reviewed-by: Cole Robinson --- src/qemu/qemu_monitor_text.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index b387235821..7586ba4c54 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -125,14 +125,13 @@ int qemuMonitorTextCreateSnapshot(qemuMonitorPtr mon, const char *name) { - char *cmd =3D NULL; - char *reply =3D NULL; - int ret =3D -1; + g_autofree char *cmd =3D NULL; + g_autofree char *reply =3D NULL; =20 cmd =3D g_strdup_printf("savevm \"%s\"", name); =20 if (qemuMonitorJSONHumanCommand(mon, cmd, &reply)) - goto cleanup; + return -1; =20 if (strstr(reply, "Error while creating snapshot") || strstr(reply, "Could not open VM state file") || @@ -141,19 +140,14 @@ qemuMonitorTextCreateSnapshot(qemuMonitorPtr mon, (strstr(reply, "Error") && strstr(reply, "while writing VM"))) { virReportError(VIR_ERR_OPERATION_FAILED, _("Failed to take snapshot: %s"), reply); - goto cleanup; + return -1; } else if (strstr(reply, "No block device can accept snapshots")) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("this domain does not have a device to take snaps= hots")); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - VIR_FREE(cmd); - VIR_FREE(reply); - return ret; + return 0; } =20 int qemuMonitorTextLoadSnapshot(qemuMonitorPtr mon, const char *name) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list