v6: Rebase, and address comments from Max and Rich: Dropped the gluster implementation because the previous reviewed version doesn't handle reopen correctly. Left for another day.
Added Max's reviewed-by in patches 1, 3, 7, 12, 13, 16, 17 and 20 - 22. Updated "qemu -help" text. [Rich] Per patch changelog: [02/22] qapi: Add lock-mode in blockdev-add options Fix the copy-pasto in qapi comment. [Max] [04/22] block: Introduce image file locking Partly reworked, main difference being the new "bdrv_get_locking_cmd". [05/22] osdep: Add qemu_lock_fd and qemu_unlock_fd Comment fix, whitespace and empty line cleaning up, and error code. [Max] Put the new functions under "#ifndef _WIN32" so windows build doesn't break. [06/22] osdep: Introduce qemu_dup Commit message grammar. [Max] Wrap with "#ifndef _WIN32". [Max] [07/22] raw-posix: Use qemu_dup [08/22] raw-posix: Add image locking support Basically rewritten to handle reopen more reliably. [09/22] qemu-io: Add "-L" option for BDRV_O_NO_LOCK "image lock" -> "image locking" for consistency. [Max] "int nolock" -> "bool nolock". [Max] [11/22] qemu-img: Update documentation of "-L" option Drop dead assignment to flags and src_flags. [Max] [15/22] qemu-iotests: 046: Move version detection out from verify_io Drop unnecessary "-L". [Max] [18/22] iotests: 087: Disable image locking in cases where file is shared Spell fix in commit message. [Max] Move '"lock-mode": "off"' after "node-name" for consistency. [Max] [19/22] iotests: Disable image locking in 085 Use "'read-only': true". [Max] v5: - Change "lock-image=on/off" to "lock-mode=exclusive/shared/off". Default is "lock-mode=exclusive" to exclusively lock RW images and shared lock RO images; with lock-mode="shared", RW images are shared locked too; lock-mode=off turns off image locking completely. - Use F_OFD_SETLK fcntl so that close/dup on different fds are not a problem. - Update test cases. Fam Zheng (22): block: Add flag bits for image locking qapi: Add lock-mode in blockdev-add options blockdev: Add and parse "lock-mode" option for image locking block: Introduce image file locking osdep: Add qemu_lock_fd and qemu_unlock_fd osdep: Introduce qemu_dup raw-posix: Use qemu_dup raw-posix: Add image locking support qemu-io: Add "-L" option for BDRV_O_NO_LOCK qemu-img: Add "-L" option to sub commands qemu-img: Update documentation of "-L" option qemu-nbd: Add "--no-lock/-L" option block: Don't lock drive-backup target image in none mode mirror: Disable image locking on target backing chain qemu-iotests: 046: Move version detection out from verify_io qemu-iotests: Wait for QEMU processes before checking image in 091 qemu-iotests: 030: Disable image locking when checking test image iotests: 087: Disable image locking in cases where file is shared iotests: Disable image locking in 085 tests: Use null-co:// instead of /dev/null block: Turn on image locking by default qemu-iotests: Add test case 153 for image locking block.c | 57 ++++++ block/raw-posix.c | 295 ++++++++++++++++++++++++++++++- blockdev.c | 38 +++- include/block/block.h | 13 +- include/block/block_int.h | 5 + include/qemu/osdep.h | 5 + qapi/block-core.json | 19 +- qemu-img-cmds.hx | 44 ++--- qemu-img.c | 92 ++++++++-- qemu-img.texi | 3 + qemu-io.c | 24 ++- qemu-nbd.c | 7 +- qemu-nbd.texi | 2 + qemu-options.hx | 1 + tests/drive_del-test.c | 2 +- tests/nvme-test.c | 2 +- tests/qemu-iotests/030 | 2 +- tests/qemu-iotests/046 | 22 +-- tests/qemu-iotests/085 | 3 +- tests/qemu-iotests/087 | 6 + tests/qemu-iotests/091 | 3 + tests/qemu-iotests/091.out | 1 + tests/qemu-iotests/153 | 197 +++++++++++++++++++++ tests/qemu-iotests/153.out | 426 +++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 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 | 38 ++++ 30 files changed, 1241 insertions(+), 77 deletions(-) create mode 100755 tests/qemu-iotests/153 create mode 100644 tests/qemu-iotests/153.out -- 2.8.2