#!/bin/bash # Purpose: Create 100 live (external snapshots)via QMP's `blockdev-snapshot-sync` command set -x let i=0 exec 3<>/dev/tcp/localhost/4444 echo -e "{ 'execute': 'qmp_capabilities' }" >&3 read response <&3 echo $response while [ $i -lt 100 ] do echo -e "{ 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': '/home/kashyap/vmimages/f20vm-snap$i.qcow2', 'format': 'qcow2' } } ] } }" >&3 read response <&3 echo "$i: $response" let i=$i+1 done # Example output of the above snapshot creation on QMP shell would be like this # NOTE: Inovke QEMU with "-qmp tcp:localhost:4444,server" [. . .] Formatting '/home/kashyap/vmimages/f20vm-snap0.qcow2', fmt=qcow2 size=37580963840 backing_file='/home/kashyap/vmimages/f20vm.qcow2' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off Formatting '/home/kashyap/vmimages/foo/f20vm-snap1.qcow2', fmt=qcow2 size=37580963840 backing_file='/home/kashyap/vmimages/f20vm.qcow2' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off Formatting '/home/kashyap/vmimages/foo/f20vm-snap2.qcow2', fmt=qcow2 size=37580963840 backing_file='/home/kashyap/vmimages/f20vm.qcow2' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off Formatting '/home/kashyap/vmimages/foo/f20vm-snap3.qcow2', fmt=qcow2 size=37580963840 backing_file='/home/kashyap/vmimages/f20vm.qcow2' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off Formatting '/home/kashyap/vmimages/foo/f20vm-snap4.qcow2', fmt=qcow2 size=37580963840 backing_file='/home/kashyap/vmimages/f20vm.qcow2' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off Formatting '/home/kashyap/vmimages/foo/f20vm-snap5.qcow2', fmt=qcow2 size=37580963840 backing_file='/home/kashyap/vmimages/f20vm.qcow2' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off Formatting '/home/kashyap/vmimages/foo/f20vm-snap6.qcow2', fmt=qcow2 size=37580963840 backing_file='/home/kashyap/vmimages/f20vm.qcow2' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off Formatting '/home/kashyap/vmimages/foo/f20vm-snap7.qcow2', fmt=qcow2 size=37580963840 backing_file='/home/kashyap/vmimages/f20vm.qcow2' backing_fmt='qcow2' encryption=off cluster_size=65536 lazy_refcounts=off