From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXA6m-0007BS-2f for qemu-devel@nongnu.org; Wed, 02 Sep 2015 11:37:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXA6k-0008Bw-Ve for qemu-devel@nongnu.org; Wed, 02 Sep 2015 11:37:56 -0400 References: <1441183880-26993-1-git-send-email-wency@cn.fujitsu.com> <1441183880-26993-2-git-send-email-wency@cn.fujitsu.com> From: Eric Blake Message-ID: <55E717C7.5050303@redhat.com> Date: Wed, 2 Sep 2015 09:37:43 -0600 MIME-Version: 1.0 In-Reply-To: <1441183880-26993-2-git-send-email-wency@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="PbvqhKbmJaT3gldSnJbxkI1h0433nxsmM" Subject: Re: [Qemu-devel] [PATCH 01/16] introduce a new API to enable/disable attach device model List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wen Congyang , qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Cc: Kevin Wolf , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Yang Hongyang This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --PbvqhKbmJaT3gldSnJbxkI1h0433nxsmM Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/02/2015 02:51 AM, Wen Congyang wrote: > Signed-off-by: Wen Congyang > --- > block/block-backend.c | 24 ++++++++++++++++++++++++ > include/sysemu/block-backend.h | 2 ++ > 2 files changed, 26 insertions(+) >=20 > diff --git a/block/block-backend.c b/block/block-backend.c > index aee8a12..72d8b2c 100644 > --- a/block/block-backend.c > +++ b/block/block-backend.c > @@ -344,6 +344,30 @@ void *blk_get_attached_dev(BlockBackend *blk) > } > =20 > /* > + * Disable to attach a device mode to @blk. s/to attach/attaching/ s/mode/model/ But I'm not even sure this patch makes sense. I'd rather see Max's work go in that allows for a BB without a BDS as representing a drive without media, because then it is clear - either a BB has an associated BDS (and cannot attach another one), or it does not (and attaching is fine). > + * Return 0 on success, -EBUSY when a device model is attached already= =2E > + */ > +int blk_disable_attach_dev(BlockBackend *blk) > +{ > + if (blk->dev) { > + return blk->dev =3D=3D (void *)-1 ? 0 : -EBUSY; > + } > + > + blk->dev =3D (void *)-1; > + return 0; > +} > + > +/* > + * Enable to attach a device mode to @blk. > + */ > +void blk_enable_attach_dev(BlockBackend *blk) > +{ > + if (blk->dev =3D=3D (void *)-1) { At the very least, if we allow a special sentinel to represent a BB without a BDS (other than NULL, the way Max's series does it), it should at least be wrapped by a macro, rather than using '(void *)-1' at multiple call sites. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --PbvqhKbmJaT3gldSnJbxkI1h0433nxsmM 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 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV5xfHAAoJEKeha0olJ0NqvvoIAI4iAOWL4JBkd7JkdULQhvkj Od2Vn5HAvc2I/33PwxeZCP3qKtFhapJpmvoqLASuwkedY2aj+OLBEpwaFCRezWIE Y9F1cPCK4IuWfD1W+UhNrLqVAZiiPcxQLHau4c5DITAHHtiWeaeH0pKwuv5dYZnm gVaa5LDAnvKIFgyhalqvRLnWvB0Sd6ymwSnxcRNYgns6+Wv4P17cl+a25QFn2pbo 5HqCIzvqYrd4Bjc4gzLLBxtZB3zraZW+Cx8+nEtcsM7hzznublyTgnsudg4BQo4I tKT+8OO8Et2EAe4jiOLSN0i2ttxSN9D61qZJDY2AmAzisr7dAjpclh0yDQn5VFY= =FEd2 -----END PGP SIGNATURE----- --PbvqhKbmJaT3gldSnJbxkI1h0433nxsmM--