mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-09-09 09:14:57 +00:00
snapshot: expose new delete flag in virsh
It would technically be possible to have virsh compute the list of descendants of a given snapshot, then delete those one at a time. But it's complex, and not worth writing for a first cut at implementing the new flags. * tools/virsh.c (cmdSnapshotDelete): Add --children-only, --metadata. * tools/virsh.pod (snapshot-delete): Document them.
This commit is contained in:
parent
3d77d0a644
commit
ddc882733a
@ -12769,6 +12769,9 @@ static const vshCmdOptDef opts_snapshot_delete[] = {
|
|||||||
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
|
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
|
||||||
{"snapshotname", VSH_OT_DATA, VSH_OFLAG_REQ, N_("snapshot name")},
|
{"snapshotname", VSH_OT_DATA, VSH_OFLAG_REQ, N_("snapshot name")},
|
||||||
{"children", VSH_OT_BOOL, 0, N_("delete snapshot and all children")},
|
{"children", VSH_OT_BOOL, 0, N_("delete snapshot and all children")},
|
||||||
|
{"children-only", VSH_OT_BOOL, 0, N_("delete children but not snapshot")},
|
||||||
|
{"metadata", VSH_OT_BOOL, 0,
|
||||||
|
N_("delete only libvirt metadata, leaving snapshot contents behind")},
|
||||||
{NULL, 0, 0, NULL}
|
{NULL, 0, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -12793,12 +12796,22 @@ cmdSnapshotDelete(vshControl *ctl, const vshCmd *cmd)
|
|||||||
|
|
||||||
if (vshCommandOptBool(cmd, "children"))
|
if (vshCommandOptBool(cmd, "children"))
|
||||||
flags |= VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN;
|
flags |= VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN;
|
||||||
|
if (vshCommandOptBool(cmd, "children-only"))
|
||||||
|
flags |= VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY;
|
||||||
|
if (vshCommandOptBool(cmd, "metadata"))
|
||||||
|
flags |= VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY;
|
||||||
|
|
||||||
snapshot = virDomainSnapshotLookupByName(dom, name, 0);
|
snapshot = virDomainSnapshotLookupByName(dom, name, 0);
|
||||||
if (snapshot == NULL)
|
if (snapshot == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
/* XXX If we wanted, we could emulate DELETE_CHILDREN_ONLY even on
|
||||||
|
* older servers that reject the flag, by manually computing the
|
||||||
|
* list of descendants. But that's a lot of code to maintain. */
|
||||||
if (virDomainSnapshotDelete(snapshot, flags) == 0) {
|
if (virDomainSnapshotDelete(snapshot, flags) == 0) {
|
||||||
|
if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY)
|
||||||
|
vshPrint(ctl, _("Domain snapshot %s children deleted\n"), name);
|
||||||
|
else
|
||||||
vshPrint(ctl, _("Domain snapshot %s deleted\n"), name);
|
vshPrint(ctl, _("Domain snapshot %s deleted\n"), name);
|
||||||
} else {
|
} else {
|
||||||
vshError(ctl, _("Failed to delete snapshot %s"), name);
|
vshError(ctl, _("Failed to delete snapshot %s"), name);
|
||||||
|
@ -1815,12 +1815,20 @@ I<--running> or I<--paused> flag will perform additional state changes
|
|||||||
transient domains cannot be inactive, it is required to use one of these
|
transient domains cannot be inactive, it is required to use one of these
|
||||||
flags when reverting to a disk snapshot of a transient domain.
|
flags when reverting to a disk snapshot of a transient domain.
|
||||||
|
|
||||||
=item B<snapshot-delete> I<domain> I<snapshot> I<--children>
|
=item B<snapshot-delete> I<domain> I<snapshot> [I<--metadata>]
|
||||||
|
[{I<--children> | I<--children-only>}]
|
||||||
|
|
||||||
Delete the snapshot for the domain named I<snapshot>. If this snapshot
|
Delete the snapshot for the domain named I<snapshot>. If this snapshot
|
||||||
has child snapshots, changes from this snapshot will be merged into the
|
has child snapshots, changes from this snapshot will be merged into the
|
||||||
children. If I<--children> is passed, then delete this snapshot and any
|
children. If I<--children> is passed, then delete this snapshot and any
|
||||||
children of this snapshot.
|
children of this snapshot. If I<--children-only> is passed, then delete
|
||||||
|
any children of this snapshot, but leave this snapshot intact. These
|
||||||
|
two flags are mutually exclusive.
|
||||||
|
|
||||||
|
If I<--metadata> is specified, then only delete the snapshot metadata
|
||||||
|
maintained by libvirt, while leaving the snapshot contents intact for
|
||||||
|
access by external tools; otherwise deleting a snapshot also removes
|
||||||
|
the data contents from that point in time.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user