libvirt/tools
Eric Blake c615c14246 virsh: Add snapshot-list --topological
For snapshots, virsh already has a (shockingly naive [1]) client-side
topological sorter with the --tree option. But as a series of REDEFINE
calls must be presented in topological order, it's worth letting the
server do the work for us, especially since the server can give us a
topological sorting with less effort than our naive client
reconstruction.

[1] The XXX comment in virshSnapshotListCollect() about --tree being
O(n^3) is telling; https://en.wikipedia.org/wiki/Topological_sorting
is an interesting resource describing Kahn's algorithm and other
approaches for O(n) topological sorting for anyone motivated to use a
more elegant algorithm than brute force - but that doesn't affect this
patch.

For now, I am purposefully NOT implementing virsh fallback code to
provide a topological sort when the flag was rejected as unsupported;
we can worry about that down the road if users actually demonstrate
that they use new virsh but old libvirt to even need the fallback.
(The code we use for --tree could be repurposed to be such a fallback,
whether or not we keep it naive or improve it to be faster - but
again, no one should spend time on a fallback without evidence that we
need it.)

The test driver makes it easy to test:
$ virsh -c test:///default '
snapshot-create-as test a
snapshot-create-as test c
snapshot-create-as test b
snapshot-list test
snapshot-list test --topological
snapshot-list test --descendants a
snapshot-list test --descendants a --topological
snapshot-list test --tree
snapshot-list test --tree --topological
'

Without any flags, virsh does client-side sorting alphabetically, and
lists 'b' before 'c' (even though 'c' is the parent of 'b'); with the
flag, virsh skips sorting, and you can now see that the server handed
back data in a correct ordering. As shown here with a simple linear
chain, there isn't any other possible ordering, so --tree mode doesn't
seem to care whether --topological is used.  But it is possible to
compose more complicated DAGs with multiple children to a parent
(representing reverting back to a snapshot then creating more
snapshots along those divergent execution timelines), where it is then
possible (but not guaranteed) that adding the --topological flag
changes the --tree output (the client-side --tree algorithm breaks
ties based on alphabetical sorting between two nodes that share the
same parent, while the --topological sort skips the client-side
alphabetical sort and ends up exposing the server's internal order for
siblings, whether that be historical creation order or dependent on a
random hash seed).  But even if the results differ, they will still be
topologically correct.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2019-03-12 20:46:09 -05:00
..
bash-completion tools: Provide bash autompletion file 2018-01-11 18:53:04 +01:00
nss Use virStringHasSuffix() where possible 2019-03-07 10:10:49 +01:00
wireshark tools: Drop support for pre-2.4.0 wireshark 2019-02-12 09:22:59 +01:00
libvirt_recover_xattrs.sh tools: Provide a script to recover fubar'ed XATTRs setup 2018-12-19 15:32:45 +01:00
libvirt_win_icon_16x16.ico
libvirt_win_icon_32x32.ico
libvirt_win_icon_48x48.ico
libvirt_win_icon_64x64.ico
libvirt-guests.init.in Use https:// links for most sites 2017-10-16 10:22:34 +01:00
libvirt-guests.service.in Use https:// links for most sites 2017-10-16 10:22:34 +01:00
libvirt-guests.sh.in tools: do not report unknown guests in print_guests_shutdown 2018-04-24 10:46:41 +02:00
libvirt-guests.sysconf lxc: allow use of lxc:///system URI as preferred format 2018-04-12 16:52:01 +01:00
Makefile.am tools: Keep wireshark plugin registration code in git 2019-02-12 09:22:59 +01:00
virsh_win_icon.rc
virsh-completer.c virsh: Add event name completion to 'network-event' command 2019-03-05 09:09:48 +01:00
virsh-completer.h virsh: Add event name completion to 'network-event' command 2019-03-05 09:09:48 +01:00
virsh-console.c Remove all Author(s): lines from source file headers 2018-12-13 16:08:38 +00:00
virsh-console.h Enforce a standard header file guard symbol name 2018-12-14 10:47:13 +00:00
virsh-domain-monitor.c Use NULLSTR_EMPTY 2019-02-14 14:09:38 +01:00
virsh-domain-monitor.h Remove even more Author(s): lines from source files 2019-01-03 13:24:18 +01:00
virsh-domain.c virsh: Add device name completion for target option of detach-disk command 2019-03-05 09:09:48 +01:00
virsh-domain.h Remove even more Author(s): lines from source files 2019-01-03 13:24:18 +01:00
virsh-edit.c Remove even more Author(s): lines from source files 2019-01-03 13:24:18 +01:00
virsh-host.c Remove even more Author(s): lines from source files 2019-01-03 13:24:18 +01:00
virsh-host.h Remove even more Author(s): lines from source files 2019-01-03 13:24:18 +01:00
virsh-interface.c Remove even more Author(s): lines from source files 2019-01-03 13:24:18 +01:00
virsh-interface.h Remove even more Author(s): lines from source files 2019-01-03 13:24:18 +01:00
virsh-network.c virsh: Add event name completion to 'network-event' command 2019-03-05 09:09:48 +01:00
virsh-network.h virsh-network: Introduce virshNetworkEventCallback to handle network events 2019-03-05 09:09:48 +01:00
virsh-nodedev.c Require a semicolon for VIR_ENUM_IMPL calls 2019-02-03 17:46:29 -05:00
virsh-nodedev.h Remove even more Author(s): lines from source files 2019-01-03 13:24:18 +01:00
virsh-nwfilter.c Remove even more Author(s): lines from source files 2019-01-03 13:24:18 +01:00
virsh-nwfilter.h Remove even more Author(s): lines from source files 2019-01-03 13:24:18 +01:00
virsh-pool.c virsh: Expose virConnectGetStoragePoolCapabilities 2019-03-06 11:12:48 -05:00
virsh-pool.h Remove even more Author(s): lines from source files 2019-01-03 13:24:18 +01:00
virsh-secret.c Require a semicolon for VIR_ENUM_IMPL calls 2019-02-03 17:46:29 -05:00
virsh-secret.h Remove even more Author(s): lines from source files 2019-01-03 13:24:18 +01:00
virsh-snapshot.c virsh: Add snapshot-list --topological 2019-03-12 20:46:09 -05:00
virsh-snapshot.h Remove even more Author(s): lines from source files 2019-01-03 13:24:18 +01:00
virsh-util.c all: Replace virGetLastError with virGetLastErrorCode where we can 2018-06-05 18:44:05 +02:00
virsh-util.h Enforce a standard header file guard symbol name 2018-12-14 10:47:13 +00:00
virsh-volume.c Require a semicolon for VIR_ENUM_IMPL calls 2019-02-03 17:46:29 -05:00
virsh-volume.h Remove even more Author(s): lines from source files 2019-01-03 13:24:18 +01:00
virsh.c Remove even more Author(s): lines from source files 2019-01-03 13:24:18 +01:00
virsh.h Remove even more Author(s): lines from source files 2019-01-03 13:24:18 +01:00
virsh.pod virsh: Add snapshot-list --topological 2019-03-12 20:46:09 -05:00
virt-admin-completer.c Remove even more Author(s): lines from source files 2019-01-03 13:24:18 +01:00
virt-admin-completer.h Remove even more Author(s): lines from source files 2019-01-03 13:24:18 +01:00
virt-admin.c Use NULLSTR_EMPTY 2019-02-14 14:09:38 +01:00
virt-admin.h Remove even more Author(s): lines from source files 2019-01-03 13:24:18 +01:00
virt-admin.pod virsh: Elide backslash-newline in batch mode 2019-02-26 15:42:21 -06:00
virt-host-validate-bhyve.c internal: Move <stdio.h> include to internal.h 2018-09-20 10:16:38 +02:00
virt-host-validate-bhyve.h Enforce a standard header file guard symbol name 2018-12-14 10:47:13 +00:00
virt-host-validate-common.c tools/virt-host-validate: Fix IOMMU check on s390x 2019-03-08 09:16:00 +01:00
virt-host-validate-common.h Enforce a standard header file guard symbol name 2018-12-14 10:47:13 +00:00
virt-host-validate-lxc.c virt-host-validate: require freezer for LXC 2018-10-05 15:53:29 +02:00
virt-host-validate-lxc.h Enforce a standard header file guard symbol name 2018-12-14 10:47:13 +00:00
virt-host-validate-qemu.c virt-host-validate: rewrite cgroup detection to use util/vircgroup 2018-10-05 15:53:29 +02:00
virt-host-validate-qemu.h Enforce a standard header file guard symbol name 2018-12-14 10:47:13 +00:00
virt-host-validate.c src: More cleanup of some system headers already contained in internal.h 2018-09-20 10:16:39 +02:00
virt-host-validate.pod Use https:// links for most sites 2017-10-16 10:22:34 +01:00
virt-login-shell.c Remove even more Author(s): lines from source files 2019-01-03 13:24:18 +01:00
virt-login-shell.conf virt-login-shell: add ability to auto-detect shell from container 2016-06-10 11:03:02 +01:00
virt-login-shell.pod Use https:// links for most sites 2017-10-16 10:22:34 +01:00
virt-pki-validate.in tools: rename S_ORG to C_ORG in virt-pki-validate 2018-12-11 14:58:43 +00:00
virt-pki-validate.pod Use https:// links for most sites 2017-10-16 10:22:34 +01:00
virt-sanlock-cleanup.in build: Extract pod from source files 2016-04-25 15:40:43 +02:00
virt-sanlock-cleanup.pod Use https:// links for most sites 2017-10-16 10:22:34 +01:00
virt-xml-validate.in tools/virt-xml-validate: Fix GPL information 2019-01-25 14:04:19 +01:00
virt-xml-validate.pod virt-xml-validate: Add schema for nwfilterbinding 2018-07-19 16:16:57 -04:00
vsh-table.c vsh-table: allow empty columns 2019-02-12 10:14:53 +01:00
vsh-table.h Enforce a standard header file guard symbol name 2018-12-14 10:47:13 +00:00
vsh.c tools: vsh: Don't use assert() 2019-03-12 14:17:02 +01:00
vsh.h Remove even more Author(s): lines from source files 2019-01-03 13:24:18 +01:00