Snapshots --------- There's multiple different ways to create snapshots, the below covers some basics. Internal snapshots ~~~~~~~~~~~~~~~~~~ Original and delta are stored in the same QCOW2 file; the disk image _must_ be QCOW2 format: - Create an 'internal' snapshot: $ virsh snapshot-create-as f24vm snap1 "Clean Fedora-24" - Revert to a previously known sane state: $ virsh snapshot-revert f24vm snap1 External snapshots ------------------ Everytime a snapshot is taken, the current disk becomes a 'backing le' & a new QCOW2 overlay is created to track the 'delta'. (Snapshots are created instantaneous; excellent for live backups.) - Create external live disk-only snapshot: $ virsh snapshot-create-as \ --domain vm1 sn1 \ --diskspec vda,file=/export/images/sn1.qcow2 \ --disk-only --atomic - Create an external live disk *and* memory live snapshot: $ virsh snapshot-create-as \ --domain ostack-controller snap1 \ --diskspec vda,file=/export/vmimages/disk-snap.qcow2,snapshot=external \ --memspec file=/export/vmimages/mem-snap.qcow2,snapshot=external \ --atomic Merging external snapshots ~~~~~~~~~~~~~~~~~~~~~~~~~~ - Merge an entire chain (including current active image) into its base image http://wiki.libvirt.org/page/Live-merge-an-entire-disk-image-chain-including-current-active-disk - Efficient live disk backup with active blockcommit http://wiki.libvirt.org/page/Live-disk-backup-with-active-blockcommit Networks -------- - To create a new libvirt network https://kashyapc.fedorapeople.org/virt/create-a-new-libvirt-bridge.txt - To hot add a new NIC https://kashyapc.fedorapeople.org/virt/add-network-card-in-guest.txt Monitoring Block layer QEMU events from libvirt ----------------------------------------------- On shell 1, monitor the QEMU events from `virsh`: $ virsh qemu-monitor-event --pretty --loop cirrvm event BLOCK_JOB_READY at 1430299466.819642 for domain cirrvm: { "device": "drive-ide0-0-0", "len": 41126400, "offset": 41126400, "speed": 0, "type": "mirror" } event BLOCK_JOB_COMPLETED at 1430299467.206985 for domain cirrvm: { "device": "drive-ide0-0-0", "len": 41126400, "offset": 41126400, "speed": 0, "type": "mirror" } On shell 2, run a live `blockcopy` test: $ virsh dumpxml --inactive cirrvm > /var/tmp/cirrvm.xml $ virsh undefine cirrvm $ virsh blockcopy cirrvm hda /export/copy-cirrvm-0.3.3.qcow2 \ --wait --verbose --shallow --finish Block Copy: [100 %] Successfully copied $ virsh define /var/tmp/cirrvm.xml