From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60508) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1arRoe-0006Mp-QJ for qemu-devel@nongnu.org; Sat, 16 Apr 2016 11:07:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1arRod-0006d1-QC for qemu-devel@nongnu.org; Sat, 16 Apr 2016 11:07:20 -0400 References: <1460690887-32751-1-git-send-email-famz@redhat.com> From: "Denis V. Lunev" Message-ID: <57124D29.8080907@openvz.org> Date: Sat, 16 Apr 2016 17:33:13 +0300 MIME-Version: 1.0 In-Reply-To: <1460690887-32751-1-git-send-email-famz@redhat.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH for-2.7 v2 00/17] block: Lock images when opening List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: Kevin Wolf , Max Reitz , Jeff Cody , Markus Armbruster , Eric Blake , John Snow , qemu-block@nongnu.org, berrange@redhat.com, pbonzini@redhat.com On 04/15/2016 06:27 AM, Fam Zheng wrote: > v2: Lock byte 1 in the image itself, no lock file. [Daniel] > Fix migration (image are not locked in bdrv_open_common if > BDRV_O_INACTIVE). [Denis] > Simplify test case fixes because of the above. > Add lock for RBD. > Add "-L" option in "qemu-img" and "qemu-nbd" too. [Denis] > Add test case for image locking. > > Too many troubles have been caused by two processes writing to the same image > unexpectedly. This series introduces automatical image locking into QEMU to > avoid such tragedy. With this, the user won't be able to open the image from > two processes (e.g. using qemu-img when the image is attached to the guest). > > Underneath is the fcntl syscall that locks the local file, similar to what is > already used in libvirt virtlockd. The difference is that libvirt locks byte 0, > we lock byte 1. Read only openings are mapped to shared locks. > > The alternative locking API, flock(2), cannot protect host NFS mount points, so > it's not used. > > Gluster locking is also implemented wrapping glfs_posix_lock in patch 6. It's > only lightly tested. > > All other drivers that don't implement .bdrv_lockf are always permissive and > does no checking. > > In the future, the intention is that image format drivers that introduce > locking mechanisms could also fit into this API. > > Fam Zheng (17): > block: Add BDRV_O_NO_LOCK > qapi: Add lock-image in blockdev-add options > blockdev: Add and parse "lock-image" option for block devices > block: Introduce image file locking > raw-posix: Implement .bdrv_lockf > gluster: Implement .bdrv_lockf > rbd: Implement image locking > 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 > qemu-iotests: 140: Disable image lock for qemu-io access > qemu-iotests: 046: Move version detection out from verify_io > qemu-iotests: Wait for QEMU processes before checking image in 091 > qemu-iotests: Disable image lock when checking test image > block: Turn on image locking by default > qemu-iotests: Add test case 152 for image locking > > block.c | 42 ++++++++ > block/gluster.c | 30 ++++++ > block/raw-posix.c | 35 +++++++ > block/rbd.c | 25 +++++ > blockdev.c | 8 ++ > include/block/block.h | 1 + > include/block/block_int.h | 12 +++ > qapi/block-core.json | 6 +- > qemu-img-cmds.hx | 44 ++++----- > qemu-img.c | 90 +++++++++++++---- > qemu-img.texi | 3 + > qemu-io.c | 22 ++++- > qemu-nbd.c | 6 +- > qemu-nbd.texi | 2 + > tests/qemu-iotests/030 | 2 +- > tests/qemu-iotests/046 | 22 +++-- > tests/qemu-iotests/091 | 3 + > tests/qemu-iotests/091.out | 1 + > tests/qemu-iotests/140 | 2 +- > tests/qemu-iotests/152 | 106 ++++++++++++++++++++ > tests/qemu-iotests/152.out | 237 +++++++++++++++++++++++++++++++++++++++++++++ > tests/qemu-iotests/group | 1 + > 22 files changed, 645 insertions(+), 55 deletions(-) > create mode 100755 tests/qemu-iotests/152 > create mode 100644 tests/qemu-iotests/152.out > done for now...