From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48431) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avoDO-00054v-Rm for qemu-devel@nongnu.org; Thu, 28 Apr 2016 11:51:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1avoDJ-0005Lb-5P for qemu-devel@nongnu.org; Thu, 28 Apr 2016 11:50:54 -0400 References: <1461849406-29743-1-git-send-email-kwolf@redhat.com> <1461849406-29743-7-git-send-email-kwolf@redhat.com> From: Eric Blake Message-ID: <57223150.3010404@redhat.com> Date: Thu, 28 Apr 2016 09:50:40 -0600 MIME-Version: 1.0 In-Reply-To: <1461849406-29743-7-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="rUPxoJvXltn4bKsUCWtCpc56HGAFeSaDW" Subject: Re: [Qemu-devel] [PATCH v2 06/17] bochs: Implement .bdrv_co_preadv() interface List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , qemu-block@nongnu.org Cc: famz@redhat.com, sw@weilnetz.de, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --rUPxoJvXltn4bKsUCWtCpc56HGAFeSaDW Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 04/28/2016 07:16 AM, Kevin Wolf wrote: > Signed-off-by: Kevin Wolf > --- > block/bochs.c | 51 +++++++++++++++++++++++++++++++++------------------= > 1 file changed, 33 insertions(+), 18 deletions(-) >=20 > + uint64_t sector_num =3D offset >> BDRV_SECTOR_BITS; > + int nb_sectors =3D bytes >> BDRV_SECTOR_BITS; Since we're using the named constant here (instead of /512 or >>9),... > + 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; > - } else if (block_offset > 0) { > - ret =3D bdrv_pread(bs->file->bs, block_offset, buf, 512); > + ret =3D block_offset; > + goto fail; > + } > + > + qemu_iovec_reset(&local_qiov); > + qemu_iovec_concat(&local_qiov, qiov, bytes_done, 512); should we also use the named constant BDRV_SECTOR_SIZE here instead of 51= 2? I don't care strongly enough for a respin, though, particularly since it would affect line wrapping. Reviewed-by: Eric Blake > + > + if (block_offset > 0) { > + ret =3D bdrv_co_preadv(bs->file->bs, block_offset, 512, > + &local_qiov, 0); > if (ret < 0) { > - return ret; > + goto fail; > } > } else { > - memset(buf, 0, 512); > + qemu_iovec_memset(&local_qiov, 0, 0, 512); > } > nb_sectors--; > sector_num++; > - buf +=3D 512; > + bytes_done +=3D 512; More of the magic 512, if you care. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --rUPxoJvXltn4bKsUCWtCpc56HGAFeSaDW 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/ iQEcBAEBCAAGBQJXIjFQAAoJEKeha0olJ0NqiVoH/3ppAaWovSxL/ummAwhhCLFz ZXXtEysH3SVV3gUr4kcORHjc+exGgcpd6SdWvDeYgY6vXv4IUaRV4zVl6MmgJDgj /L4s7mrtKrqZu2TWv+cywHiJCxbQ2Ht7Df044IuzAdyOlCnrTdvrzo5ipRuBGoMn dn1qFmBaREsIwsOrNBl9YQP+Gs0BigKTyrHMNRnUSC9Cdfdcu+PGjrQSqIUWVkbS 6TNMU0Jq+jT609AeU/dmSPQMdorwmZqAMbRECq9LbetjUXnCe2GOWtC9cLBBAYXQ 2JDcA9ysdweSmmwKivcoJl0h3kmf69HY65rbVSC7QB2r3sRJKOfPIb67djICZNY= =Cgku -----END PGP SIGNATURE----- --rUPxoJvXltn4bKsUCWtCpc56HGAFeSaDW--