diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 871e63c9cd..0cac0c4146 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1582,15 +1582,27 @@ qemuSnapshotCreateXMLValidateDef(virDomainObj *vm, * to internal snapshots. */ static bool -qemuSnapshotCreateUseExternal(virDomainSnapshotDef *def, +qemuSnapshotCreateUseExternal(virDomainObj *vm, + virDomainSnapshotDef *def, unsigned int flags) { + size_t i; + if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) return true; if (def->memory == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) return true; + if (!virDomainObjIsActive(vm)) { + /* No need to check all disks as function qemuSnapshotPrepare() guarantees + * that we don't have a combination of internal and external location. */ + for (i = 0; i < def->ndisks; i++) { + if (def->disks[i].snapshot == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) + return true; + } + } + return false; } @@ -1623,7 +1635,7 @@ qemuSnapshotCreateAlignDisks(virDomainObj *vm, return -1; } - if (qemuSnapshotCreateUseExternal(def, flags)) { + if (qemuSnapshotCreateUseExternal(vm, def, flags)) { align_location = VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; def->state = virDomainObjGetState(vm, NULL);