qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>,
	qemu-block@nongnu.org
Subject: [Qemu-devel] [PATCH RFC] block: Tolerate existing writers on read only BdrvChild
Date: Wed,  1 Mar 2017 16:15:04 +0800	[thread overview]
Message-ID: <20170301081504.23595-1-famz@redhat.com> (raw)

In an ideal world, read-write access to an image is inherently
exclusive, because we cannot guarantee other readers and writers a
consistency view of the whole image at all point. That's what the
current permission system does, and it is okay as long as it is entirely
internal. But that would change with the coming image locking. In
practice, both end users and our test cases use tools like qemu-img and
qemu-io to peek at images while guest is running.

Relax a bit and accept other writers in this case.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block.c b/block.c
index f293ccb..9bdd77c 100644
--- a/block.c
+++ b/block.c
@@ -1685,12 +1685,12 @@ void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c,
         /* Format drivers may touch metadata even if the guest doesn't write */
         if (!bdrv_is_read_only(bs)) {
             perm |= BLK_PERM_WRITE | BLK_PERM_RESIZE;
+            shared &= ~(BLK_PERM_WRITE | BLK_PERM_RESIZE);
         }
 
         /* bs->file always needs to be consistent because of the metadata. We
          * can never allow other users to resize or write to it. */
         perm |= BLK_PERM_CONSISTENT_READ;
-        shared &= ~(BLK_PERM_WRITE | BLK_PERM_RESIZE);
     } else {
         /* We want consistent read from backing files if the parent needs it.
          * No other operations are performed on backing files. */
-- 
2.9.3

             reply	other threads:[~2017-03-01  8:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-01  8:15 Fam Zheng [this message]
2017-03-01  9:49 ` [Qemu-devel] [PATCH RFC] block: Tolerate existing writers on read only BdrvChild Kevin Wolf
2017-03-01 12:39   ` Fam Zheng
2017-03-01 15:16     ` Kevin Wolf
2017-03-01 16:10       ` Fam Zheng
2017-03-01 16:22         ` Kevin Wolf
2017-03-02 11:21           ` Fam Zheng
2017-03-02 14:23             ` Kevin Wolf
2017-03-03  1:46               ` 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=20170301081504.23595-1-famz@redhat.com \
    --to=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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).