|
|
acda74 |
From 7289999ecc435bcc65881c64b49efba9746a9571 Mon Sep 17 00:00:00 2001
|
|
|
acda74 |
Message-Id: <7289999ecc435bcc65881c64b49efba9746a9571@dist-git>
|
|
|
acda74 |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
acda74 |
Date: Tue, 21 Feb 2023 16:52:28 +0100
|
|
|
acda74 |
Subject: [PATCH] qemu_snapshot: refactor qemuSnapshotDeleteExternalPrepare
|
|
|
acda74 |
|
|
|
acda74 |
When user creates external snapshot with making only memory snapshot
|
|
|
acda74 |
without any disks deleting that snapshot failed without reporting any
|
|
|
acda74 |
meaningful error.
|
|
|
acda74 |
|
|
|
acda74 |
The issue is that the qemuSnapshotDeleteExternalPrepare function
|
|
|
acda74 |
returns NULL because the returned list is empty. This will not change
|
|
|
acda74 |
so to make it clear if the function fails or not return int instead and
|
|
|
acda74 |
have another parameter where we can pass the list.
|
|
|
acda74 |
|
|
|
acda74 |
With the fixed memory snapshot deletion it will now correctly delete
|
|
|
acda74 |
memory only snapshot as well.
|
|
|
acda74 |
|
|
|
acda74 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2170826
|
|
|
acda74 |
|
|
|
acda74 |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
acda74 |
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
acda74 |
(cherry picked from commit e3957c22462bc52c37c94ca4d6fe3d26f8202119)
|
|
|
acda74 |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
acda74 |
---
|
|
|
acda74 |
src/qemu/qemu_snapshot.c | 28 +++++++++++++++-------------
|
|
|
acda74 |
1 file changed, 15 insertions(+), 13 deletions(-)
|
|
|
acda74 |
|
|
|
acda74 |
diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
|
|
|
acda74 |
index 5cdcbc6290..cfa531edef 100644
|
|
|
acda74 |
--- a/src/qemu/qemu_snapshot.c
|
|
|
acda74 |
+++ b/src/qemu/qemu_snapshot.c
|
|
|
acda74 |
@@ -2301,9 +2301,10 @@ qemuSnapshotFindParentSnapForDisk(virDomainMomentObj *snap,
|
|
|
acda74 |
}
|
|
|
acda74 |
|
|
|
acda74 |
|
|
|
acda74 |
-static GSList*
|
|
|
acda74 |
+static int
|
|
|
acda74 |
qemuSnapshotDeleteExternalPrepare(virDomainObj *vm,
|
|
|
acda74 |
- virDomainMomentObj *snap)
|
|
|
acda74 |
+ virDomainMomentObj *snap,
|
|
|
acda74 |
+ GSList **externalData)
|
|
|
acda74 |
{
|
|
|
acda74 |
ssize_t i;
|
|
|
acda74 |
virDomainSnapshotDef *snapdef = virDomainSnapshotObjGetDef(snap);
|
|
|
acda74 |
@@ -2320,7 +2321,7 @@ qemuSnapshotDeleteExternalPrepare(virDomainObj *vm,
|
|
|
acda74 |
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
|
acda74 |
_("snapshot disk '%s' was target of not completed snapshot delete"),
|
|
|
acda74 |
snapDisk->name);
|
|
|
acda74 |
- return NULL;
|
|
|
acda74 |
+ return -1;
|
|
|
acda74 |
}
|
|
|
acda74 |
|
|
|
acda74 |
data = g_new0(qemuSnapshotDeleteExternalData, 1);
|
|
|
acda74 |
@@ -2328,18 +2329,18 @@ qemuSnapshotDeleteExternalPrepare(virDomainObj *vm,
|
|
|
acda74 |
|
|
|
acda74 |
data->domDisk = qemuDomainDiskByName(vm->def, snapDisk->name);
|
|
|
acda74 |
if (!data->domDisk)
|
|
|
acda74 |
- return NULL;
|
|
|
acda74 |
+ return -1;
|
|
|
acda74 |
|
|
|
acda74 |
data->diskSrc = virStorageSourceChainLookupBySource(data->domDisk->src,
|
|
|
acda74 |
data->snapDisk->src,
|
|
|
acda74 |
&data->prevDiskSrc);
|
|
|
acda74 |
if (!data->diskSrc)
|
|
|
acda74 |
- return NULL;
|
|
|
acda74 |
+ return -1;
|
|
|
acda74 |
|
|
|
acda74 |
if (!virStorageSourceIsSameLocation(data->diskSrc, data->snapDisk->src)) {
|
|
|
acda74 |
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
|
|
|
acda74 |
_("VM disk source and snapshot disk source are not the same"));
|
|
|
acda74 |
- return NULL;
|
|
|
acda74 |
+ return -1;
|
|
|
acda74 |
}
|
|
|
acda74 |
|
|
|
acda74 |
data->parentDomDisk = virDomainDiskByTarget(snapdef->parent.dom,
|
|
|
acda74 |
@@ -2348,7 +2349,7 @@ qemuSnapshotDeleteExternalPrepare(virDomainObj *vm,
|
|
|
acda74 |
virReportError(VIR_ERR_OPERATION_FAILED,
|
|
|
acda74 |
_("failed to find disk '%s' in snapshot VM XML"),
|
|
|
acda74 |
snapDisk->name);
|
|
|
acda74 |
- return NULL;
|
|
|
acda74 |
+ return -1;
|
|
|
acda74 |
}
|
|
|
acda74 |
|
|
|
acda74 |
if (virDomainObjIsActive(vm)) {
|
|
|
acda74 |
@@ -2356,13 +2357,13 @@ qemuSnapshotDeleteExternalPrepare(virDomainObj *vm,
|
|
|
acda74 |
if (!virStorageSourceIsBacking(data->parentDiskSrc)) {
|
|
|
acda74 |
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
|
|
|
acda74 |
_("failed to find parent disk source in backing chain"));
|
|
|
acda74 |
- return NULL;
|
|
|
acda74 |
+ return -1;
|
|
|
acda74 |
}
|
|
|
acda74 |
|
|
|
acda74 |
if (!virStorageSourceIsSameLocation(data->parentDiskSrc, data->parentDomDisk->src)) {
|
|
|
acda74 |
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
|
|
|
acda74 |
_("snapshot VM disk source and parent disk source are not the same"));
|
|
|
acda74 |
- return NULL;
|
|
|
acda74 |
+ return -1;
|
|
|
acda74 |
}
|
|
|
acda74 |
}
|
|
|
acda74 |
|
|
|
acda74 |
@@ -2371,15 +2372,16 @@ qemuSnapshotDeleteExternalPrepare(virDomainObj *vm,
|
|
|
acda74 |
if (data->parentSnap && !virDomainSnapshotIsExternal(data->parentSnap)) {
|
|
|
acda74 |
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
|
|
acda74 |
_("deleting external snapshot that has internal snapshot as parent not supported"));
|
|
|
acda74 |
- return NULL;
|
|
|
acda74 |
+ return -1;
|
|
|
acda74 |
}
|
|
|
acda74 |
|
|
|
acda74 |
ret = g_slist_prepend(ret, g_steal_pointer(&data));
|
|
|
acda74 |
}
|
|
|
acda74 |
|
|
|
acda74 |
ret = g_slist_reverse(ret);
|
|
|
acda74 |
+ *externalData = g_steal_pointer(&ret;;
|
|
|
acda74 |
|
|
|
acda74 |
- return g_steal_pointer(&ret;;
|
|
|
acda74 |
+ return 0;
|
|
|
acda74 |
}
|
|
|
acda74 |
|
|
|
acda74 |
|
|
|
acda74 |
@@ -3159,7 +3161,7 @@ qemuSnapshotDelete(virDomainObj *vm,
|
|
|
acda74 |
g_autoslist(qemuSnapshotDeleteExternalData) tmpData = NULL;
|
|
|
acda74 |
|
|
|
acda74 |
/* this also serves as validation whether the snapshot can be deleted */
|
|
|
acda74 |
- if (!(tmpData = qemuSnapshotDeleteExternalPrepare(vm, snap)))
|
|
|
acda74 |
+ if (qemuSnapshotDeleteExternalPrepare(vm, snap, &tmpData) < 0)
|
|
|
acda74 |
goto endjob;
|
|
|
acda74 |
|
|
|
acda74 |
if (!virDomainObjIsActive(vm)) {
|
|
|
acda74 |
@@ -3174,7 +3176,7 @@ qemuSnapshotDelete(virDomainObj *vm,
|
|
|
acda74 |
|
|
|
acda74 |
/* Call the prepare again as some data require that the VM is
|
|
|
acda74 |
* running to get everything we need. */
|
|
|
acda74 |
- if (!(externalData = qemuSnapshotDeleteExternalPrepare(vm, snap)))
|
|
|
acda74 |
+ if (qemuSnapshotDeleteExternalPrepare(vm, snap, &externalData) < 0)
|
|
|
acda74 |
goto endjob;
|
|
|
acda74 |
} else {
|
|
|
acda74 |
qemuDomainJobPrivate *jobPriv = vm->job->privateData;
|
|
|
acda74 |
--
|
|
|
acda74 |
2.39.1
|
|
|
acda74 |
|