From: Fam Zheng <famz@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>,
Jeff Cody <jcody@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
Eric Blake <eblake@redhat.com>, John Snow <jsnow@redhat.com>,
qemu-block@nongnu.org, berrange@redhat.com, pbonzini@redhat.com,
den@openvz.org, stefanha@redhat.com
Subject: [Qemu-devel] [PATCH v3 00/27] block: Lock images when opening
Date: Thu, 28 Apr 2016 20:57:19 +0800 [thread overview]
Message-ID: <1461848266-32119-1-git-send-email-famz@redhat.com> (raw)
v3: Highlight is handling of image locks during close(3) and bdrv_reopen(). A
number of new patches are added consequently. Per patch change logs are:
[01/27] block: Add BDRV_O_NO_LOCK
Add Denis's rev-by.
[03/27] blockdev: Add and parse "lock-image" option for block devices
Add as root BDS option too.
[04/27] block: Introduce image file locking
Treat -ENOTSUP the same as empty .bdrv_lockf.
[05/27] block: Add bdrv_image_locked
New.
[06/27] block: Make bdrv_reopen_{commit,abort} private functions
[07/27] block: Handle image locking during reopen
New. Handle reopen. [Laszlo]
[08/27] osdep: Add qemu_lock_fd and qemu_unlock_fd
[09/27] osdep: Introduce qemu_dup
[10/27] raw-posix: Use qemu_dup
[11/27] raw-posix: Implement .bdrv_lockf
New. Handle close. [Daniel]
[12/27] gluster: Implement .bdrv_lockf
Add Niels' rev-by.
[13/27] qemu-io: Add "-L" option for BDRV_O_NO_LOCK
Update argument documentation. [Denis]
[18/27] mirror: Disable image locking on target backing chain
New. Target image is not locked.
[19/27] qemu-iotests: 140: Disable image lock for qemu-io access
[20/27] qemu-iotests: 046: Move version detection out from verify_io
[21/27] qemu-iotests: Wait for QEMU processes before checking image in 091
[22/27] qemu-iotests: 030: Disable image lock when checking test image
[23/27] iotests: 087: Disable image lock in cases where file is shared
[24/27] iotests: Disable image locking in 085
[25/27] tests: Use null-co:// instead of /dev/null
New. Several updates of testing to avoid image locking voilation.
[27/27] qemu-iotests: Add test case 153 for image locking
Add a number of new combinations.
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), doesn't provide byte range locking and
is also forwarded to fcntl on Linux NFS mount points, so we'd end up
conflicting with virtlockd. Thus it is not used.
Gluster locking is also implemented wrapping glfs_posix_lock. The patch is
lightly tested.
All other drivers that don't implement .bdrv_lockf are always permissive and do
not check.
Fam Zheng (27):
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
block: Add bdrv_image_locked
block: Make bdrv_reopen_{commit,abort} private functions
block: Handle image locking during reopen
osdep: Add qemu_lock_fd and qemu_unlock_fd
osdep: Introduce qemu_dup
raw-posix: Use qemu_dup
raw-posix: Implement .bdrv_lockf
gluster: Implement .bdrv_lockf
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: 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: 030: Disable image lock when checking test image
iotests: 087: Disable image lock 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 | 69 +++++++++++-
block/gluster.c | 31 ++++++
block/raw-posix.c | 32 ++++--
blockdev.c | 23 ++++
include/block/block.h | 6 +-
include/block/block_int.h | 12 ++
include/qemu/osdep.h | 3 +
qapi/block-core.json | 6 +-
qemu-img-cmds.hx | 44 ++++----
qemu-img.c | 90 ++++++++++++---
qemu-img.texi | 3 +
qemu-io.c | 24 +++-
qemu-nbd.c | 7 +-
qemu-nbd.texi | 2 +
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/140 | 2 +-
tests/qemu-iotests/153 | 191 ++++++++++++++++++++++++++++++++
tests/qemu-iotests/153.out | 266 +++++++++++++++++++++++++++++++++++++++++++++
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 | 215 +++++++++++++++++++++++++++++++++---
31 files changed, 986 insertions(+), 92 deletions(-)
create mode 100755 tests/qemu-iotests/153
create mode 100644 tests/qemu-iotests/153.out
--
2.8.0
next reply other threads:[~2016-04-28 12:57 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-28 12:57 Fam Zheng [this message]
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 01/27] block: Add BDRV_O_NO_LOCK Fam Zheng
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 02/27] qapi: Add lock-image in blockdev-add options Fam Zheng
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 03/27] blockdev: Add and parse "lock-image" option for block devices Fam Zheng
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 04/27] block: Introduce image file locking Fam Zheng
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 05/27] block: Add bdrv_image_locked Fam Zheng
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 06/27] block: Make bdrv_reopen_{commit, abort} private functions Fam Zheng
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 07/27] block: Handle image locking during reopen Fam Zheng
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 08/27] osdep: Add qemu_lock_fd and qemu_unlock_fd Fam Zheng
2016-05-04 13:46 ` Richard W.M. Jones
2016-05-10 2:43 ` Fam Zheng
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 09/27] osdep: Introduce qemu_dup Fam Zheng
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 10/27] raw-posix: Use qemu_dup Fam Zheng
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 11/27] raw-posix: Implement .bdrv_lockf Fam Zheng
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 12/27] gluster: " Fam Zheng
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 13/27] qemu-io: Add "-L" option for BDRV_O_NO_LOCK Fam Zheng
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 14/27] qemu-img: Add "-L" option to sub commands Fam Zheng
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 15/27] qemu-img: Update documentation of "-L" option Fam Zheng
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 16/27] qemu-nbd: Add "--no-lock/-L" option Fam Zheng
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 17/27] block: Don't lock drive-backup target image in none mode Fam Zheng
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 18/27] mirror: Disable image locking on target backing chain Fam Zheng
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 19/27] qemu-iotests: 140: Disable image lock for qemu-io access Fam Zheng
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 20/27] qemu-iotests: 046: Move version detection out from verify_io Fam Zheng
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 21/27] qemu-iotests: Wait for QEMU processes before checking image in 091 Fam Zheng
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 22/27] qemu-iotests: 030: Disable image lock when checking test image Fam Zheng
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 23/27] iotests: 087: Disable image lock in cases where file is shared Fam Zheng
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 24/27] iotests: Disable image locking in 085 Fam Zheng
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 25/27] tests: Use null-co:// instead of /dev/null Fam Zheng
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 26/27] block: Turn on image locking by default Fam Zheng
2016-04-28 12:57 ` [Qemu-devel] [PATCH v3 27/27] qemu-iotests: Add test case 153 for image locking Fam Zheng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1461848266-32119-1-git-send-email-famz@redhat.com \
--to=famz@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=den@openvz.org \
--cc=eblake@redhat.com \
--cc=jcody@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).