mirror of https://gitee.com/openkylin/libvirt.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 <phrdina@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
22a07239f5
commit
403c0cf17f
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue