From: Max Reitz <mreitz@redhat.com>
To: Peter Lieven <pl@kamp.de>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, jcody@redhat.com, famz@redhat.com,
benoit@irqsave.net, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH 2/4] block: introduce bdrv_runtime_opts
Date: Mon, 20 Oct 2014 17:27:52 +0200 [thread overview]
Message-ID: <544529F8.7000305@redhat.com> (raw)
In-Reply-To: <1413815720-29976-3-git-send-email-pl@kamp.de>
On 20.10.2014 at 16:35, Peter Lieven wrote:
> This patch (orginally by Kevin) adds a bdrv_runtime_opts QemuOptsList.
> The list will absorb all options that belong to the BDS (and not the
> BlockBackend) and will be parsed and handled in bdrv_open_common.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> Signed-off-by: Peter Lieven <pl@kamp.de>
> ---
> block.c | 39 +++++++++++++++++++++++++++++++++------
> 1 file changed, 33 insertions(+), 6 deletions(-)
>
> diff --git a/block.c b/block.c
> index ba5281d..3b4a59a 100644
> --- a/block.c
> +++ b/block.c
> @@ -27,6 +27,7 @@
> #include "block/block_int.h"
> #include "block/blockjob.h"
> #include "qemu/module.h"
> +#include "qapi/qmp/qbool.h"
> #include "qapi/qmp/qjson.h"
> #include "sysemu/block-backend.h"
> #include "sysemu/sysemu.h"
> @@ -875,6 +876,19 @@ static void bdrv_assign_node_name(BlockDriverState *bs,
> QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs, node_list);
> }
>
> +static QemuOptsList bdrv_runtime_opts = {
> + .name = "bdrv_common",
> + .head = QTAILQ_HEAD_INITIALIZER(bdrv_runtime_opts.head),
> + .desc = {
> + {
> + .name = "node-name",
> + .type = QEMU_OPT_STRING,
> + .help = "Node name of the block device node",
> + },
> + { /* end of list */ }
> + },
> +};
> +
> /*
> * Common part for opening disk images and files
> *
> @@ -886,6 +900,7 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
> int ret, open_flags;
> const char *filename;
> const char *node_name = NULL;
> + QemuOpts *opts;
> Error *local_err = NULL;
>
> assert(drv != NULL);
> @@ -906,19 +921,28 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
>
> trace_bdrv_open_common(bs, filename ?: "", flags, drv->format_name);
>
> - node_name = qdict_get_try_str(options, "node-name");
> + opts = qemu_opts_create(&bdrv_runtime_opts, NULL, 0, &error_abort);
> + qemu_opts_absorb_qdict(opts, options, &local_err);
> + if (local_err) {
> + error_propagate(errp, local_err);
> + ret = -EINVAL;
> + goto fail_opts;
> + }
> +
> + node_name = qemu_opt_get(opts, "node-name");
> bdrv_assign_node_name(bs, node_name, &local_err);
> if (local_err) {
> error_propagate(errp, local_err);
> - return -EINVAL;
> + ret = -EINVAL;
> + goto fail_opts;
> }
> - qdict_del(options, "node-name");
>
> /* bdrv_open() with directly using a protocol as drv. This layer is already
> * opened, so assign it to bs (while file becomes a closed BlockDriverState)
> * and return immediately. */
> if (file != NULL && drv->bdrv_file_open) {
> bdrv_swap(file, bs);
> + qemu_opts_del(opts);
> return 0;
> }
>
> @@ -936,7 +960,8 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
> ? "Driver '%s' can only be used for read-only devices"
> : "Driver '%s' is not whitelisted",
> drv->format_name);
> - return -ENOTSUP;
> + ret = -ENOTSUP;
> + goto fail_opts;
> }
>
> assert(bs->copy_on_read == 0); /* bdrv_new() and bdrv_close() make it so */
> @@ -945,7 +970,8 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
> bdrv_enable_copy_on_read(bs);
> } else {
> error_setg(errp, "Can't use copy-on-read on read-only device");
> - return -EINVAL;
> + ret = -EINVAL;
> + goto fail_opts;
> }
> }
>
> @@ -958,7 +984,6 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
>
> bs->drv = drv;
> bs->opaque = g_malloc0(drv->instance_size);
> -
> bs->enable_write_cache = !!(flags & BDRV_O_CACHE_WB);
>
> /* Open the image, either directly or using a protocol */
I know it's not even your patch originally, but I still don't like
spurious empty line removals, whoever might be responsible for them.
> @@ -1010,6 +1035,8 @@ free_and_fail:
> g_free(bs->opaque);
> bs->opaque = NULL;
> bs->drv = NULL;
> +fail_opts:
> + qemu_opts_del(opts);
> return ret;
> }
>
With that empty line removal hunk removed:
Reviewed-by: Max Reitz <mreitz@redhat.com>
next prev parent reply other threads:[~2014-10-20 15:28 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-20 14:35 [Qemu-devel] [PATCH 0/4] multiwrite patches for 2.2 Peter Lieven
2014-10-20 14:35 ` [Qemu-devel] [PATCH 1/4] block: add accounting for merged requests Peter Lieven
2014-10-20 15:08 ` Max Reitz
2014-10-20 14:35 ` [Qemu-devel] [PATCH 2/4] block: introduce bdrv_runtime_opts Peter Lieven
2014-10-20 15:27 ` Max Reitz [this message]
2014-10-20 14:35 ` [Qemu-devel] [PATCH 3/4] block: add a knob to disable multiwrite_merge Peter Lieven
2014-10-20 15:41 ` Max Reitz
2014-10-20 14:35 ` [Qemu-devel] [PATCH 4/4] hw/virtio-blk: add a constant for max number of merged requests Peter Lieven
2014-10-20 15:51 ` Max Reitz
2014-10-20 15:56 ` [Qemu-devel] [PATCH 0/4] multiwrite patches for 2.2 Max Reitz
2014-10-20 20:48 ` Peter Lieven
2014-10-21 7:06 ` Max Reitz
2014-10-21 7:43 ` Peter Lieven
2014-10-21 8:01 ` Peter Lieven
2014-10-21 9:07 ` Max Reitz
2014-10-21 9:38 ` Kevin Wolf
2014-10-21 9:54 ` Max Reitz
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=544529F8.7000305@redhat.com \
--to=mreitz@redhat.com \
--cc=benoit@irqsave.net \
--cc=famz@redhat.com \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=pl@kamp.de \
--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).