From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56655) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZ0lf-0006EB-Pz for qemu-devel@nongnu.org; Mon, 07 Sep 2015 14:03:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZ0le-0000YU-PJ for qemu-devel@nongnu.org; Mon, 07 Sep 2015 14:03:47 -0400 References: <1437414365-11881-1-git-send-email-mreitz@redhat.com> <1437414365-11881-7-git-send-email-mreitz@redhat.com> <20150907174303.GH5529@noname.redhat.com> From: Max Reitz Message-ID: <55EDD177.6030300@redhat.com> Date: Mon, 7 Sep 2015 20:03:35 +0200 MIME-Version: 1.0 In-Reply-To: <20150907174303.GH5529@noname.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="BH7xpenl0AENO9ihoT5XtAgQge91XAcpG" Subject: Re: [Qemu-devel] [PATCH v4 06/38] block: Make bdrv_is_inserted() recursive List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: Alberto Garcia , qemu-block@nongnu.org, John Snow , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --BH7xpenl0AENO9ihoT5XtAgQge91XAcpG Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 07.09.2015 19:43, Kevin Wolf wrote: > Am 20.07.2015 um 19:45 hat Max Reitz geschrieben: >> If bdrv_is_inserted() is called on the top level BDS, it should make >> sure all nodes in the BDS tree are actually inserted. >> >> Signed-off-by: Max Reitz >> Reviewed-by: Eric Blake >> Reviewed-by: Alberto Garcia >> --- >> block.c | 7 +++---- >> 1 file changed, 3 insertions(+), 4 deletions(-) >> >> diff --git a/block.c b/block.c >> index 494e08e..1d27b6a 100644 >> --- a/block.c >> +++ b/block.c >> @@ -3235,10 +3235,9 @@ bool bdrv_is_inserted(BlockDriverState *bs) >> if (!drv) { >> return false; >> } >> - if (!drv->bdrv_is_inserted) { >> - return true; >> - } >> - return drv->bdrv_is_inserted(bs); >> + return (!drv->bdrv_is_inserted || drv->bdrv_is_inserted(bs)) && >> + (!bs->file || bdrv_is_inserted(bs->file)) && >> + (!bs->backing_hd || bdrv_is_inserted(bs->backing_hd= )); >> } >=20 > Hm... Recursion often makes the right semantics unclear. I think though= > what you're after here is good as a default behaviour, i.e. a non-leaf > node is inserted iff all of its children are inserted. We can do things= > in various ways without breaking stuff because raw-posix is the only > driver actually implementing .bdrv_is_inserted, but I think it would > make most sense like this: >=20 > * If a driver implements .bdrv_is_inserted, we use this (and only this)= > for determining whether a medium is inserted. >=20 > * The default behaviour for drivers which don't have .bdrv_is_inserted > is checking all children (in bs->children, not restricted to file and= > backing_hd, so that quorum etc. work) >=20 > * Consequently, a driver that doesn't want all of its children > considered (which may be a very valid desire), can implement its own > handler and doesn't get the default handling then. >=20 > This seems to be the most consistent with other recursive operations. You're right, I'll change this patch accordingly. > Also, after this patch, raw_bsd.c should be able drop its > implementation. Indeed. Max --BH7xpenl0AENO9ihoT5XtAgQge91XAcpG 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 iQEcBAEBCAAGBQJV7dF3AAoJEDuxQgLoOKyt4AYIAIfSHbyPbSSyzBx0FU7O1YMB 1b3IXu4OjMGJZ1hn+E+Ho5SHIWR9pGorGa8yPkrvnH10yls1r9dzWDOQCtNMiMBC Mdcl0KOKwGHAjnKtWUgHwQwMHksF9NOZ1TXIQfsA8RaEoGy04xS8BOAOL165lanM baoG5XnTFmtFGx6SQkdpRiWJl5GwUmMWnQRhAh1Fh+P8HDpAlCgSt5lIEAy2UG6H VhI7TRbYsuVkhezeS6/mf33v6VytOvXh/UxxsCgDYAv1rrOd736d/FGX86wTCwqH V6cJxd/RGrBMZ/rlzODyikA5L7DJqStD1tb2ZfPnhRZ3GR3lE8u3iwtzH90hEMg= =zeCT -----END PGP SIGNATURE----- --BH7xpenl0AENO9ihoT5XtAgQge91XAcpG--