From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 19/21] block: Update bs->options if bdrv_reopen() succeeds
Date: Wed, 15 Aug 2018 14:55:35 +0200 [thread overview]
Message-ID: <20180815125537.10651-20-kwolf@redhat.com> (raw)
In-Reply-To: <20180815125537.10651-1-kwolf@redhat.com>
From: Alberto Garcia <berto@igalia.com>
If bdrv_reopen() succeeds then bs->explicit_options is updated with
the new values, but bs->options never changes.
Here's an example:
{ "execute": "blockdev-add",
"arguments": {
"driver": "qcow2",
"node-name": "hd0",
"overlap-check": "all",
"file": {
"driver": "file",
"filename": "hd0.qcow2"
}
}
}
After this, both bs->options and bs->explicit_options contain
"overlap-check": "all".
Now let's change that using qemu-io's reopen command:
(qemu) qemu-io hd0 "reopen -o overlap-check=none"
After this, bs->explicit_options contains the new value but
bs->options still keeps the old one.
This patch updates bs->options after a BDS has been successfully
reopened.
Signed-off-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/block.c b/block.c
index e82cfa6fe2..8c95f9893a 100644
--- a/block.c
+++ b/block.c
@@ -3055,8 +3055,8 @@ cleanup:
bdrv_reopen_abort(&bs_entry->state);
}
qobject_unref(bs_entry->state.explicit_options);
+ qobject_unref(bs_entry->state.options);
}
- qobject_unref(bs_entry->state.options);
g_free(bs_entry);
}
g_free(bs_queue);
@@ -3156,6 +3156,7 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
Error *local_err = NULL;
BlockDriver *drv;
QemuOpts *opts;
+ QDict *orig_reopen_opts;
const char *value;
bool read_only;
@@ -3163,6 +3164,11 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
assert(reopen_state->bs->drv != NULL);
drv = reopen_state->bs->drv;
+ /* This function and each driver's bdrv_reopen_prepare() remove
+ * entries from reopen_state->options as they are processed, so
+ * we need to make a copy of the original QDict. */
+ orig_reopen_opts = qdict_clone_shallow(reopen_state->options);
+
/* Process generic block layer options */
opts = qemu_opts_create(&bdrv_runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, reopen_state->options, &local_err);
@@ -3269,8 +3275,13 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
ret = 0;
+ /* Restore the original reopen_state->options QDict */
+ qobject_unref(reopen_state->options);
+ reopen_state->options = qobject_ref(orig_reopen_opts);
+
error:
qemu_opts_del(opts);
+ qobject_unref(orig_reopen_opts);
return ret;
}
@@ -3300,8 +3311,10 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_state)
/* set BDS specific flags now */
qobject_unref(bs->explicit_options);
+ qobject_unref(bs->options);
bs->explicit_options = reopen_state->explicit_options;
+ bs->options = reopen_state->options;
bs->open_flags = reopen_state->flags;
bs->read_only = !(reopen_state->flags & BDRV_O_RDWR);
--
2.13.6
next prev parent reply other threads:[~2018-08-15 12:56 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-15 12:55 [Qemu-devel] [PULL 00/21] Block layer patches Kevin Wolf
2018-08-15 12:55 ` [Qemu-devel] [PULL 01/21] block/qapi: Fix memory leak in qmp_query_blockstats() Kevin Wolf
2018-08-15 12:55 ` [Qemu-devel] [PULL 02/21] qemu-iotests: Test removing a throttle group member with a pending timer Kevin Wolf
2018-08-15 12:55 ` [Qemu-devel] [PULL 03/21] throttle-groups: Skip the round-robin if a member is being drained Kevin Wolf
2018-08-15 12:55 ` [Qemu-devel] [PULL 04/21] qemu-iotests: Update 093 to improve the draining test Kevin Wolf
2018-08-15 12:55 ` [Qemu-devel] [PULL 05/21] throttle-groups: Don't allow timers without throttled requests Kevin Wolf
2018-08-15 12:55 ` [Qemu-devel] [PULL 06/21] luks: Allow share-rw=on Kevin Wolf
2018-08-15 12:55 ` [Qemu-devel] [PULL 07/21] block: Remove deprecated -drive geometry options Kevin Wolf
2018-08-15 12:55 ` [Qemu-devel] [PULL 08/21] block: Remove deprecated -drive option addr Kevin Wolf
2018-08-15 12:55 ` [Qemu-devel] [PULL 09/21] block: Remove deprecated -drive option serial Kevin Wolf
2018-08-15 12:55 ` [Qemu-devel] [PULL 10/21] block: Remove dead deprecation warning code Kevin Wolf
2018-08-15 12:55 ` [Qemu-devel] [PULL 11/21] qapi/block: Document restrictions for node names Kevin Wolf
2018-08-15 12:55 ` [Qemu-devel] [PULL 12/21] mirror: Fail gracefully for source == target Kevin Wolf
2018-08-15 12:55 ` [Qemu-devel] [PULL 13/21] qemu-img: fix regression copying secrets during convert Kevin Wolf
2018-08-15 12:55 ` [Qemu-devel] [PULL 14/21] block: make .bdrv_close optional Kevin Wolf
2018-08-15 12:55 ` [Qemu-devel] [PULL 15/21] block: drop empty .bdrv_close handlers Kevin Wolf
2018-08-15 12:55 ` [Qemu-devel] [PULL 16/21] qdict: Make qdict_extract_subqdict() accept dst = NULL Kevin Wolf
2018-08-15 12:55 ` [Qemu-devel] [PULL 17/21] block: Remove children options from bs->{options, explicit_options} Kevin Wolf
2018-08-15 12:55 ` [Qemu-devel] [PULL 18/21] block: Simplify bdrv_reopen_abort() Kevin Wolf
2018-08-15 12:55 ` Kevin Wolf [this message]
2018-08-15 12:55 ` [Qemu-devel] [PULL 20/21] block: Simplify append_open_options() Kevin Wolf
2018-08-15 12:55 ` [Qemu-devel] [PULL 21/21] qapi: block: Remove mentions of error types which were removed Kevin Wolf
2018-08-16 8:50 ` [Qemu-devel] [PULL 00/21] Block layer patches Peter Maydell
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=20180815125537.10651-20-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=peter.maydell@linaro.org \
--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).