COLO block replication doesn't support the shared disk case, Here we try to implement it.
For the detail of shared-disk scenario, please refer to patch 1. COLO codes with shared-disk block replication can be found from the link: https://github.com/coloft/qemu/tree/colo-developing-with-shared-disk-2016-12-5 Test procedures: 1. Secondary: # x86_64-softmmu/qemu-system-x86_64 -boot c -m 2048 -smp 2 -qmp stdio -vnc :9 -name secondary -enable-kvm -cpu qemu64,+kvmclock -device piix3-usb-uhci -drive if=none,driver=qcow2,file.filename=/mnt/ramfs/hidden_disk.img,id=hidden_disk0,backing.driver=raw,backing.file.filename=/work/kvm/suse11_sp3_64 -drive if=ide,id=active-disk0,driver=replication,mode=secondary,file.driver=qcow2,top-id=active-disk0,file.file.filename=/mnt/ramfs/active_disk.img,file.backing=hidden_disk0,shared-disk=on -incoming tcp:0:9999 Issue qmp commands: {'execute':'qmp_capabilities'} {'execute': 'nbd-server-start', 'arguments': {'addr': {'type': 'inet', 'data': {'host': '0', 'port': '9998'} } } } {'execute': 'nbd-server-add', 'arguments': {'device': 'hidden_disk0', 'writable': true } } 2.Primary: # x86_64-softmmu/qemu-system-x86_64 -enable-kvm -m 2048 -smp 2 -qmp stdio -vnc :9 -name primary -cpu qemu64,+kvmclock -device piix3-usb-uhci -drive if=virtio,id=primary_disk0,file.filename=/work/kvm/suse11_sp3_64,driver=raw -S Issue qmp commands: {'execute':'qmp_capabilities'} {'execute': 'human-monitor-command', 'arguments': {'command-line': 'drive_add -n buddy driver=replication,mode=primary,file.driver=nbd,file.host=9.42.3.17,file.port=9998,file.export=hidden_disk0,shared-disk-id=primary_disk0,shared-disk=on,node-name=rep'}} {'execute': 'migrate-set-capabilities', 'arguments': {'capabilities': [ {'capability': 'x-colo', 'state': true } ] } } {'execute': 'migrate', 'arguments': {'uri': 'tcp:9.42.3.17:9999' } } 3. Failover Secondary side: Issue qmp commands: { 'execute': 'nbd-server-stop' } { "execute": "x-colo-lost-heartbeat" } Please review and any commits are welcomed. Cc: Juan Quintela <quint...@redhat.com> Cc: Amit Shah <amit.s...@redhat.com> Cc: Dr. David Alan Gilbert (git) <dgilb...@redhat.com> Cc: eddie.d...@intel.com v2: - Drop the patch which add a blk_root() helper - Fix some comments from Changlong zhanghailiang (6): docs/block-replication: Add description for shared-disk case replication: add shared-disk and shared-disk-id options replication: Split out backup_do_checkpoint() from secondary_do_checkpoint() replication: fix code logic with the new shared_disk option replication: Implement block replication for shared disk case nbd/replication: implement .bdrv_get_info() for nbd and replication driver block/nbd.c | 12 ++++ block/replication.c | 156 +++++++++++++++++++++++++++++++++++---------- docs/block-replication.txt | 139 ++++++++++++++++++++++++++++++++++++++-- qapi/block-core.json | 9 ++- 4 files changed, 278 insertions(+), 38 deletions(-) -- 1.8.3.1