Move it to code path for creating new snapshot. Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx> --- src/qemu/qemu_snapshot.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 6860133bbb..9a3f90e346 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1703,7 +1703,6 @@ qemuSnapshotCreateXML(virDomainPtr domain, virQEMUDriver *driver = domain->conn->privateData; virDomainMomentObj *snap = NULL; virDomainSnapshotPtr snapshot = NULL; - virDomainMomentObj *current = NULL; bool update_current = true; bool redefine = flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE; g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); @@ -1767,6 +1766,8 @@ qemuSnapshotCreateXML(virDomainPtr domain, goto endjob; } } else { + virDomainMomentObj *current = NULL; + if (qemuSnapshotAlignDisks(vm, def, driver, flags) < 0) goto endjob; @@ -1777,12 +1778,11 @@ qemuSnapshotCreateXML(virDomainPtr domain, goto endjob; def = NULL; - } - current = virDomainSnapshotGetCurrent(vm->snapshots); - if (current) { - if (!redefine) + current = virDomainSnapshotGetCurrent(vm->snapshots); + if (current) { snap->def->parent_name = g_strdup(current->def->name); + } } /* actually do the snapshot */ -- 2.31.1