Create a series of snapshots, with names that intentionally sort
differently by topology than by name. Use revert to create fanout.
Domain snapshot s1 created
error: operation failed: domain moment s1 already exists

Domain snapshot s3 created
Domain snapshot s2 created
Domain snapshot s3 reverted

Domain snapshot s6 created
Domain snapshot s5 created
Domain snapshot s6 reverted

Domain snapshot s4 created
Domain snapshot s1 reverted

Domain snapshot s7 created
Domain snapshot s8 created
checkpoints cannot be created while snapshots exist
error: Operation not supported: cannot create checkpoint while snapshot exists

Checking tree view (siblings sorted alphabetically)
s1
  |
  +- s3
  |   |
  |   +- s2
  |   +- s6
  |       |
  |       +- s4
  |       +- s5
  |         
  +- s7
      |
      +- s8
        

Current was last one created, but we can change that
s8
Snapshot s1 set as current
s1
Deleting current root leads to multiple roots, demonstrate list filtering
Domain snapshot s1 deleted

error: domain 'test' has no current snapshot

list roots
s3
s7

list leaves
s2
s4
s5
s8

list no-leaves
s3
s6	s3
s7

list from
s2
s6

s2
s4
s5
s6

More fun with delete flags, current node moves up to remaining parent
Snapshot s4 set as current
Domain snapshot s6 children deleted

s6
Domain snapshot s7 deleted

s6
Domain snapshot s6 deleted

s3
Now the tree is linear, so we have an unambiguous topological order
s2
s3

s3
s2

<domainsnapshot>
  <name>s3</name>
  <state>running</state>
  
  <memory snapshot='internal'/>
  <disks>
    <disk name='vda' snapshot='internal'/>
  </disks>
  <domain type='test'>
    <name>test</name>
    <uuid>6695eb01-f6a4-8304-79aa-97f2502e193f</uuid>
    <memory unit='KiB'>8388608</memory>
    <currentMemory unit='KiB'>2097152</currentMemory>
    <vcpu placement='static'>2</vcpu>
    <os>
      <type arch='i686'>hvm</type>
      <boot dev='hd'/>
    </os>
    <clock offset='utc'/>
    <on_poweroff>destroy</on_poweroff>
    <on_reboot>restart</on_reboot>
    <on_crash>destroy</on_crash>
    <devices>
      <disk type='file' device='disk'>
        <source file='/guest/diskimage1'/>
        <target dev='vda' bus='virtio'/>
        <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
      </disk>
      <interface type='network'>
        <mac address='aa:bb:cc:dd:ee:ff'/>
        <source network='default'/>
        <target dev='testnet0'/>
        <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
      </interface>
      <memballoon model='virtio'>
        <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
      </memballoon>
    </devices>
  </domain>
</domainsnapshot>

<domainsnapshot>
  <name>s2</name>
  <state>running</state>
  <parent>
    <name>s3</name>
  </parent>
  
  <memory snapshot='internal'/>
  <disks>
    <disk name='vda' snapshot='internal'/>
  </disks>
  <domain type='test'>
    <name>test</name>
    <uuid>6695eb01-f6a4-8304-79aa-97f2502e193f</uuid>
    <memory unit='KiB'>8388608</memory>
    <currentMemory unit='KiB'>2097152</currentMemory>
    <vcpu placement='static'>2</vcpu>
    <os>
      <type arch='i686'>hvm</type>
      <boot dev='hd'/>
    </os>
    <clock offset='utc'/>
    <on_poweroff>destroy</on_poweroff>
    <on_reboot>restart</on_reboot>
    <on_crash>destroy</on_crash>
    <devices>
      <disk type='file' device='disk'>
        <source file='/guest/diskimage1'/>
        <target dev='vda' bus='virtio'/>
        <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
      </disk>
      <interface type='network'>
        <mac address='aa:bb:cc:dd:ee:ff'/>
        <source network='default'/>
        <target dev='testnet0'/>
        <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
      </interface>
      <memballoon model='virtio'>
        <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
      </memballoon>
    </devices>
  </domain>
</domainsnapshot>