From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, berto@igalia.com, qemu-devel@nongnu.org,
mreitz@redhat.com
Subject: [Qemu-devel] [PATCH v3 07/21] block: Pass driver-specific options to .bdrv_refresh_filename()
Date: Fri, 4 Dec 2015 14:35:10 +0100 [thread overview]
Message-ID: <1449236124-19605-8-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1449236124-19605-1-git-send-email-kwolf@redhat.com>
In order to decide whether a blkdebug: filename can be produced or a
json: one is necessary, blkdebug checked whether bs->options had more
options than just "config", "x-image" or "image" (the latter including
nested options). That doesn't work well when generic block layer options
are present.
This patch passes an option QDict to the driver that contains only
driver-specific options, i.e. the options for the general block layer as
well as child nodes are already filtered out. Works much better this
way.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
---
block.c | 5 ++++-
block/blkdebug.c | 17 ++++++-----------
block/blkverify.c | 2 +-
block/nbd.c | 10 +++++-----
block/quorum.c | 2 +-
include/block/block_int.h | 2 +-
6 files changed, 18 insertions(+), 20 deletions(-)
diff --git a/block.c b/block.c
index 0dfff7a..5ca7c71 100644
--- a/block.c
+++ b/block.c
@@ -4027,7 +4027,10 @@ void bdrv_refresh_filename(BlockDriverState *bs)
bs->full_open_options = NULL;
}
- drv->bdrv_refresh_filename(bs);
+ opts = qdict_new();
+ append_open_options(opts, bs);
+ drv->bdrv_refresh_filename(bs, opts);
+ QDECREF(opts);
} else if (bs->file) {
/* Try to reconstruct valid information from the underlying file */
bool has_open_options;
diff --git a/block/blkdebug.c b/block/blkdebug.c
index dee3a0e..48b0812 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -731,17 +731,15 @@ static int blkdebug_truncate(BlockDriverState *bs, int64_t offset)
return bdrv_truncate(bs->file->bs, offset);
}
-static void blkdebug_refresh_filename(BlockDriverState *bs)
+static void blkdebug_refresh_filename(BlockDriverState *bs, QDict *options)
{
QDict *opts;
const QDictEntry *e;
bool force_json = false;
- for (e = qdict_first(bs->options); e; e = qdict_next(bs->options, e)) {
+ for (e = qdict_first(options); e; e = qdict_next(options, e)) {
if (strcmp(qdict_entry_key(e), "config") &&
- strcmp(qdict_entry_key(e), "x-image") &&
- strcmp(qdict_entry_key(e), "image") &&
- strncmp(qdict_entry_key(e), "image.", strlen("image.")))
+ strcmp(qdict_entry_key(e), "x-image"))
{
force_json = true;
break;
@@ -757,7 +755,7 @@ static void blkdebug_refresh_filename(BlockDriverState *bs)
if (!force_json && bs->file->bs->exact_filename[0]) {
snprintf(bs->exact_filename, sizeof(bs->exact_filename),
"blkdebug:%s:%s",
- qdict_get_try_str(bs->options, "config") ?: "",
+ qdict_get_try_str(options, "config") ?: "",
bs->file->bs->exact_filename);
}
@@ -767,11 +765,8 @@ static void blkdebug_refresh_filename(BlockDriverState *bs)
QINCREF(bs->file->bs->full_open_options);
qdict_put_obj(opts, "image", QOBJECT(bs->file->bs->full_open_options));
- for (e = qdict_first(bs->options); e; e = qdict_next(bs->options, e)) {
- if (strcmp(qdict_entry_key(e), "x-image") &&
- strcmp(qdict_entry_key(e), "image") &&
- strncmp(qdict_entry_key(e), "image.", strlen("image.")))
- {
+ for (e = qdict_first(options); e; e = qdict_next(options, e)) {
+ if (strcmp(qdict_entry_key(e), "x-image")) {
qobject_incref(qdict_entry_value(e));
qdict_put_obj(opts, qdict_entry_key(e), qdict_entry_value(e));
}
diff --git a/block/blkverify.c b/block/blkverify.c
index c5f8e8d..1d75449 100644
--- a/block/blkverify.c
+++ b/block/blkverify.c
@@ -307,7 +307,7 @@ static void blkverify_attach_aio_context(BlockDriverState *bs,
bdrv_attach_aio_context(s->test_file->bs, new_context);
}
-static void blkverify_refresh_filename(BlockDriverState *bs)
+static void blkverify_refresh_filename(BlockDriverState *bs, QDict *options)
{
BDRVBlkverifyState *s = bs->opaque;
diff --git a/block/nbd.c b/block/nbd.c
index cd6a587..416f42b 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -342,13 +342,13 @@ static void nbd_attach_aio_context(BlockDriverState *bs,
nbd_client_attach_aio_context(bs, new_context);
}
-static void nbd_refresh_filename(BlockDriverState *bs)
+static void nbd_refresh_filename(BlockDriverState *bs, QDict *options)
{
QDict *opts = qdict_new();
- const char *path = qdict_get_try_str(bs->options, "path");
- const char *host = qdict_get_try_str(bs->options, "host");
- const char *port = qdict_get_try_str(bs->options, "port");
- const char *export = qdict_get_try_str(bs->options, "export");
+ const char *path = qdict_get_try_str(options, "path");
+ const char *host = qdict_get_try_str(options, "host");
+ const char *port = qdict_get_try_str(options, "port");
+ const char *export = qdict_get_try_str(options, "export");
qdict_put_obj(opts, "driver", QOBJECT(qstring_from_str("nbd")));
diff --git a/block/quorum.c b/block/quorum.c
index b9ba028..2810e37 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -997,7 +997,7 @@ static void quorum_attach_aio_context(BlockDriverState *bs,
}
}
-static void quorum_refresh_filename(BlockDriverState *bs)
+static void quorum_refresh_filename(BlockDriverState *bs, QDict *options)
{
BDRVQuorumState *s = bs->opaque;
QDict *opts;
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 7265247..136635a 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -136,7 +136,7 @@ struct BlockDriver {
int (*bdrv_set_key)(BlockDriverState *bs, const char *key);
int (*bdrv_make_empty)(BlockDriverState *bs);
- void (*bdrv_refresh_filename)(BlockDriverState *bs);
+ void (*bdrv_refresh_filename)(BlockDriverState *bs, QDict *options);
/* aio */
BlockAIOCB *(*bdrv_aio_readv)(BlockDriverState *bs,
--
1.8.3.1
next prev parent reply other threads:[~2015-12-04 13:35 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-04 13:35 [Qemu-devel] [PATCH v3 00/21] block: Cache mode for children etc Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 01/21] qcow2: Add .bdrv_join_options callback Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 02/21] block: Fix reopen with semantically overlapping options Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 03/21] mirror: Error out when a BDS would get two BBs Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 04/21] block: Allow references for backing files Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 05/21] block: Consider all block layer options in append_open_options Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 06/21] block: Exclude nested options only for children in append_open_options() Kevin Wolf
2015-12-04 21:47 ` Max Reitz
2015-12-15 2:16 ` Wen Congyang
2015-12-04 13:35 ` Kevin Wolf [this message]
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 08/21] block: Keep "driver" in bs->options Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 09/21] block: Allow specifying child options in reopen Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 10/21] block: reopen: Document option precedence and refactor accordingly Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 11/21] block: Add infrastructure for option inheritance Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 12/21] block: Split out parse_json_protocol() Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 13/21] block: Introduce bs->explicit_options Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 14/21] blockdev: Set 'format' indicates non-empty drive Kevin Wolf
2015-12-04 21:59 ` Max Reitz
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 15/21] qemu-iotests: Remove cache mode test without medium Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 16/21] block: reopen: Extract QemuOpts for generic block layer options Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 17/21] block: Move cache options into options QDict Kevin Wolf
2015-12-04 22:07 ` Max Reitz
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 18/21] blkdebug: Enable reopen Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 19/21] qemu-iotests: Try setting cache mode for children Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 20/21] qemu-iotests: Test cache mode option inheritance Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 21/21] qemu-iotests: Test reopen with node-name/driver options Kevin Wolf
2015-12-07 9:25 ` [Qemu-devel] [PATCH v3 00/21] block: Cache mode for children etc Kevin Wolf
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=1449236124-19605-8-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=berto@igalia.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).