mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
qemu_snapshot: remove memory snapshot when deleting external snapshot
When deleting external snapshot we should remove the memory snapshot file as well. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
0261c2ab42
commit
356e227208
@ -2684,9 +2684,11 @@ qemuSnapshotSetInvalid(virDomainObj *vm,
|
||||
|
||||
static int
|
||||
qemuSnapshotDiscardExternal(virDomainObj *vm,
|
||||
virDomainMomentObj *snap,
|
||||
GSList *externalData)
|
||||
{
|
||||
GSList *cur = NULL;
|
||||
virDomainSnapshotDef *snapdef = virDomainSnapshotObjGetDef(snap);
|
||||
|
||||
for (cur = externalData; cur; cur = g_slist_next(cur)) {
|
||||
qemuSnapshotDeleteExternalData *data = cur->data;
|
||||
@ -2756,6 +2758,14 @@ qemuSnapshotDiscardExternal(virDomainObj *vm,
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (snapdef->memory == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL &&
|
||||
snapdef->memorysnapshotfile) {
|
||||
if (unlink(snapdef->memorysnapshotfile) < 0) {
|
||||
VIR_WARN("failed to remove memory snapshot '%s'",
|
||||
snapdef->memorysnapshotfile);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
@ -2886,7 +2896,7 @@ qemuSnapshotDiscardImpl(virQEMUDriver *driver,
|
||||
}
|
||||
|
||||
if (virDomainSnapshotIsExternal(snap)) {
|
||||
if (qemuSnapshotDiscardExternal(vm, externalData) < 0)
|
||||
if (qemuSnapshotDiscardExternal(vm, snap, externalData) < 0)
|
||||
return -1;
|
||||
} else {
|
||||
if (qemuDomainSnapshotForEachQcow2(driver, def, snap, "-d", true) < 0)
|
||||
@ -2894,7 +2904,7 @@ qemuSnapshotDiscardImpl(virQEMUDriver *driver,
|
||||
}
|
||||
} else {
|
||||
if (virDomainSnapshotIsExternal(snap)) {
|
||||
if (qemuSnapshotDiscardExternal(vm, externalData) < 0)
|
||||
if (qemuSnapshotDiscardExternal(vm, snap, externalData) < 0)
|
||||
return -1;
|
||||
} else {
|
||||
/* Similarly as internal snapshot creation we would use a regular job
|
||||
|
Loading…
Reference in New Issue
Block a user