From nobody Tue May 13 20:08:37 2025 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1530620812305441.7364025149693; Tue, 3 Jul 2018 05:26:52 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6472F3082134; Tue, 3 Jul 2018 12:26: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 18E1D5D6B5; Tue, 3 Jul 2018 12:26: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 AB6D418363F7; Tue, 3 Jul 2018 12:26:48 +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 w63CPI1k007909 for ; Tue, 3 Jul 2018 08:25:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id D517A2027047; Tue, 3 Jul 2018 12:25:18 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 793732026D76 for ; Tue, 3 Jul 2018 12:25:18 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Jul 2018 14:33:03 +0200 Message-Id: <752e0519a211ef011725b8b8bb7da169e7f6a8bc.1530621122.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/8] qemu: monitor: Add API to help creating 'transaction' arguments 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: , MIME-Version: 1.0 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 03 Jul 2018 12:26:51 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add a new helper that will be solely used to create arguments for the transaction command. Later on this will make it possible to remove the overloading which was caused by the fact that snapshots were created without transaction and also will help in blockdevizing of snapshots. Signed-off-by: Peter Krempa Reviewed-by: J=EF=BF=BDn Tomko --- src/qemu/qemu_monitor_json.c | 46 ++++++++++++++++++++++++++++++++++++++++= ++++ src/qemu/qemu_monitor_json.h | 4 ++++ 2 files changed, 50 insertions(+) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 3e90279b71..54fefcb612 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -464,6 +464,52 @@ qemuMonitorJSONHasError(virJSONValuePtr reply, } +/** + * qemuMonitorJSONTransactionAdd: + * @actions: array of actions for the 'transaction' command + * @cmdname: command to add to @actions + * @...: arguments for @cmdname (see virJSONValueObjectAddVArgs for format= ting) + * + * Add a new command with arguments to the existing ones. The resulting ar= ray + * is used as argument for the 'transaction' command. + * + * Returns 0 on success and -1 on error. + */ +int +qemuMonitorJSONTransactionAdd(virJSONValuePtr actions, + const char *cmdname, + ...) +{ + virJSONValuePtr entry =3D NULL; + virJSONValuePtr data =3D NULL; + va_list args; + int ret =3D -1; + + va_start(args, cmdname); + + if (virJSONValueObjectCreateVArgs(&data, args) < 0) + goto cleanup; + + if (virJSONValueObjectCreate(&entry, + "s:type", cmdname, + "A:data", &data, NULL) < 0) + goto cleanup; + + if (virJSONValueArrayAppend(actions, entry) < 0) + goto cleanup; + + entry =3D NULL; + ret =3D 0; + + cleanup: + virJSONValueFree(entry); + virJSONValueFree(data); + va_end(args); + + return ret; +} + + /** * qemuMonitorJSONMakeCommandInternal: * @cmdname: QMP command name diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 6bc0dd3ad2..da6c121d72 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -32,6 +32,10 @@ # include "cpu/cpu.h" # include "util/virgic.h" +int qemuMonitorJSONTransactionAdd(virJSONValuePtr actions, + const char *cmdname, + ...); + int qemuMonitorJSONIOProcessLine(qemuMonitorPtr mon, const char *line, qemuMonitorMessagePtr msg); --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list