mirror of https://gitee.com/openkylin/libvirt.git
qemu_snapshot: refactor qemuSnapshotDelete
Move code around to make it clear what is called when deleting single snapshot or children snapshots. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
a784d4076a
commit
06c2382ab9
|
@ -2350,25 +2350,28 @@ qemuSnapshotDelete(virDomainObj *vm,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (snap->nchildren) {
|
|
||||||
rep.dir = cfg->snapshotDir;
|
|
||||||
rep.parent = snap->parent;
|
|
||||||
rep.vm = vm;
|
|
||||||
rep.err = 0;
|
|
||||||
rep.xmlopt = driver->xmlopt;
|
|
||||||
rep.writeMetadata = qemuDomainSnapshotWriteMetadata;
|
|
||||||
virDomainMomentForEachChild(snap,
|
|
||||||
qemuSnapshotChildrenReparent,
|
|
||||||
&rep);
|
|
||||||
if (rep.err < 0)
|
|
||||||
goto endjob;
|
|
||||||
virDomainMomentMoveChildren(snap, snap->parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) {
|
if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) {
|
||||||
virDomainMomentDropChildren(snap);
|
virDomainMomentDropChildren(snap);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
} else {
|
||||||
|
ret = qemuDomainSnapshotDiscard(driver, vm, snap, true, metadata_only);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (snap->nchildren) {
|
||||||
|
rep.dir = cfg->snapshotDir;
|
||||||
|
rep.parent = snap->parent;
|
||||||
|
rep.vm = vm;
|
||||||
|
rep.err = 0;
|
||||||
|
rep.xmlopt = driver->xmlopt;
|
||||||
|
rep.writeMetadata = qemuDomainSnapshotWriteMetadata;
|
||||||
|
virDomainMomentForEachChild(snap,
|
||||||
|
qemuSnapshotChildrenReparent,
|
||||||
|
&rep);
|
||||||
|
if (rep.err < 0)
|
||||||
|
goto endjob;
|
||||||
|
virDomainMomentMoveChildren(snap, snap->parent);
|
||||||
|
}
|
||||||
ret = qemuDomainSnapshotDiscard(driver, vm, snap, true, metadata_only);
|
ret = qemuDomainSnapshotDiscard(driver, vm, snap, true, metadata_only);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue