Received: from eggs.gnu.org ([2001:4830:134:3::10]:50867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAeMa-0001d7-0c for qemu-devel@nongnu.org; Wed, 08 Jun 2016 10:21:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAeMY-000287-Tm for qemu-devel@nongnu.org; Wed, 08 Jun 2016 10:21:43 -0400 References: <20160606144212.24074-1-mreitz@redhat.com> <20160606144212.24074-2-mreitz@redhat.com> <20160608085835.GB5324@noname.str.redhat.com> From: Max Reitz Message-ID: <16355317-d153-539d-8e77-e5480890dd48@redhat.com> Date: Wed, 8 Jun 2016 16:21:32 +0200 MIME-Version: 1.0 In-Reply-To: <20160608085835.GB5324@noname.str.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Ufrhlrjhg8kuNDbp5ePnfd4mF29otbDQN" Subject: Re: [Qemu-devel] [PATCH v2 1/3] block: Allow replacement of a BDS by its overlay List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Fam Zheng This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Ufrhlrjhg8kuNDbp5ePnfd4mF29otbDQN From: Max Reitz To: Kevin Wolf Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Fam Zheng Message-ID: <16355317-d153-539d-8e77-e5480890dd48@redhat.com> Subject: Re: [PATCH v2 1/3] block: Allow replacement of a BDS by its overlay References: <20160606144212.24074-1-mreitz@redhat.com> <20160606144212.24074-2-mreitz@redhat.com> <20160608085835.GB5324@noname.str.redhat.com> In-Reply-To: <20160608085835.GB5324@noname.str.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 08.06.2016 10:58, Kevin Wolf wrote: > Am 06.06.2016 um 16:42 hat Max Reitz geschrieben: >> change_parent_backing_link() asserts that the BDS to be replaced is no= t >> 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 >=20 > So the scenario is like this? >=20 > +---- to > v > base <- from <- top >=20 > And we want to change it into this: >=20 > base <- from <- to <- top >=20 > Okay, makes sense. Doesn't the assert(c->role !=3D &child_backing) prevent this scenario? (which is the reason for the first sentence in my commit message.) So the scenario is rather: +----- target v base <- source <- BB to: base <- source <- target <- BB > (Hm, put ASCII art in the commit message? I'd be all for it.) Well, depending on whether a v3 will come or not, I can put it there, of course. >=20 >> 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; >> =20 >> QLIST_FOREACH_SAFE(c, &from->parents, next_parent, next) { >> + if (c->role =3D=3D &child_backing) { >> + /* Allow @from to be in a backing chain, but only if it i= s @to's >> + * backing chain. Do not replace @from by @to there. */ >=20 > The comment suggests bdrv_chain_contains(), but you only accept it as a= > direct child of top and you accept non-backing-file children. >=20 > Intuitively I would say that anywhere in the backing chain would make > sense, but we can always allow that later when we actually need it. > Accepting all types of children sounds right when I think about > inserting a quorum node as 'to'. >=20 > So I guess the code is fine and the comment should be changed to > correctly reflect what the code does. OK, will do. >> + QLIST_FOREACH(to_c, &to->children, next) { >> + if (to_c =3D=3D c) { >> + break; >> + } >> + } >> + if (to_c) { >> + continue; >> + } >> + } >> + >> assert(c->role !=3D &child_backing); >> bdrv_ref(to); >> bdrv_replace_child(c, to); >=20 > The other thing is that I'm unsure whether this function makes any sens= e > at all. "Replace in all parents" is kind of arbitrary. In the long term= , > we may want to allow the user to specify the exact graph modifications > on (block-)job-complete. Well, as a replacement of bdrv_swap(), this function definitely does make sense. Whether we can do even better in the long run... Is a question for the long run, I think. Max --Ufrhlrjhg8kuNDbp5ePnfd4mF29otbDQN Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJXWCnsAAoJEDuxQgLoOKyt3ywIAIIT9l+mjsI1fy5Sh0JVtgq5 eqtB70JyotziPQebhDEQD38l7xWrmr8KaPsosvYdscNtz4r6wqc9N5Db98nVepfH YVnliy6stZeJBSVVq9YssT0vJmTrdGqDzoVp3mPojN/etpCE2x33jRZ5wsgWAXAI 5Ma4oTBFv/W2XW35QxgOwuwRvTFQGaf4vaYGRFuRTV+cS4DUmvQ1jDHl/seED9BB Uk3u29oxV7etRthg1q1I7puPA41kh9lkFN4/q/Ku5wGUhOy/HZOmu9dIwYJdLC/U 0w/nZqGXwD4pyv/MajQkoJrqg3Gidt1sojOO4Mvc5t6nNgWjDNQqAYmVjUvxjDo= =4f8w -----END PGP SIGNATURE----- --Ufrhlrjhg8kuNDbp5ePnfd4mF29otbDQN--