mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-19 11:05:16 +00:00
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>
This commit is contained in:
parent
30b0e553bc
commit
d51179fa82
@ -3144,6 +3144,8 @@ qemuSnapshotDeleteExternalPrepareData(virDomainObj *vm,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data->parentSnap = qemuSnapshotFindParentSnapForDisk(snap, data->snapDisk);
|
||||||
|
|
||||||
if (data->merge) {
|
if (data->merge) {
|
||||||
virStorageSource *snapDiskSrc = NULL;
|
virStorageSource *snapDiskSrc = NULL;
|
||||||
|
|
||||||
@ -3185,8 +3187,6 @@ qemuSnapshotDeleteExternalPrepareData(virDomainObj *vm,
|
|||||||
qemuSnapshotGetDisksWithBackingStore(vm, snap, data);
|
qemuSnapshotGetDisksWithBackingStore(vm, snap, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
data->parentSnap = qemuSnapshotFindParentSnapForDisk(snap, data->snapDisk);
|
|
||||||
|
|
||||||
if (data->parentSnap && !virDomainSnapshotIsExternal(data->parentSnap)) {
|
if (data->parentSnap && !virDomainSnapshotIsExternal(data->parentSnap)) {
|
||||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
||||||
_("deleting external snapshot that has internal snapshot as parent not supported"));
|
_("deleting external snapshot that has internal snapshot as parent not supported"));
|
||||||
@ -3642,10 +3642,12 @@ qemuSnapshotDiscardExternal(virDomainObj *vm,
|
|||||||
if (!data->job)
|
if (!data->job)
|
||||||
goto error;
|
goto error;
|
||||||
} else {
|
} else {
|
||||||
if (virStorageSourceInit(data->parentDomDisk->src) < 0 ||
|
if (data->parentSnap && virDomainSnapshotIsExternal(data->parentSnap)) {
|
||||||
virStorageSourceUnlink(data->parentDomDisk->src) < 0) {
|
if (virStorageSourceInit(data->parentDomDisk->src) < 0 ||
|
||||||
VIR_WARN("Failed to remove snapshot image '%s'",
|
virStorageSourceUnlink(data->parentDomDisk->src) < 0) {
|
||||||
data->snapDisk->name);
|
VIR_WARN("Failed to remove snapshot image '%s'",
|
||||||
|
data->snapDisk->name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user