qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Fam Zheng <famz@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, rjones@redhat.com,
	John Snow <jsnow@redhat.com>, Jeff Cody <jcody@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Max Reitz <mreitz@redhat.com>,
	stefanha@redhat.com, den@openvz.org, pbonzini@redhat.com,
	berrange@redhat.com
Subject: Re: [Qemu-devel] [PATCH v7 03/20] block: Add and parse "lock-mode" option for image locking
Date: Tue, 6 Sep 2016 18:33:24 +0200	[thread overview]
Message-ID: <20160906163324.GH4667@noname.redhat.com> (raw)
In-Reply-To: <1470662013-19785-4-git-send-email-famz@redhat.com>

Am 08.08.2016 um 15:13 hat Fam Zheng geschrieben:
> Respect the locking mode from CLI or QMP, and set the open flags
> accordingly.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  block.c               | 21 +++++++++++++++++++++
>  blockdev.c            |  9 +++++++++
>  include/block/block.h |  1 +
>  qemu-options.hx       |  1 +
>  4 files changed, 32 insertions(+)
> 
> diff --git a/block.c b/block.c
> index 30d64e6..5f76f60 100644
> --- a/block.c
> +++ b/block.c
> @@ -705,6 +705,7 @@ static void bdrv_inherited_options(int *child_flags, QDict *child_options,
>       * the parent. */
>      qdict_copy_default(child_options, parent_options, BDRV_OPT_CACHE_DIRECT);
>      qdict_copy_default(child_options, parent_options, BDRV_OPT_CACHE_NO_FLUSH);
> +    qdict_copy_default(child_options, parent_options, BDRV_OPT_LOCK_MODE);
>  
>      /* Our block drivers take care to send flushes and respect unmap policy,
>       * so we can default to enable both on lower layers regardless of the
> @@ -757,6 +758,7 @@ static void bdrv_backing_options(int *child_flags, QDict *child_options,
>       * which is only applied on the top level (BlockBackend) */
>      qdict_copy_default(child_options, parent_options, BDRV_OPT_CACHE_DIRECT);
>      qdict_copy_default(child_options, parent_options, BDRV_OPT_CACHE_NO_FLUSH);
> +    qdict_copy_default(child_options, parent_options, BDRV_OPT_LOCK_MODE);
>  
>      /* backing files always opened read-only */
>      flags &= ~(BDRV_O_RDWR | BDRV_O_COPY_ON_READ);
> @@ -880,6 +882,11 @@ static QemuOptsList bdrv_runtime_opts = {
>              .name = BDRV_OPT_CACHE_NO_FLUSH,
>              .type = QEMU_OPT_BOOL,
>              .help = "Ignore flush requests",
> +        },{
> +            .name = BDRV_OPT_LOCK_MODE,
> +            .type = QEMU_OPT_STRING,
> +            .help = "how to lock the image (auto, shared, off. "
> +                    "default: auto)",
>          },
>          { /* end of list */ }
>      },
> @@ -897,6 +904,7 @@ static int bdrv_open_common(BlockDriverState *bs, BdrvChild *file,
>      const char *filename;
>      const char *driver_name = NULL;
>      const char *node_name = NULL;
> +    const char *lock_mode = NULL;
>      QemuOpts *opts;
>      BlockDriver *drv;
>      Error *local_err = NULL;
> @@ -940,6 +948,19 @@ static int bdrv_open_common(BlockDriverState *bs, BdrvChild *file,
>          goto fail_opts;
>      }
>  
> +    lock_mode = qemu_opt_get(opts, BDRV_OPT_LOCK_MODE) ? : "off";

Am I missing some other place that overrides this or does it make the
default "off" rather than "auto"?

> +    if (!strcmp(lock_mode, "auto")) {
> +        /* Default */
> +    } else if (!strcmp(lock_mode, "shared")) {
> +        bs->open_flags |= BDRV_O_SHARED_LOCK;
> +    } else if (!strcmp(lock_mode, "off")) {
> +        bs->open_flags |= BDRV_O_NO_LOCK;
> +    } else {
> +        error_setg(errp, "invalid lock mode");
> +        ret = -EINVAL;
> +        goto fail_opts;
> +    }
> +
>      bs->read_only = !(bs->open_flags & BDRV_O_RDWR);

The other thing is that we didn't really finish the discussion whether
leaving the configuration on the node level to the user is a good idea
when the restrictions that the user can influence rather come from the
top level (the guest OS) and only propagate down the BDS tree.

Aren't we requiring that the user understands the internal workings of
qemu in order to infer which nodes need to be locked in which mode,
rather than just saying "my guest is okay with sharing this disk, you
can figure out what this means for locking"?

Kevin

  reply	other threads:[~2016-09-06 16:33 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-08 13:13 [Qemu-devel] [PATCH v7 00/20] block: Image locking series for 2.8 Fam Zheng
2016-08-08 13:13 ` [Qemu-devel] [PATCH v7 01/20] block: Add flag bits for image locking Fam Zheng
2016-08-08 13:13 ` [Qemu-devel] [PATCH v7 02/20] qapi: Add lock-mode in blockdev-add options Fam Zheng
2016-09-06 16:18   ` Kevin Wolf
2016-09-07  2:19     ` Fam Zheng
2016-09-22 14:58   ` Eric Blake
2016-09-23  4:01     ` Fam Zheng
2016-08-08 13:13 ` [Qemu-devel] [PATCH v7 03/20] block: Add and parse "lock-mode" option for image locking Fam Zheng
2016-09-06 16:33   ` Kevin Wolf [this message]
2016-09-07  2:18     ` Fam Zheng
2016-08-08 13:13 ` [Qemu-devel] [PATCH v7 04/20] block: Introduce image file locking Fam Zheng
2016-08-08 13:13 ` [Qemu-devel] [PATCH v7 05/20] osdep: Add qemu_lock_fd and qemu_unlock_fd Fam Zheng
2016-08-08 13:13 ` [Qemu-devel] [PATCH v7 06/20] raw-posix: Add image locking support Fam Zheng
2016-08-08 13:13 ` [Qemu-devel] [PATCH v7 07/20] qemu-io: Add "-L" option for BDRV_O_NO_LOCK Fam Zheng
2016-08-08 13:13 ` [Qemu-devel] [PATCH v7 08/20] qemu-img: Add "-L" option to sub commands Fam Zheng
2016-08-08 13:13 ` [Qemu-devel] [PATCH v7 09/20] qemu-img: Update documentation of "-L" option Fam Zheng
2016-08-08 13:13 ` [Qemu-devel] [PATCH v7 10/20] qemu-nbd: Add "--no-lock/-L" option Fam Zheng
2016-08-08 13:13 ` [Qemu-devel] [PATCH v7 11/20] block: Don't lock drive-backup target image in none mode Fam Zheng
2016-08-08 13:13 ` [Qemu-devel] [PATCH v7 12/20] qemu-iotests: 046: Move version detection out from verify_io Fam Zheng
2016-08-08 13:13 ` [Qemu-devel] [PATCH v7 13/20] qemu-iotests: Wait for QEMU processes before checking image in 091 Fam Zheng
2016-08-08 13:13 ` [Qemu-devel] [PATCH v7 14/20] qemu-iotests: 030: Disable image locking when checking test image Fam Zheng
2016-08-08 13:13 ` [Qemu-devel] [PATCH v7 15/20] iotests: 087: Disable image locking in cases where file is shared Fam Zheng
2016-08-08 13:13 ` [Qemu-devel] [PATCH v7 16/20] iotests: 130: Check image info locklessly Fam Zheng
2016-08-08 13:13 ` [Qemu-devel] [PATCH v7 17/20] iotests: Disable image locking in 085 Fam Zheng
2016-08-08 13:13 ` [Qemu-devel] [PATCH v7 18/20] tests: Use null-co:// instead of /dev/null Fam Zheng
2016-08-08 13:13 ` [Qemu-devel] [PATCH v7 19/20] block: Turn on image locking by default Fam Zheng
2016-08-08 13:13 ` [Qemu-devel] [PATCH v7 20/20] qemu-iotests: Add test case 153 for image locking Fam Zheng
2016-08-08 13:59 ` [Qemu-devel] [PATCH v7 00/20] block: Image locking series for 2.8 no-reply
2016-08-09  4:42   ` Fam Zheng
2016-09-06  1:49 ` 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=20160906163324.GH4667@noname.redhat.com \
    --to=kwolf@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=den@openvz.org \
    --cc=famz@redhat.com \
    --cc=jcody@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rjones@redhat.com \
    --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).