/*
* virsh-snapshot.c: Commands to manage domain snapshot
*
- * Copyright (C) 2005, 2007-2016 Red Hat, Inc.
+ * Copyright (C) 2005-2019 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
}
}
}
- qsort(snaplist->snaps, snaplist->nsnaps, sizeof(*snaplist->snaps),
- virshSnapSorter);
+ if (!(orig_flags & VIR_DOMAIN_SNAPSHOT_LIST_TOPOLOGICAL))
+ qsort(snaplist->snaps, snaplist->nsnaps, sizeof(*snaplist->snaps),
+ virshSnapSorter);
snaplist->nsnaps -= deleted;
VIR_STEAL_PTR(ret, snaplist);
.type = VSH_OT_BOOL,
.help = N_("list snapshot names only")
},
+ {.name = "topological",
+ .type = VSH_OT_BOOL,
+ .help = N_("sort list topologically rather than by name"),
+ },
{.name = NULL}
};
FILTER("external", EXTERNAL);
#undef FILTER
+ if (vshCommandOptBool(cmd, "topological"))
+ flags |= VIR_DOMAIN_SNAPSHOT_LIST_TOPOLOGICAL;
+
if (roots)
flags |= VIR_DOMAIN_SNAPSHOT_LIST_ROOTS;
with I<--current>.
=item B<snapshot-list> I<domain> [I<--metadata>] [I<--no-metadata>]
-[{I<--parent> | I<--roots> | [{I<--tree> | I<--name>}]}]
+[{I<--parent> | I<--roots> | [{I<--tree> | I<--name>}]}] [I<--topological>]
[{[I<--from>] B<snapshot> | I<--current>} [I<--descendants>]]
[I<--leaves>] [I<--no-leaves>] [I<--inactive>] [I<--active>]
[I<--disk-only>] [I<--internal>] [I<--external>]
List all of the available snapshots for the given domain, defaulting
to show columns for the snapshot name, creation time, and domain state.
+Normally, table form output is sorted by snapshot name; using
+I<--topological> instead sorts so that no child is listed before its
+ancestors (although there may be more than one possible ordering with
+this property).
+
If I<--parent> is specified, add a column to the output table giving
the name of the parent of each snapshot. If I<--roots> is specified,
the list will be filtered to just snapshots that have no parents.