From nobody Tue May 13 20:26:12 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 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