qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Fam Zheng <famz@redhat.com>
Cc: Max Reitz <mreitz@redhat.com>,
	qemu-block@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v3 1/5] block: Allow replacement of a BDS by its overlay
Date: Mon, 13 Jun 2016 17:13:40 +0200	[thread overview]
Message-ID: <20160613151340.GD5968@noname.str.redhat.com> (raw)
In-Reply-To: <20160612031547.GF27167@ad.usersys.redhat.com>

Am 12.06.2016 um 05:15 hat Fam Zheng geschrieben:
> On Fri, 06/10 20:57, Max Reitz wrote:
> > 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.
> > 
> > For instance, when doing a sync=none drive-mirror operation, we may have
> > the following BDS/BB forest before block job completion:
> > 
> >   target
> > 
> >   base <- source <- BlockBackend
> > 
> > During job completion, we want to establish the source BDS as the
> > target's backing node:
> > 
> >           target
> >             |
> >             v
> >   base <- source <- BlockBackend
> > 
> > This makes the target a valid replacement for the source:
> > 
> >           target <- BlockBackend
> >             |
> >             v
> >   base <- source
> > 
> > Without this modification to change_parent_backing_link() we have to
> > inject the target into the graph before the source is its backing node,
> > thus temporarily creating a wrong graph:
> > 
> >   target <- BlockBackend
> > 
> >   base <- source
> > 
> > Signed-off-by: Max Reitz <mreitz@redhat.com>
> > ---
> >  block.c | 16 +++++++++++++++-
> >  1 file changed, 15 insertions(+), 1 deletion(-)
> > 
> > diff --git a/block.c b/block.c
> > index f54bc25..dc76c159 100644
> > --- a/block.c
> > +++ b/block.c
> > @@ -2224,9 +2224,23 @@ 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) {
> > +            /* @from is generally not allowed to be a backing file, except for
> > +             * when @to is the overlay. In that case, @from may not be replaced
> > +             * by @to as @to's backing node. */
> > +            QLIST_FOREACH(to_c, &to->children, next) {
> > +                if (to_c == c) {
> > +                    break;
> > +                }
> > +            }
> 
> Why not just test "c->bs == to" here, why is it necessary to iterate through
> to->children list?

Because c->bs == from. We want to check whether 'to' is the parent, not
whether it is the child.

Kevin

  reply	other threads:[~2016-06-13 15:13 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-10 18:57 [Qemu-devel] [PATCH v3 0/5] block/mirror: Fix (?) target backing BDS Max Reitz
2016-06-10 18:57 ` [Qemu-devel] [PATCH v3 1/5] block: Allow replacement of a BDS by its overlay Max Reitz
2016-06-12  3:15   ` Fam Zheng
2016-06-13 15:13     ` Kevin Wolf [this message]
2016-06-10 18:57 ` [Qemu-devel] [PATCH v3 2/5] block/mirror: Fix target backing BDS Max Reitz
2016-06-10 18:57 ` [Qemu-devel] [PATCH v3 3/5] block/null: Implement bdrv_refresh_filename() Max Reitz
2016-06-12  4:08   ` Fam Zheng
2016-06-14 12:59     ` Max Reitz
2016-06-10 18:57 ` [Qemu-devel] [PATCH v3 4/5] iotests: Add test for post-mirror backing chains Max Reitz
2016-06-12  4:17   ` Fam Zheng
2016-06-14 13:01     ` Max Reitz
2016-06-10 18:57 ` [Qemu-devel] [PATCH v3 5/5] iotests: Add test for oVirt-like storage migration Max Reitz
2016-06-12  4:23 ` [Qemu-devel] [PATCH v3 0/5] block/mirror: Fix (?) target backing BDS Fam Zheng
2016-06-13 15:16 ` Kevin Wolf
2016-06-14 15:53 ` 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=20160613151340.GD5968@noname.str.redhat.com \
    --to=kwolf@redhat.com \
    --cc=famz@redhat.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).