From: Pavel Hrdina Date: Thu, 2 Mar 2023 22:48:08 +0000 (+0100) Subject: qemu_snapshot: fix external snapshot deletion for non-active snapshots X-Git-Tag: v9.2.0-rc1~115 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=403c0cf17fea62707334726fc4267b7f89aa19f1;p=thirdparty%2Flibvirt.git qemu_snapshot: fix external snapshot deletion for non-active snapshots For shutoff VMs we don't have the storage source backing chain populated so it will fail this check and error out. Move it to part that is done only when VM is running. Signed-off-by: Pavel Hrdina Reviewed-by: Martin Kletzander --- diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 7207b5879a..7aa4195f04 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2331,18 +2331,6 @@ qemuSnapshotDeleteExternalPrepare(virDomainObj *vm, if (!data->domDisk) return -1; - data->diskSrc = virStorageSourceChainLookupBySource(data->domDisk->src, - data->snapDisk->src, - &data->prevDiskSrc); - if (!data->diskSrc) - return -1; - - if (!virStorageSourceIsSameLocation(data->diskSrc, data->snapDisk->src)) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("VM disk source and snapshot disk source are not the same")); - return -1; - } - data->parentDomDisk = virDomainDiskByTarget(snapdef->parent.dom, data->snapDisk->name); if (!data->parentDomDisk) { @@ -2353,6 +2341,18 @@ qemuSnapshotDeleteExternalPrepare(virDomainObj *vm, } if (virDomainObjIsActive(vm)) { + data->diskSrc = virStorageSourceChainLookupBySource(data->domDisk->src, + data->snapDisk->src, + &data->prevDiskSrc); + if (!data->diskSrc) + return -1; + + if (!virStorageSourceIsSameLocation(data->diskSrc, data->snapDisk->src)) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("VM disk source and snapshot disk source are not the same")); + return -1; + } + data->parentDiskSrc = data->diskSrc->backingStore; if (!virStorageSourceIsBacking(data->parentDiskSrc)) { virReportError(VIR_ERR_OPERATION_FAILED, "%s",