From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58817) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9wdo-0000OP-HE for qemu-devel@nongnu.org; Fri, 18 Dec 2015 10:08:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a9wdn-0004M3-6J for qemu-devel@nongnu.org; Fri, 18 Dec 2015 10:08:20 -0500 From: Kevin Wolf Date: Fri, 18 Dec 2015 16:07:18 +0100 Message-Id: <1450451274-7472-13-git-send-email-kwolf@redhat.com> In-Reply-To: <1450451274-7472-1-git-send-email-kwolf@redhat.com> References: <1450451274-7472-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 12/48] block: Allow specifying child options in reopen List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org If the child was defined in the same context (-drive argument or blockdev-add QMP command) as its parent, a reopen of the parent should work the same and allow changing options of the child. Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz Reviewed-by: Alberto Garcia --- block.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/block.c b/block.c index 2c41fff..9c42b17 100644 --- a/block.c +++ b/block.c @@ -1720,15 +1720,23 @@ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue, flags &= ~BDRV_O_PROTOCOL; QLIST_FOREACH(child, &bs->children, next) { + QDict *new_child_options; + char *child_key_dot; int child_flags; + /* reopen can only change the options of block devices that were + * implicitly created and inherited options. For other (referenced) + * block devices, a syntax like "backing.foo" results in an error. */ if (child->bs->inherits_from != bs) { continue; } + child_key_dot = g_strdup_printf("%s.", child->name); + qdict_extract_subqdict(options, &new_child_options, child_key_dot); + g_free(child_key_dot); + child_flags = child->role->inherit_flags(flags); - /* TODO Pass down child flags (backing.*, extents.*, ...) */ - bdrv_reopen_queue(bs_queue, child->bs, NULL, child_flags); + bdrv_reopen_queue(bs_queue, child->bs, new_child_options, child_flags); } bs_entry = g_new0(BlockReopenQueueEntry, 1); -- 1.8.3.1