[21-APR-2015] Purpose: Test dirty-bitmap with `drive-backup` in QEMU Prequisites =========== I tested with this branch: https://github.com/jnsnow/qemu/commits/incremental-transactions $ git checkout -b v2.5-and-v6-inc-backup jsnow/incremental-transactions $ git describe v2.3.0-rc3-37-g6932a32 Test ==== (1) Invoke QEMU w/ QMP server over Unix socket: --------------- $ ./invoke-qemu-with-qmp.sh . . . -qmp unix:./qmp-sock,server char device redirected to /dev/pts/49 (label charserial0) QEMU waiting for connection on: disconnected:unix:./qmp-sock,server --------------- (2) Pre-create the target destination: $ qemu-img create -f qcow2 incremental.0.img -b full_backup.img -F qcow2 (3) And, use `rlwrap` in combination with `socat` (previously learnt this trick from Markus Armbruster, it conveniently retains the command history) to connect to the QMP server and issue 'block-dirty-bitmap-add' and 'drive-mirror' commands with 'dirty-bitmap': ---------------- $ rlwrap -H ~/.qmp_history socat UNIX-CONNECT:./qmp-sock STDIO {"QMP": {"version": {"qemu": {"micro": 93, "minor": 2, "major": 2}, "package": ""}, "capabilities": []}} {"execute":"qmp_capabilities"} {"return": {}} { 'execute': 'block-dirty-bitmap-add', 'arguments': { 'node': 'drive-ide0-0-0', 'name': 'bitmap0' } } {"return": {}} { 'execute': 'drive-backup', 'arguments': { 'device': 'drive-ide0-0-0', 'bitmap': 'bitmap0', 'sync': 'dirty-bitmap', 'target': +'/home/kashyapc/work/virt/qemu/incremental-backup-test-qemu/tests/incremental.0.img', 'mode': 'existing', 'format': 'qcow2' } } {"return": {}} {"timestamp": {"seconds": 1429647518, "microseconds": 663755}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "drive-ide0-0-0", "len": 41126400, "offset": 41156608, "speed": 0, "type": +"backup"}} ---------------- Additional notes ================ Comments from eblake on running QMP: - It will require additional reads to see the event lines (qemu sends events as the job makes progress) - when you first connect, the qemu sends a line BEFORE you send your 'qmp_capabilities' response so you're off by one if you don't read the initial server greeting - I'm not sure how modal QMP is - that is, I don't know if it refuses to read new commands from your input until after you have drained the output it was trying to send you , or whether you can send commands as fast as you want and then read replies - There's a limit as to how much you can send before you must read, based on buffer sizes, but I don't know if there are additional limits on per-line reads Trivial QMP scripts =================== #!/bin/bash set -x # Create bitmap exec 3<>/dev/tcp/localhost/4444 echo -e "{ 'execute': 'qmp_capabilities' }" >&3 read response <&3 read response <&3 echo "$response" echo -e "{ 'execute': 'block-dirty-bitmap-add', 'arguments': { 'node': 'drive-ide0-0-0', 'name': 'bitmap0' } }" >&3 read response <&3 echo "$response" #!/bin/bash set -x # Test incremental backup with `drive-backup` exec 3<>/dev/tcp/localhost/4444 echo -e "{ 'execute': 'qmp_capabilities' }" >&3 read response <&3 read response <&3 echo "$response" echo -e "{ 'execute': 'drive-backup', 'arguments': { 'device': 'drive-ide0-0-0', 'bitmap': 'bitmap0', 'sync': 'dirty-bitmap', 'target': '/home/kashyapc/work/virt/qemu/incremental-backup-test-qemu/tests/incremental.0.img', 'mode': 'existing', 'format': 'qcow2' } }" >&3 read response <&3 echo "$response"