From nobody Mon May 13 04:19:16 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1698844370041968.3555195498562; Wed, 1 Nov 2023 06:12:50 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 9EF6617B7; Wed, 1 Nov 2023 09:12:48 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 04709178E; Wed, 1 Nov 2023 09:11:45 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 3F8EE17A1; Wed, 1 Nov 2023 09:11:42 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id B8BCA17A0 for ; Wed, 1 Nov 2023 09:11:41 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-150-o2knGxOdOjKVhDK0PjpFIQ-1; Wed, 01 Nov 2023 09:11:37 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DB923811E7E for ; Wed, 1 Nov 2023 13:11:36 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.176]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7FD631121308 for ; Wed, 1 Nov 2023 13:11:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: o2knGxOdOjKVhDK0PjpFIQ-1 From: Pavel Hrdina To: devel@lists.libvirt.org Subject: [libvirt PATCH] qemu_snapshot: fix reverting to inactive snapshot Date: Wed, 1 Nov 2023 14:11:35 +0100 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: NCDY5BM2MN2CZZBYRHVX3C3QNGPKO5X5 X-Message-ID-Hash: NCDY5BM2MN2CZZBYRHVX3C3QNGPKO5X5 X-MailFrom: phrdina@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZM-MESSAGEID: 1698844371403100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When reverting to inactive snapshot updating the domain definition needs to happen after the new overlays are created otherwise qemu-img will correctly fail with error: Trying to create an image with the same filename as the backing file Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 1962ba4027..5fc0b82e79 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2157,13 +2157,20 @@ qemuSnapshotRevertExternalInactive(virDomainObj *vm, { virQEMUDriver *driver =3D QEMU_DOMAIN_PRIVATE(vm)->driver; g_autoptr(virBitmap) created =3D NULL; + int ret =3D -1; =20 created =3D virBitmapNew(tmpsnapdef->ndisks); =20 + if (qemuSnapshotCreateQcow2Files(driver, domdef, tmpsnapdef, created) = < 0) + goto cleanup; + if (qemuSnapshotDomainDefUpdateDisk(domdef, tmpsnapdef, false) < 0) - return -1; + goto cleanup; =20 - if (qemuSnapshotCreateQcow2Files(driver, domdef, tmpsnapdef, created) = < 0) { + ret =3D 0; + + cleanup: + if (ret < 0 && created) { ssize_t bit =3D -1; virErrorPtr err =3D NULL; =20 @@ -2180,11 +2187,9 @@ qemuSnapshotRevertExternalInactive(virDomainObj *vm, } =20 virErrorRestore(&err); - - return -1; } =20 - return 0; + return ret; } =20 =20 --=20 2.41.0