import OL

This commit is contained in:
eabdullin 2025-03-19 14:46:26 +03:00
parent 67bd732fb9
commit c982bef298
2 changed files with 81 additions and 2 deletions

View File

@ -0,0 +1,71 @@
From 97f5f89dbfb8a6a896a488a9e61a55f16074586e Mon Sep 17 00:00:00 2001
Message-ID: <97f5f89dbfb8a6a896a488a9e61a55f16074586e.1737462828.git.jdenemar@redhat.com>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Thu, 9 Jan 2025 16:23:44 +0100
Subject: [PATCH] qemu: snapshot: delete disk image only if parent snapshot is
external
When we are deleting external snapshot that is not active we only need
to delete overlay disk image of the parent snapshot. This works
correctly even if parent snapshot is external and active as it will have
another overlay created when user reverted to that snapshot.
In case the parent snapshot is internal there are no overlay disk images
created as everything is stored internally within the disk image. In
this case we would delete the actual disk image storing internal
snapshots and most likely the original disk image as well resulting in
data loss once the VM is shutoff.
Fixes: https://gitlab.com/libvirt/libvirt/-/issues/734
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
(cherry picked from commit d51179fa82448f4720f1645f0b7100df80508cc4)
https://issues.redhat.com/browse/RHEL-75154
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
src/qemu/qemu_snapshot.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index f5260c4a22..e42f80f2f9 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -2884,6 +2884,8 @@ qemuSnapshotDeleteExternalPrepareData(virDomainObj *vm,
return -1;
}
+ data->parentSnap = qemuSnapshotFindParentSnapForDisk(snap, data->snapDisk);
+
if (data->merge) {
virStorageSource *snapDiskSrc = NULL;
@@ -2925,8 +2927,6 @@ qemuSnapshotDeleteExternalPrepareData(virDomainObj *vm,
qemuSnapshotGetDisksWithBackingStore(vm, snap, data);
}
- data->parentSnap = qemuSnapshotFindParentSnapForDisk(snap, data->snapDisk);
-
if (data->parentSnap && !virDomainSnapshotIsExternal(data->parentSnap)) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("deleting external snapshot that has internal snapshot as parent not supported"));
@@ -3392,10 +3392,12 @@ qemuSnapshotDiscardExternal(virDomainObj *vm,
if (!data->job)
goto error;
} else {
- if (virStorageSourceInit(data->parentDomDisk->src) < 0 ||
- virStorageSourceUnlink(data->parentDomDisk->src) < 0) {
- VIR_WARN("Failed to remove snapshot image '%s'",
- data->snapDisk->name);
+ if (data->parentSnap && virDomainSnapshotIsExternal(data->parentSnap)) {
+ if (virStorageSourceInit(data->parentDomDisk->src) < 0 ||
+ virStorageSourceUnlink(data->parentDomDisk->src) < 0) {
+ VIR_WARN("Failed to remove snapshot image '%s'",
+ data->snapDisk->name);
+ }
}
}
}
--
2.48.1

View File

@ -289,7 +289,7 @@
Summary: Library providing a simple virtualization API
Name: libvirt
Version: 10.5.0
Release: 7.4%{?dist}%{?extra_release}
Release: 7.5.0.1%{?dist}%{?extra_release}
License: GPL-2.0-or-later AND LGPL-2.1-only AND LGPL-2.1-or-later AND OFL-1.1
URL: https://libvirt.org/
@ -339,6 +339,7 @@ Patch39: libvirt-qemu-Turn-EIM-IOMMU-on-automagically.patch
Patch40: libvirt-qemu_domain-Automagically-add-IOMMU-if-needed.patch
Patch41: libvirt-qemu-Enable-I-O-APIC-if-needed.patch
Patch42: libvirt-qemu-Enable-I-O-APIC-even-more-frequently.patch
Patch43: libvirt-qemu-snapshot-delete-disk-image-only-if-parent-snapshot-is-external.patch
Requires: libvirt-daemon = %{version}-%{release}
@ -1363,7 +1364,8 @@ exit 1
%define arg_packager_version -Dpackager_version="%{release}"
%define arg_selinux_mount -Dselinux_mount="/sys/fs/selinux"
# place macros above and build commands below this comment
# Set SOURCE_DATE_EPOCH from changelog
%define source_date_epoch_from_changelog 1
export SOURCE_DATE_EPOCH=$(stat --printf='%Y' %{_specdir}/libvirt.spec)
@ -2667,6 +2669,12 @@ exit 0
%endif
%changelog
* Tue Mar 18 2025 EL Errata <el-errata_ww@oracle.com> - 10.5.0-7.5.0.1.el9_5
- Set SOURCE_DATE_EPOCH from changelog [Orabug: 32019554]
* Tue Jan 21 2025 Jiri Denemark <jdenemar@redhat.com> - 10.5.0-7.5.el9_5
- qemu: snapshot: delete disk image only if parent snapshot is external (RHEL-75154)
* Fri Dec 20 2024 Jiri Denemark <jdenemar@redhat.com> - 10.5.0-7.4.el9_5
- qemu: Enable I/O APIC if needed (RHEL-69725)
- qemu: Enable I/O APIC even more frequently (RHEL-69725)