From nobody Wed May 15 07:14:19 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1530620797811571.6949598612354; Tue, 3 Jul 2018 05:26:37 -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 AC7CF308403C; Tue, 3 Jul 2018 12:26:36 +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 22A20611A0; Tue, 3 Jul 2018 12:26:36 +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 7E66C18363F8; Tue, 3 Jul 2018 12:26:35 +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 w63CPGgw007872 for ; Tue, 3 Jul 2018 08:25:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5B0C42027047; Tue, 3 Jul 2018 12:25:16 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id D698F2026D76 for ; Tue, 3 Jul 2018 12:25:15 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Jul 2018 14:32:59 +0200 Message-Id: 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 1/8] qemu: snapshot: Require support of 'transaction' command for external snapshots 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 03 Jul 2018 12:26:37 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" While qemu supports the 'transaction' command since v1.1.0 (52e7c241ac766406f05fa) and the 'blockdev-snapshot-sync' command since v0.14.0-rc0 we need to keep the capability bits present since some qemu downstreams (RHEL/CentOS 7 for example) chose to cripple qemu by arbitrarily compile out some stuff which was already present at that time. To simplify the crazy code just require both commands to be present at the beginning of a external snapshot so that we can remove the case when 'transaction' would not be supported. This also allows to drop any logic connected to the VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC flag since snapshots are atomic with the 'transaction' command. Signed-off-by: Peter Krempa Reviewed-by: J=EF=BF=BDn Tomko --- src/qemu/qemu_driver.c | 62 +++++++++++-----------------------------------= ---- 1 file changed, 13 insertions(+), 49 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 825b2b27e6..4f577e50d2 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14614,18 +14614,9 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm, size_t i; bool active =3D virDomainObjIsActive(vm); bool reuse =3D (*flags & VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT) !=3D 0; - bool atomic =3D (*flags & VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC) !=3D 0; bool found_internal =3D false; bool forbid_internal =3D false; int external =3D 0; - qemuDomainObjPrivatePtr priv =3D vm->privateData; - - if (def->state =3D=3D VIR_DOMAIN_DISK_SNAPSHOT && - reuse && !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_TRANSACTION)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("reuse is not supported with this QEMU binary")); - goto cleanup; - } for (i =3D 0; i < def->ndisks; i++) { virDomainSnapshotDiskDefPtr disk =3D &def->disks[i]; @@ -14756,18 +14747,6 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm, if (external && !active) *flags |=3D VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY; - if (def->state !=3D VIR_DOMAIN_DISK_SNAPSHOT && active) { - if (external =3D=3D 1 || - virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_TRANSACTION)) { - *flags |=3D VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC; - } else if (atomic && external > 1) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("atomic live snapshot of multiple disks " - "is unsupported")); - goto cleanup; - } - } - ret =3D 0; cleanup: @@ -15033,15 +15012,8 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPt= r driver, if (virDomainObjCheckActive(vm) < 0) return -1; - if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_TRANSACTION)) { - if (!(actions =3D virJSONValueNewArray())) - return -1; - } else if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DISK_SNAPSHOT)) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("live disk snapshot not supported with this " - "QEMU binary")); + if (!(actions =3D virJSONValueNewArray())) return -1; - } /* prepare a list of objects to use in the vm definition so that we do= n't * have to roll back later */ @@ -15154,8 +15126,6 @@ qemuDomainSnapshotCreateActiveExternal(virQEMUDrive= rPtr driver, char *xml =3D NULL; bool memory =3D snap->def->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_= EXTERNAL; bool memory_unlink =3D false; - bool atomic =3D !!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC); - bool transaction =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_TRANSACT= ION); int thaw =3D 0; /* 1 if freeze succeeded, -1 if freeze failed */ bool pmsuspended =3D false; virQEMUDriverConfigPtr cfg =3D NULL; @@ -15163,6 +15133,14 @@ qemuDomainSnapshotCreateActiveExternal(virQEMUDriv= erPtr driver, char *compressedpath =3D NULL; virQEMUSaveDataPtr data =3D NULL; + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DISK_SNAPSHOT) || + !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_TRANSACTION)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("live disk snapshot not supported with this " + "QEMU binary")); + return -1; + } + /* If quiesce was requested, then issue a freeze command, and a * counterpart thaw command when it is actually sent to agent. * The command will fail if the guest is paused or the guest agent @@ -15197,20 +15175,11 @@ qemuDomainSnapshotCreateActiveExternal(virQEMUDri= verPtr driver, } else if (virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_RUNNING) { /* For external checkpoints (those with memory), the guest * must pause (either by libvirt up front, or by qemu after - * _LIVE converges). For disk-only snapshots with multiple - * disks, libvirt must pause externally to get all snapshots - * to be at the same point in time, unless qemu supports - * transactions. For a single disk, snapshot is atomic - * without requiring a pause. Thanks to - * qemuDomainSnapshotPrepare, if we got to this point, the - * atomic flag now says whether we need to pause, and a - * capability bit says whether to use transaction. - */ + * _LIVE converges). */ if (memory) resume =3D true; - if ((memory && !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_LIVE)) || - (!memory && atomic && !transaction)) { + if (memory && !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_LIVE)) { if (qemuProcessStopCPUs(driver, vm, VIR_DOMAIN_PAUSED_SNAPSHOT, QEMU_ASYNC_JOB_SNAPSHOT) < 0) goto cleanup; @@ -15265,13 +15234,8 @@ qemuDomainSnapshotCreateActiveExternal(virQEMUDriv= erPtr driver, qemuDomainObjSetAsyncJobMask(vm, QEMU_JOB_DEFAULT_MASK); } - /* now the domain is now paused if: - * - if a memory snapshot was requested - * - an atomic snapshot was requested AND - * qemu does not support transactions - * - * Next we snapshot the disks. - */ + /* now the domain is now paused if a memory snapshot was requested */ + if ((ret =3D qemuDomainSnapshotCreateDiskActive(driver, vm, snap, flag= s, QEMU_ASYNC_JOB_SNAPSHOT)= ) < 0) goto cleanup; --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 15 07:14:19 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1530620806746156.47818009579498; Tue, 3 Jul 2018 05:26:46 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2EB3A3082A3C; Tue, 3 Jul 2018 12:26:44 +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 DC70960BE4; Tue, 3 Jul 2018 12:26:43 +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 820864A463; Tue, 3 Jul 2018 12:26:43 +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 w63CPHD6007882 for ; Tue, 3 Jul 2018 08:25:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id F40462027047; Tue, 3 Jul 2018 12:25:16 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 98BDC2026D76 for ; Tue, 3 Jul 2018 12:25:16 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Jul 2018 14:33:00 +0200 Message-Id: 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 2/8] qemu: snapshot: Remove monitor code now that 'transaction' is always used 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 03 Jul 2018 12:26:46 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Since we now always do the snapshot via the 'transaction' command we can drop the code which would enter monitor for individual disk snapshots. Signed-off-by: Peter Krempa Reviewed-by: J=EF=BF=BDn Tomko --- src/qemu/qemu_driver.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4f577e50d2..39b745b1db 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14925,14 +14925,12 @@ qemuDomainSnapshotUpdateDiskSources(qemuDomainSna= pshotDiskDataPtr dd, } -/* The domain is expected to hold monitor lock. */ static int qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver, virDomainObjPtr vm, qemuDomainSnapshotDiskDataPtr dd, virJSONValuePtr actions, - bool reuse, - qemuDomainAsyncJob asyncJob) + bool reuse) { qemuDomainObjPrivatePtr priv =3D vm->privateData; char *device =3D NULL; @@ -14964,23 +14962,10 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUD= riverPtr driver, dd->prepared =3D true; - /* create the actual snapshot */ formatStr =3D virStorageFileFormatTypeToString(dd->src->format); - /* The monitor is only accessed if qemu doesn't support transactions. - * Otherwise the following monitor command only constructs the command. - */ - if (!actions && - qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - goto cleanup; - ret =3D rc =3D qemuMonitorDiskSnapshot(priv->mon, actions, device, sou= rce, formatStr, reuse); - if (!actions) { - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret =3D -1; - } - virDomainAuditDisk(vm, dd->disk->src, dd->src, "snapshot", rc >=3D 0); cleanup: @@ -15032,11 +15017,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPt= r driver, ret =3D qemuDomainSnapshotCreateSingleDiskActive(driver, vm, &diskdata[i], - actions, reuse, asy= ncJob); - - /* without transaction support the change can't be rolled back */ - if (!actions) - qemuDomainSnapshotUpdateDiskSources(&diskdata[i], &persist); + actions, reuse); if (ret < 0) goto error; @@ -15044,7 +15025,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr= driver, do_transaction =3D true; } - if (actions && do_transaction) { + if (do_transaction) { if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) goto cleanup; --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 15 07:14:19 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1530620732451256.74663028417467; Tue, 3 Jul 2018 05:25:32 -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 228E4308FBA0; Tue, 3 Jul 2018 12:25:31 +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 B59961001920; Tue, 3 Jul 2018 12:25:30 +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 5075F18363F6; Tue, 3 Jul 2018 12:25:30 +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 w63CPHZn007887 for ; Tue, 3 Jul 2018 08:25:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 985B42027047; Tue, 3 Jul 2018 12:25:17 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3CC0C2026D76 for ; Tue, 3 Jul 2018 12:25:17 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Jul 2018 14:33:01 +0200 Message-Id: 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 3/8] qemu: snapshot: Unify conditions checking whether snapshot needs to be taken 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.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.43]); Tue, 03 Jul 2018 12:25:31 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In the cleanup path we already checked whether a snapshot needed to be taken by looking into the collected data. Use the same approach when creating the snapshot command data and when commiting the changes to the domain definition. Signed-off-by: Peter Krempa Reviewed-by: J=EF=BF=BDn Tomko --- src/qemu/qemu_driver.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 39b745b1db..e5005fd829 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15012,7 +15012,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr= driver, * VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL with a valid file name and * qcow2 format. */ for (i =3D 0; i < snap->def->ndisks; i++) { - if (snap->def->disks[i].snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATI= ON_NONE) + if (!diskdata[i].src) continue; ret =3D qemuDomainSnapshotCreateSingleDiskActive(driver, vm, @@ -15036,8 +15036,14 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPt= r driver, goto error; } - for (i =3D 0; i < snap->def->ndisks; i++) + for (i =3D 0; i < snap->def->ndisks; i++) { + qemuDomainSnapshotDiskDataPtr dd =3D &diskdata[i]; + + if (!dd->src) + continue; + qemuDomainSnapshotUpdateDiskSources(&diskdata[i], &persist); + } } error: --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 15 07:14:19 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1530620738453552.5470863900779; Tue, 3 Jul 2018 05:25:38 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 43BAB308626B; Tue, 3 Jul 2018 12:25:37 +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 069DC30012A6; Tue, 3 Jul 2018 12:25: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 AE18D4A463; Tue, 3 Jul 2018 12:25:36 +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 w63CPIg8007897 for ; Tue, 3 Jul 2018 08:25:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3DF312027047; 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 D53622026D76 for ; Tue, 3 Jul 2018 12:25:17 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Jul 2018 14:33:02 +0200 Message-Id: <8d170686779056c4ebdb4afb99941beeb0dd8631.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 4/8] qemu: snapshot: Audit actual disk snapshot creation 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.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 03 Jul 2018 12:25:37 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Currently we'd audit that we managed to format the data for the 'transaction' command rather than the (un)successful attempt to create the snapshot. Move the auditing code so that it can actually audit the result of the 'transaction' command. Signed-off-by: Peter Krempa Reviewed-by: J=EF=BF=BDn Tomko --- src/qemu/qemu_driver.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e5005fd829..ea06e23ff1 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14936,7 +14936,7 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDri= verPtr driver, char *device =3D NULL; char *source =3D NULL; const char *formatStr =3D NULL; - int ret =3D -1, rc; + int ret =3D -1; if (!(device =3D qemuAliasDiskDriveFromDisk(dd->disk))) goto cleanup; @@ -14964,9 +14964,8 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDri= verPtr driver, formatStr =3D virStorageFileFormatTypeToString(dd->src->format); - ret =3D rc =3D qemuMonitorDiskSnapshot(priv->mon, actions, device, sou= rce, - formatStr, reuse); - virDomainAuditDisk(vm, dd->disk->src, dd->src, "snapshot", rc >=3D 0); + ret =3D qemuMonitorDiskSnapshot(priv->mon, actions, device, source, + formatStr, reuse); cleanup: VIR_FREE(device); @@ -15031,10 +15030,8 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPt= r driver, ret =3D qemuMonitorTransaction(priv->mon, &actions); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || ret < 0) { + if (qemuDomainObjExitMonitor(driver, vm) < 0) ret =3D -1; - goto error; - } for (i =3D 0; i < snap->def->ndisks; i++) { qemuDomainSnapshotDiskDataPtr dd =3D &diskdata[i]; @@ -15042,8 +15039,14 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPt= r driver, if (!dd->src) continue; - qemuDomainSnapshotUpdateDiskSources(&diskdata[i], &persist); + virDomainAuditDisk(vm, dd->disk->src, dd->src, "snapshot", ret= >=3D 0); + + if (ret =3D=3D 0) + qemuDomainSnapshotUpdateDiskSources(dd, &persist); } + + if (ret < 0) + goto error; } error: --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 15 07:14:19 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 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 From nobody Wed May 15 07:14:19 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1530620743551981.6024478835212; Tue, 3 Jul 2018 05:25:43 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5082A30832E9; Tue, 3 Jul 2018 12:25:42 +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 19839655C8; Tue, 3 Jul 2018 12:25: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 BCDD218363F6; Tue, 3 Jul 2018 12:25:41 +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 w63CPJOh007914 for ; Tue, 3 Jul 2018 08:25:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 78DC22027047; Tue, 3 Jul 2018 12:25:19 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DEA22026D76 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:04 +0200 Message-Id: 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 6/8] qemu: block: Create helper for creating data for legacy snapshots 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.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Tue, 03 Jul 2018 12:25:42 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" With 'transaction' support we don't need to keep around the multipurpose code which would create the snapshot if 'transaction' is not supported. To simplify this add a new helper that just wraps the arguments for 'blockdev-snapshot-sync' operation in 'transaction' and use it instead of qemuBlockSnapshotAddLegacy. Additionally this allows to format the arguments prior to creating the file for simpler cleanup. Signed-off-by: Peter Krempa Reviewed-by: J=EF=BF=BDn Tomko --- src/qemu/qemu_block.c | 37 +++++++++++++++++++++++++++++++++++++ src/qemu/qemu_block.h | 6 ++++++ src/qemu/qemu_driver.c | 18 +++--------------- 3 files changed, 46 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 0ebf2d2aff..db1579ca20 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -19,8 +19,10 @@ #include #include "qemu_block.h" +#include "qemu_command.h" #include "qemu_domain.h" #include "qemu_alias.h" +#include "qemu_monitor_json.h" #include "viralloc.h" #include "virstring.h" @@ -1683,3 +1685,38 @@ qemuBlockStorageSourceDetachOneBlockdev(virQEMUDrive= rPtr driver, return ret; } + + +int +qemuBlockSnapshotAddLegacy(virJSONValuePtr actions, + virDomainDiskDefPtr disk, + virStorageSourcePtr newsrc, + bool reuse) +{ + const char *format =3D virStorageFileFormatTypeToString(newsrc->format= ); + char *device =3D NULL; + char *source =3D NULL; + int ret =3D -1; + + if (!(device =3D qemuAliasDiskDriveFromDisk(disk))) + goto cleanup; + + if (qemuGetDriveSourceString(newsrc, NULL, &source) < 0) + goto cleanup; + + if (qemuMonitorJSONTransactionAdd(actions, "blockdev-snapshot-sync", + "s:device", device, + "s:snapshot-file", source, + "s:format", format, + "S:mode", reuse ? "existing" : NULL, + NULL) < 0) + goto cleanup; + + ret =3D 0; + + cleanup: + VIR_FREE(device); + VIR_FREE(source); + + return ret; +} diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index 418b5064b5..fd8984e60b 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -117,4 +117,10 @@ qemuBlockStorageSourceDetachOneBlockdev(virQEMUDriverP= tr driver, qemuDomainAsyncJob asyncJob, virStorageSourcePtr src); +int +qemuBlockSnapshotAddLegacy(virJSONValuePtr actions, + virDomainDiskDefPtr disk, + virStorageSourcePtr newsrc, + bool reuse); + #endif /* __QEMU_BLOCK_H__ */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ea06e23ff1..2d8af5daaa 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14932,23 +14932,16 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUD= riverPtr driver, virJSONValuePtr actions, bool reuse) { - qemuDomainObjPrivatePtr priv =3D vm->privateData; - char *device =3D NULL; - char *source =3D NULL; - const char *formatStr =3D NULL; int ret =3D -1; - if (!(device =3D qemuAliasDiskDriveFromDisk(dd->disk))) - goto cleanup; - - if (qemuGetDriveSourceString(dd->src, NULL, &source) < 0) + if (qemuBlockSnapshotAddLegacy(actions, dd->disk, dd->src, reuse) < 0) goto cleanup; /* pre-create the image file so that we can label it before handing it= to qemu */ if (!reuse && dd->src->type !=3D VIR_STORAGE_TYPE_BLOCK) { if (virStorageFileCreate(dd->src) < 0) { virReportSystemError(errno, _("failed to create image file '%s= '"), - source); + NULLSTR(dd->src->path)); goto cleanup; } dd->created =3D true; @@ -14962,14 +14955,9 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDr= iverPtr driver, dd->prepared =3D true; - formatStr =3D virStorageFileFormatTypeToString(dd->src->format); - - ret =3D qemuMonitorDiskSnapshot(priv->mon, actions, device, source, - formatStr, reuse); + ret =3D 0; cleanup: - VIR_FREE(device); - VIR_FREE(source); return ret; } --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 15 07:14:19 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1530620749198489.9149716610789; Tue, 3 Jul 2018 05:25:49 -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 2B9433081244; Tue, 3 Jul 2018 12:25:48 +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 E1C6317CC9; Tue, 3 Jul 2018 12:25:47 +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 76F7A18363F7; Tue, 3 Jul 2018 12:25:47 +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 w63CPKdQ007919 for ; Tue, 3 Jul 2018 08:25:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 210B12027047; Tue, 3 Jul 2018 12:25:20 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id B59EC2026D76 for ; Tue, 3 Jul 2018 12:25:19 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Jul 2018 14:33:05 +0200 Message-Id: <12054bba7ebd891bc2f7b50bb76f832c58cb9302.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 7/8] qemu: monitor: Remove old external snapshot code 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 03 Jul 2018 12:25:48 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Remove the dual mode code which allowed to create snapshots without support for 'transaction'. Signed-off-by: Peter Krempa Reviewed-by: J=EF=BF=BDn Tomko --- src/qemu/qemu_monitor.c | 17 ----------------- src/qemu/qemu_monitor.h | 6 ------ src/qemu/qemu_monitor_json.c | 37 ------------------------------------- src/qemu/qemu_monitor_json.h | 8 -------- 4 files changed, 68 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 6ed475ede0..5d7f6905ae 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3177,23 +3177,6 @@ qemuMonitorDeleteSnapshot(qemuMonitorPtr mon, const = char *name) } -/* Use the snapshot_blkdev command to convert the existing file for - * device into a read-only backing file of a new qcow2 image located - * at file. */ -int -qemuMonitorDiskSnapshot(qemuMonitorPtr mon, virJSONValuePtr actions, - const char *device, const char *file, - const char *format, bool reuse) -{ - VIR_DEBUG("actions=3D%p, device=3D%s, file=3D%s, format=3D%s, reuse=3D= %d", - actions, device, file, format, reuse); - - QEMU_CHECK_MONITOR(mon); - - return qemuMonitorJSONDiskSnapshot(mon, actions, device, file, format,= reuse); -} - - /* Start a drive-mirror block job. bandwidth is in bytes/sec. */ int qemuMonitorDriveMirror(qemuMonitorPtr mon, diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index b3d62324b4..e09ca14bfa 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -827,12 +827,6 @@ int qemuMonitorCreateSnapshot(qemuMonitorPtr mon, cons= t char *name); int qemuMonitorLoadSnapshot(qemuMonitorPtr mon, const char *name); int qemuMonitorDeleteSnapshot(qemuMonitorPtr mon, const char *name); -int qemuMonitorDiskSnapshot(qemuMonitorPtr mon, - virJSONValuePtr actions, - const char *device, - const char *file, - const char *format, - bool reuse); int qemuMonitorTransaction(qemuMonitorPtr mon, virJSONValuePtr *actions) ATTRIBUTE_NONNULL(2); int qemuMonitorDriveMirror(qemuMonitorPtr mon, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 54fefcb612..cf1636d858 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4101,43 +4101,6 @@ int qemuMonitorJSONDelObject(qemuMonitorPtr mon, } -int -qemuMonitorJSONDiskSnapshot(qemuMonitorPtr mon, virJSONValuePtr actions, - const char *device, const char *file, - const char *format, bool reuse) -{ - int ret =3D -1; - virJSONValuePtr cmd; - virJSONValuePtr reply =3D NULL; - - cmd =3D qemuMonitorJSONMakeCommandRaw(actions !=3D NULL, - "blockdev-snapshot-sync", - "s:device", device, - "s:snapshot-file", file, - "s:format", format, - "S:mode", reuse ? "existing" : NUL= L, - NULL); - if (!cmd) - return -1; - - if (actions) { - if (virJSONValueArrayAppend(actions, cmd) =3D=3D 0) { - ret =3D 0; - cmd =3D NULL; - } - } else { - if ((ret =3D qemuMonitorJSONCommand(mon, cmd, &reply)) < 0) - goto cleanup; - - ret =3D qemuMonitorJSONCheckError(cmd, reply); - } - - cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; -} - /* speed is in bytes/sec */ int qemuMonitorJSONDriveMirror(qemuMonitorPtr mon, diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index da6c121d72..b61046379c 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -242,14 +242,6 @@ int qemuMonitorJSONAddObject(qemuMonitorPtr mon, int qemuMonitorJSONDelObject(qemuMonitorPtr mon, const char *objalias); -int qemuMonitorJSONDiskSnapshot(qemuMonitorPtr mon, - virJSONValuePtr actions, - const char *device, - const char *file, - const char *format, - bool reuse) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) - ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5); int qemuMonitorJSONTransaction(qemuMonitorPtr mon, virJSONValuePtr *action= s) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); int qemuMonitorJSONDriveMirror(qemuMonitorPtr mon, --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 15 07:14:19 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1530620755317847.7447492108171; Tue, 3 Jul 2018 05:25:55 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3734E3078AA3; Tue, 3 Jul 2018 12:25:54 +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 0A0AA30012B1; Tue, 3 Jul 2018 12:25:54 +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 99C5318363F5; Tue, 3 Jul 2018 12:25:53 +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 w63CPKiu007927 for ; Tue, 3 Jul 2018 08:25:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id B844C2027047; Tue, 3 Jul 2018 12:25:20 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D0632026D76 for ; Tue, 3 Jul 2018 12:25:20 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Jul 2018 14:33:06 +0200 Message-Id: <8bafac921a8a7b29bc2f0e28f4aba306431dfc0d.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 8/8] qemu: monitor: Remove old code for dual handling of 'transaction' data 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.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 03 Jul 2018 12:25:54 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Now that we use only the separate function for creating data for the 'transaction' command we can remove all the boilerplate which was necessary before. Signed-off-by: Peter Krempa Reviewed-by: J=EF=BF=BDn Tomko --- src/qemu/qemu_monitor_json.c | 42 ++++++++++------------------------------= -- 1 file changed, 10 insertions(+), 32 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index cf1636d858..87ec496d0d 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -514,48 +514,30 @@ qemuMonitorJSONTransactionAdd(virJSONValuePtr actions, * qemuMonitorJSONMakeCommandInternal: * @cmdname: QMP command name * @arguments: a JSON object containing command arguments or NULL - * @transaction: format the command as arguments for the 'transaction' com= mand * - * Create a JSON object used on the QMP monitor to call a command. If - * @transaction is true, the returned object is formatted to be used as a = member - * of the 'transaction' command. + * Create a JSON object used on the QMP monitor to call a command. * * Note that @arguments is always consumed and should not be referenced af= ter * the call to this function. */ static virJSONValuePtr qemuMonitorJSONMakeCommandInternal(const char *cmdname, - virJSONValuePtr arguments, - bool transaction) + virJSONValuePtr arguments) { - virJSONValuePtr cmd =3D NULL; virJSONValuePtr ret =3D NULL; - if (!transaction) { - if (virJSONValueObjectCreate(&cmd, - "s:execute", cmdname, - "A:arguments", &arguments, NULL) < 0) - goto cleanup; - } else { - if (virJSONValueObjectCreate(&cmd, - "s:type", cmdname, - "A:data", &arguments, NULL) < 0) - goto cleanup; - } - - VIR_STEAL_PTR(ret, cmd); + ignore_value(virJSONValueObjectCreate(&ret, + "s:execute", cmdname, + "A:arguments", &arguments, NULL)= ); - cleanup: virJSONValueFree(arguments); - virJSONValueFree(cmd); return ret; } static virJSONValuePtr ATTRIBUTE_SENTINEL -qemuMonitorJSONMakeCommandRaw(bool transaction, - const char *cmdname, - ...) +qemuMonitorJSONMakeCommand(const char *cmdname, + ...) { virJSONValuePtr obj =3D NULL; virJSONValuePtr jargs =3D NULL; @@ -566,7 +548,7 @@ qemuMonitorJSONMakeCommandRaw(bool transaction, if (virJSONValueObjectCreateVArgs(&jargs, args) < 0) goto cleanup; - obj =3D qemuMonitorJSONMakeCommandInternal(cmdname, jargs, transaction= ); + obj =3D qemuMonitorJSONMakeCommandInternal(cmdname, jargs); cleanup: va_end(args); @@ -574,9 +556,6 @@ qemuMonitorJSONMakeCommandRaw(bool transaction, return obj; } -#define qemuMonitorJSONMakeCommand(cmdname, ...) \ - qemuMonitorJSONMakeCommandRaw(false, cmdname, __VA_ARGS__) - static virJSONValuePtr qemuMonitorJSONKeywordStringToJSON(const char *str, const char *firstkeywo= rd) @@ -4057,7 +4036,7 @@ qemuMonitorJSONAddObject(qemuMonitorPtr mon, virJSONValuePtr cmd; virJSONValuePtr reply =3D NULL; - if (!(cmd =3D qemuMonitorJSONMakeCommandInternal("object-add", props, = false))) + if (!(cmd =3D qemuMonitorJSONMakeCommandInternal("object-add", props))) goto cleanup; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) @@ -7964,8 +7943,7 @@ qemuMonitorJSONBlockdevAdd(qemuMonitorPtr mon, virJSONValuePtr reply =3D NULL; int ret =3D -1; - if (!(cmd =3D qemuMonitorJSONMakeCommandInternal("blockdev-add", - props, false))) + if (!(cmd =3D qemuMonitorJSONMakeCommandInternal("blockdev-add", props= ))) return -1; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list