From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58387) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avQ7Q-0002lu-Op for qemu-devel@nongnu.org; Wed, 27 Apr 2016 10:07:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1avQ7L-0006Y7-4Y for qemu-devel@nongnu.org; Wed, 27 Apr 2016 10:07:08 -0400 Date: Wed, 27 Apr 2016 15:06:47 +0100 From: Stefan Hajnoczi Message-ID: <20160427140647.GF1985@stefanha-x1.localdomain> References: <1461750767-23273-1-git-send-email-kwolf@redhat.com> <1461750767-23273-7-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="bGR76rFJjkSxVeRa" Content-Disposition: inline In-Reply-To: <1461750767-23273-7-git-send-email-kwolf@redhat.com> Subject: Re: [Qemu-devel] [PATCH 06/17] bochs: Implement .bdrv_co_preadv() interface List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-block@nongnu.org, mreitz@redhat.com, famz@redhat.com, sw@weilnetz.de, qemu-devel@nongnu.org --bGR76rFJjkSxVeRa Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Apr 27, 2016 at 11:52:36AM +0200, Kevin Wolf wrote: > Signed-off-by: Kevin Wolf > --- > block/bochs.c | 46 +++++++++++++++++++++++++++++----------------- > 1 file changed, 29 insertions(+), 17 deletions(-) >=20 > diff --git a/block/bochs.c b/block/bochs.c > index af8b7ab..d148454 100644 > --- a/block/bochs.c > +++ b/block/bochs.c > @@ -104,6 +104,7 @@ static int bochs_open(BlockDriverState *bs, QDict *op= tions, int flags, > int ret; > =20 > bs->read_only =3D 1; // no write support yet > + bs->request_alignment =3D BDRV_SECTOR_SIZE; /* No sub-sector I/O sup= ported */ Can this be the default in block.c? Drivers that have other alignment characteristics can set it explicitly but most drivers will want BDRV_SECTOR_SIZE so it's nice to make it common code. > =20 > ret =3D bdrv_pread(bs->file->bs, 0, &bochs, sizeof(bochs)); > if (ret < 0) { > @@ -221,39 +222,50 @@ static int64_t seek_to_sector(BlockDriverState *bs,= int64_t sector_num) > return bitmap_offset + (512 * (s->bitmap_blocks + extent_offset)); > } > =20 > -static int bochs_read(BlockDriverState *bs, int64_t sector_num, > - uint8_t *buf, int nb_sectors) > +static int coroutine_fn > +bochs_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, > + QEMUIOVector *qiov, int flags) > { > + BDRVBochsState *s =3D bs->opaque; > + uint64_t sector_num =3D offset >> BDRV_SECTOR_BITS; > + int nb_sectors =3D bytes >> BDRV_SECTOR_BITS; > + uint64_t bytes_done =3D 0; > + QEMUIOVector local_qiov; > int ret; > =20 > + assert((offset & (BDRV_SECTOR_SIZE - 1)) =3D=3D 0); > + assert((bytes & (BDRV_SECTOR_SIZE - 1)) =3D=3D 0); > + > + qemu_iovec_init(&local_qiov, qiov->niov); > + qemu_co_mutex_lock(&s->lock); > + > while (nb_sectors > 0) { > int64_t block_offset =3D seek_to_sector(bs, sector_num); > if (block_offset < 0) { > return block_offset; s->lock must be unlocked. > - } else if (block_offset > 0) { > - ret =3D bdrv_pread(bs->file->bs, block_offset, buf, 512); > + } > + > + qemu_iovec_reset(&local_qiov); > + qemu_iovec_concat(&local_qiov, qiov, bytes_done, 512); > + > + if (block_offset > 0) { > + ret =3D bdrv_co_preadv(bs->file->bs, block_offset, 512, > + &local_qiov, 0); > if (ret < 0) { > return ret; Same here. --bGR76rFJjkSxVeRa Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJXIMd3AAoJEJykq7OBq3PId9oH/2Z42/b0jSEWmHZfw9alqgO5 UEywNvUcsxhYq81hTwSBZKqOLqltaDanYhfX32yNsReSSw9mBZP6ZXPLjnS/2Nb7 4zpPod9Mtwu551n5v6FXQ+taQJqa8B0+24KaMa+XH6qOwOQP7z5KIuyl56wCqAaI USxuT8fHkQ3IyQxc86UiABmGTLQb5piS0v2V8fbGwGNFttmLK1wxBrI5LPFMOFKF ATW3ZNRkP2mQUGV5PXIy6b08ysW81vNo4tzy3mpXd2siMs/JZtAeAl1/G8Z8v9I6 RCSTTnDUNapZlZ8Ymz+KcY5q/q0oUUQ3R6oEaDDdBxlASXc2g7wnNLpbCZJm2bs= =obGr -----END PGP SIGNATURE----- --bGR76rFJjkSxVeRa--