From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, pkrempa@redhat.com, qemu-devel@nongnu.org,
mreitz@redhat.com
Subject: [PATCH 1/2] block: Remove 'backing': null from bs->{explicit_, }options
Date: Fri, 8 Nov 2019 09:53:11 +0100 [thread overview]
Message-ID: <20191108085312.27049-2-kwolf@redhat.com> (raw)
In-Reply-To: <20191108085312.27049-1-kwolf@redhat.com>
bs->options and bs->explicit_options shouldn't contain any options for
child nodes. bdrv_open_inherited() takes care to remove any options that
match a child name after opening the image and the same is done when
reopening.
However, we miss the case of 'backing': null, which is a child option,
but results in no child being created. This means that a 'backing': null
remains in bs->options and bs->explicit_options.
A typical use for 'backing': null is in live snapshots: blockdev-add for
the qcow2 overlay makes sure not to open the backing file (because it is
already opened and blockdev-snapshot will attach it). After doing a
blockdev-snapshot, bs->options and bs->explicit_options become
inconsistent with the actual state (bs has a backing file now, but the
options still say null). On the next occasion that the image is
reopened, e.g. switching it from read-write to read-only when another
snapshot is taken, the option will take effect again and the node
incorrectly loses its backing file.
Fix bdrv_open_inherited() to remove the 'backing' option from
bs->options and bs->explicit_options even for the case where it
specifies that no backing file is wanted.
Reported-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/block.c b/block.c
index dad5a3d8e0..74ba9acb08 100644
--- a/block.c
+++ b/block.c
@@ -3019,6 +3019,8 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
"use \"backing\": null instead");
}
flags |= BDRV_O_NO_BACKING;
+ qdict_del(bs->explicit_options, "backing");
+ qdict_del(bs->options, "backing");
qdict_del(options, "backing");
}
--
2.20.1
next prev parent reply other threads:[~2019-11-08 8:54 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-08 8:53 [PATCH 0/2] block: Fix multiple blockdev-snapshot calls Kevin Wolf
2019-11-08 8:53 ` Kevin Wolf [this message]
2019-11-08 14:30 ` [PATCH 1/2] block: Remove 'backing': null from bs->{explicit_, }options Alberto Garcia
2019-11-12 16:01 ` [PATCH 1/2] block: Remove 'backing': null from bs->{explicit_,}options Peter Krempa
2019-11-08 8:53 ` [PATCH 2/2] iotests: Test multiple blockdev-snapshot calls Kevin Wolf
2019-11-08 14:32 ` Alberto Garcia
2019-11-13 9:28 ` Kevin Wolf
2019-11-12 16:07 ` Peter Krempa
2019-11-13 9:25 ` Kevin Wolf
2019-11-18 18:03 ` Max Reitz
2019-11-18 16:26 ` [PATCH 0/2] block: Fix " Peter Krempa
2019-11-18 16:49 ` 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=20191108085312.27049-2-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pkrempa@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).