From: Max Reitz <mreitz@redhat.com>
To: qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>,
Kevin Wolf <kwolf@redhat.com>, Fam Zheng <famz@redhat.com>
Subject: [Qemu-devel] [PATCH v2 1/3] block: Allow replacement of a BDS by its overlay
Date: Mon, 6 Jun 2016 16:42:10 +0200 [thread overview]
Message-ID: <20160606144212.24074-2-mreitz@redhat.com> (raw)
In-Reply-To: <20160606144212.24074-1-mreitz@redhat.com>
change_parent_backing_link() asserts that the BDS to be replaced is not
used as a backing file. However, we may want to replace a BDS by its
overlay in which case that very link should not be redirected.
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
block.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/block.c b/block.c
index f54bc25..16463aa 100644
--- a/block.c
+++ b/block.c
@@ -2224,9 +2224,22 @@ void bdrv_close_all(void)
static void change_parent_backing_link(BlockDriverState *from,
BlockDriverState *to)
{
- BdrvChild *c, *next;
+ BdrvChild *c, *next, *to_c;
QLIST_FOREACH_SAFE(c, &from->parents, next_parent, next) {
+ if (c->role == &child_backing) {
+ /* Allow @from to be in a backing chain, but only if it is @to's
+ * backing chain. Do not replace @from by @to there. */
+ QLIST_FOREACH(to_c, &to->children, next) {
+ if (to_c == c) {
+ break;
+ }
+ }
+ if (to_c) {
+ continue;
+ }
+ }
+
assert(c->role != &child_backing);
bdrv_ref(to);
bdrv_replace_child(c, to);
--
2.8.3
next prev parent reply other threads:[~2016-06-06 14:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-06 14:42 [Qemu-devel] [PATCH v2 0/3] block/mirror: Fix target backing BDS Max Reitz
2016-06-06 14:42 ` Max Reitz [this message]
2016-06-08 8:58 ` [Qemu-devel] [PATCH v2 1/3] block: Allow replacement of a BDS by its overlay Kevin Wolf
2016-06-08 14:21 ` Max Reitz
2016-06-06 14:42 ` [Qemu-devel] [PATCH v2 2/3] block/mirror: Fix target backing BDS Max Reitz
2016-06-08 9:32 ` Kevin Wolf
2016-06-08 11:28 ` Paolo Bonzini
2016-06-08 11:47 ` Kevin Wolf
2016-06-08 14:40 ` Max Reitz
2016-06-08 14:42 ` Max Reitz
2016-06-08 14:38 ` Max Reitz
2016-06-08 16:54 ` Max Reitz
2016-06-08 15:39 ` Nir Soffer
2016-06-09 8:58 ` Kevin Wolf
2016-06-09 11:16 ` Nir Soffer
2016-06-06 14:42 ` [Qemu-devel] [PATCH v2 3/3] iotests: Add test for post-mirror backing chains 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=20160606144212.24074-2-mreitz@redhat.com \
--to=mreitz@redhat.com \
--cc=famz@redhat.com \
--cc=kwolf@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.