All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for-2.7 v2 00/17] block: Lock images when opening
@ 2016-04-15  3:27 Fam Zheng
  2016-04-15  3:27 ` [Qemu-devel] [PATCH for-2.7 v2 01/17] block: Add BDRV_O_NO_LOCK Fam Zheng
                   ` (18 more replies)
  0 siblings, 19 replies; 65+ messages in thread
From: Fam Zheng @ 2016-04-15  3:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Max Reitz, Jeff Cody, Markus Armbruster, Eric Blake,
	John Snow, qemu-block, berrange, pbonzini, den

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

-- 
2.8.0

^ permalink raw reply	[flat|nested] 65+ messages in thread

end of thread, other threads:[~2016-04-28  1:33 UTC | newest]

Thread overview: 65+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-15  3:27 [Qemu-devel] [PATCH for-2.7 v2 00/17] block: Lock images when opening Fam Zheng
2016-04-15  3:27 ` [Qemu-devel] [PATCH for-2.7 v2 01/17] block: Add BDRV_O_NO_LOCK Fam Zheng
2016-04-16 10:47   ` Denis V. Lunev
2016-04-15  3:27 ` [Qemu-devel] [PATCH for-2.7 v2 02/17] qapi: Add lock-image in blockdev-add options Fam Zheng
2016-04-16 10:48   ` Denis V. Lunev
2016-04-26  8:01     ` Fam Zheng
2016-04-15  3:27 ` [Qemu-devel] [PATCH for-2.7 v2 03/17] blockdev: Add and parse "lock-image" option for block devices Fam Zheng
2016-04-16 13:15   ` Denis V. Lunev
2016-04-19 13:00     ` Fam Zheng
2016-04-15  3:27 ` [Qemu-devel] [PATCH for-2.7 v2 04/17] block: Introduce image file locking Fam Zheng
2016-04-16 13:22   ` Denis V. Lunev
2016-04-18  1:43     ` Fam Zheng
2016-04-16 23:29   ` Max Reitz
2016-04-18  1:33     ` Fam Zheng
2016-04-18  5:34       ` Denis V. Lunev
2016-04-19 19:14         ` Max Reitz
2016-04-20  8:46           ` Denis V. Lunev
2016-04-19 19:13       ` Max Reitz
2016-04-25 23:55   ` Laszlo Ersek
2016-04-26  0:47     ` Fam Zheng
2016-04-15  3:27 ` [Qemu-devel] [PATCH for-2.7 v2 05/17] raw-posix: Implement .bdrv_lockf Fam Zheng
2016-04-16 13:29   ` Denis V. Lunev
2016-04-18  1:12     ` Fam Zheng
2016-04-18  5:30       ` Denis V. Lunev
2016-04-18  9:34       ` Daniel P. Berrange
2016-04-18  9:38         ` Denis V. Lunev
2016-04-17 19:27   ` Richard W.M. Jones
2016-04-18  1:10     ` Fam Zheng
2016-04-18  8:04       ` Richard W.M. Jones
2016-04-19 12:37         ` Fam Zheng
2016-04-19 13:07           ` Richard W.M. Jones
2016-04-19 13:19             ` Fam Zheng
2016-04-19 13:36               ` Richard W.M. Jones
2016-04-19 13:45                 ` Daniel P. Berrange
2016-04-19 13:34         ` Daniel P. Berrange
2016-04-19 13:40           ` Richard W.M. Jones
2016-04-15  3:27 ` [Qemu-devel] [PATCH for-2.7 v2 06/17] gluster: " Fam Zheng
2016-04-15 12:24   ` [Qemu-devel] [Qemu-block] " Niels de Vos
2016-04-15  3:27 ` [Qemu-devel] [PATCH for-2.7 v2 07/17] rbd: Implement image locking Fam Zheng
2016-04-23  1:57   ` Jason Dillaman
2016-04-25  0:42     ` Fam Zheng
2016-04-26 15:42       ` Jason Dillaman
2016-04-27  0:20         ` Fam Zheng
2016-04-27 18:18           ` Jason Dillaman
2016-04-28  1:33             ` Fam Zheng
2016-04-15  3:27 ` [Qemu-devel] [PATCH for-2.7 v2 08/17] qemu-io: Add "-L" option for BDRV_O_NO_LOCK Fam Zheng
2016-04-16 13:46   ` Denis V. Lunev
2016-04-19 12:59     ` Fam Zheng
2016-04-15  3:27 ` [Qemu-devel] [PATCH for-2.7 v2 09/17] qemu-img: Add "-L" option to sub commands Fam Zheng
2016-04-16 14:29   ` Denis V. Lunev
2016-04-16 14:30     ` Denis V. Lunev
2016-04-19 12:59     ` Fam Zheng
2016-04-15  3:28 ` [Qemu-devel] [PATCH for-2.7 v2 10/17] qemu-img: Update documentation of "-L" option Fam Zheng
2016-04-15  3:28 ` [Qemu-devel] [PATCH for-2.7 v2 11/17] qemu-nbd: Add "--no-lock/-L" option Fam Zheng
2016-04-16 14:32   ` Denis V. Lunev
2016-04-19 12:58     ` Fam Zheng
2016-04-15  3:28 ` [Qemu-devel] [PATCH for-2.7 v2 12/17] qemu-iotests: 140: Disable image lock for qemu-io access Fam Zheng
2016-04-15  3:28 ` [Qemu-devel] [PATCH for-2.7 v2 13/17] qemu-iotests: 046: Move version detection out from verify_io Fam Zheng
2016-04-15  3:28 ` [Qemu-devel] [PATCH for-2.7 v2 14/17] qemu-iotests: Wait for QEMU processes before checking image in 091 Fam Zheng
2016-04-15  3:28 ` [Qemu-devel] [PATCH for-2.7 v2 15/17] qemu-iotests: Disable image lock when checking test image Fam Zheng
2016-04-15  3:28 ` [Qemu-devel] [PATCH for-2.7 v2 16/17] block: Turn on image locking by default Fam Zheng
2016-04-15  3:28 ` [Qemu-devel] [PATCH for-2.7 v2 17/17] qemu-iotests: Add test case 152 for image locking Fam Zheng
2016-04-16 14:33 ` [Qemu-devel] [PATCH for-2.7 v2 00/17] block: Lock images when opening Denis V. Lunev
2016-04-18  9:53 ` Daniel P. Berrange
2016-04-19 12:40   ` Fam Zheng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.