This is v9 of the image locking series. I redid the whole series, adopting the "two locks" approach from Kevin and Max.
Depends on "[Qemu-devel] [PATCH] raw-posix: Rename 'raw_s' to 'rs'" in Max's block branch. Fam Zheng (14): osdep: Add qemu_lock_fd and qemu_unlock_fd block: Define BDRV_O_SHARE_RW qemu-io: Set "share-rw" flag together with read-only qemu-img: Set "share-rw" flag in read-only commands block: Set "share-rw" flag in drive-backup when sync=none block: Set "share-rw" flag for incoming migration iotests: 055: Don't attach the drive to vm for drive-backup iotests: 030: Read-only open image for getting map iotests: 087: Don't attch test image twice iotests: 085: Avoid image locking conflict iotests: 091: Quit QEMU before checking image tests: Use null-co:// instead of /dev/null as the dummy image raw-posix: Implement image locking tests: Add test-image-lock block/raw-posix.c | 710 +++++++++++++++++++++++++++++++++++++++++---- blockdev.c | 5 +- include/block/block.h | 2 + include/qemu/osdep.h | 2 + qemu-img.c | 10 +- qemu-io.c | 2 + tests/Makefile.include | 2 + tests/drive_del-test.c | 2 +- tests/nvme-test.c | 2 +- tests/qemu-iotests/030 | 4 +- tests/qemu-iotests/055 | 32 +- tests/qemu-iotests/085 | 32 +- tests/qemu-iotests/085.out | 3 +- tests/qemu-iotests/087 | 6 +- tests/qemu-iotests/091 | 2 + tests/test-image-lock.c | 179 ++++++++++++ tests/usb-hcd-uhci-test.c | 2 +- tests/usb-hcd-xhci-test.c | 2 +- tests/virtio-blk-test.c | 2 +- tests/virtio-scsi-test.c | 4 +- util/osdep.c | 29 ++ 21 files changed, 939 insertions(+), 95 deletions(-) create mode 100644 tests/test-image-lock.c -- 2.7.4