From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39896) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZemFL-0001gW-7w for qemu-devel@nongnu.org; Wed, 23 Sep 2015 11:46:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZemFK-000212-7Q for qemu-devel@nongnu.org; Wed, 23 Sep 2015 11:46:15 -0400 References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-12-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: <5602C93C.4060305@redhat.com> Date: Wed, 23 Sep 2015 17:46:04 +0200 MIME-Version: 1.0 In-Reply-To: <1442497700-2536-12-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="hk5JNJIltBNQLTod08bqoaOvSMovML4xu" Subject: Re: [Qemu-devel] [PATCH 11/16] block-backend: Add blk_set_bs() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , qemu-block@nongnu.org Cc: jcody@redhat.com, berto@igalia.com, armbru@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --hk5JNJIltBNQLTod08bqoaOvSMovML4xu Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 17.09.2015 15:48, Kevin Wolf wrote: > It allows changing the BlockDriverState that a BlockBackend points to. >=20 > Signed-off-by: Kevin Wolf > --- > block/block-backend.c | 16 ++++++++++++++++ > include/block/block_int.h | 2 ++ > 2 files changed, 18 insertions(+) >=20 > diff --git a/block/block-backend.c b/block/block-backend.c > index c2e8732..a2afcff 100644 > --- a/block/block-backend.c > +++ b/block/block-backend.c > @@ -239,6 +239,22 @@ BlockDriverState *blk_bs(BlockBackend *blk) > } > =20 > /* > + * Changes the BlockDriverState attached to @blk > + */ > +void blk_set_bs(BlockBackend *blk, BlockDriverState *bs) > +{ > + bdrv_ref(bs); > + > + if (blk->bs) { > + blk->bs->blk =3D NULL; > + bdrv_unref(blk->bs); > + } > + > + blk->bs =3D bs; > + bs->blk =3D blk; > +} > + > +/* As discussed in the BlockBackend and media thread, you should probably assert(bs->blk =3D=3D NULL), and I'd rather have this implemented as blk_remove_bs(blk); blk_insert_bs(blk, bs);, but that's probably something that won't happen until I do so myself. Max > * Return @blk's DriveInfo if any, else null. > */ > DriveInfo *blk_legacy_dinfo(BlockBackend *blk) > diff --git a/include/block/block_int.h b/include/block/block_int.h > index 4598101..cfcae52 100644 > --- a/include/block/block_int.h > +++ b/include/block/block_int.h > @@ -659,6 +659,8 @@ void backup_start(BlockDriverState *bs, BlockDriver= State *target, > BlockCompletionFunc *cb, void *opaque, > Error **errp); > =20 > +void blk_set_bs(BlockBackend *blk, BlockDriverState *bs); > + > void blk_dev_change_media_cb(BlockBackend *blk, bool load); > bool blk_dev_has_removable_media(BlockBackend *blk); > void blk_dev_eject_request(BlockBackend *blk, bool force); >=20 --hk5JNJIltBNQLTod08bqoaOvSMovML4xu 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 iQEcBAEBCAAGBQJWAsk8AAoJEDuxQgLoOKyt59YIAIom4on81Ebz7IpUyaZ0HgKC 6O96xV+3MPWz9xcsrvQyo7BnmwtQsIuhwp7wFoZ1SHFs6tn9u9IxqU0ivtAz4Kjk dWVeAmfewnSz28FldYCtG6JOBP/WWMkX23E3fZEPS8T/V/egYouVGm7MiYHgh085 Mszu++aj0LQNvagBEkCnG9I+XKAy35wU94/p2jeMwQSX4DEsMMxvSKJgzqbZPwcT 2GW6eIpjI7qy/FTHRVWOjHkXvFPzVn5qOGJw3aLvcSyGW/QezpRJKg8fex3k+uKO im694ezcnuxJVeuTS0B4ydhMl6NUtir/uMG12JZMPnKEqDw6cnejnwLWW/ciHdQ= =tHAa -----END PGP SIGNATURE----- --hk5JNJIltBNQLTod08bqoaOvSMovML4xu--