From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50164) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YG9d4-0001wd-JV for qemu-devel@nongnu.org; Tue, 27 Jan 2015 12:08:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YG9d0-0004e3-ET for qemu-devel@nongnu.org; Tue, 27 Jan 2015 12:08:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49744) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YG9d0-0004dx-81 for qemu-devel@nongnu.org; Tue, 27 Jan 2015 12:08:38 -0500 Message-ID: <54C7C60F.5050107@redhat.com> Date: Tue, 27 Jan 2015 10:08:31 -0700 From: Eric Blake MIME-Version: 1.0 References: <1422284444-12529-1-git-send-email-mreitz@redhat.com> <1422284444-12529-12-git-send-email-mreitz@redhat.com> In-Reply-To: <1422284444-12529-12-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="roh1sLEUvgQbXF3iEQwSW1P0OdTwGq3jq" Subject: Re: [Qemu-devel] [PATCH v3 11/14] qemu-io: Use BlockBackend List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel@nongnu.org Cc: Kevin Wolf , Markus Armbruster , Stefan Hajnoczi , Stefano Stabellini This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --roh1sLEUvgQbXF3iEQwSW1P0OdTwGq3jq Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 01/26/2015 08:00 AM, Max Reitz wrote: > qemu-io should behave like a guest, therefore it should use BlockBacken= d > to access the block layer. >=20 > There are a couple of places where that is infeasible: First, the > bdrv_debug_* functions could theoretically be mirrored in the > BlockBackend, but since these are functions internal to the block layer= , > they should not be visible externally (qemu-io as a test tool is excemp= t s/excempt/exempt/ > from this). >=20 > Second, bdrv_get_info() and bdrv_get_specific_info() work on a single > BDS alone, therefore they should stay BDS-specific. >=20 > Third, bdrv_is_allocated() mainly works on a single BDS as well. Some > data may be passed through from the BDS's file (if sectors which are > apparently allocated in the file are not really allocated there but jus= t > zero). >=20 > Signed-off-by: Max Reitz > --- > -static int map_f(BlockDriverState *bs, int argc, char **argv) > +static int map_f(BlockBackend *blk, int argc, char **argv) > { > int64_t offset; > - int64_t nb_sectors; > + int64_t nb_sectors, total_sectors; > char s1[64]; > int64_t num; > int ret; > const char *retstr; > =20 > offset =3D 0; > - nb_sectors =3D bs->total_sectors; > + total_sectors =3D blk_getlength(blk); > + if (total_sectors < 0) { > + error_report("Failed to query image length: %s", > + strerror(-total_sectors)); > + return 0; > + } > + > + total_sectors /=3D BDRV_SECTOR_SIZE; Another spot that would benefit from a (possibly temporary) bdrv_nb_sectors(). Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --roh1sLEUvgQbXF3iEQwSW1P0OdTwGq3jq Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJUx8YPAAoJEKeha0olJ0NqjJkH/2eQbJvxicUiHqCjxP96KQPa M+ePbXNM7Ouu3v1gYD3wrrqCc+cBHggfXS2o13x2GUAhwea0ERSX96MszBn/8TLA OWu63BgGfzP1S8ycAgCM2h/VdxJciUWB3KoL/G3PwbzOwL8DbefVHZYKnizYY6/g UIUg2K9ylodtKyaFgHDXUx7xThuHBYwhesMe4GxHOeBfnD1QBKY2N5Fzejy3nMx3 I/RUCMGxHu5HEPBqQ5exE7e6rPnIMuqy5dOULcr30VGEyRLg/IdRZcYjq4m5iW46 2cZMOAMW/nkpW3zxOXMiUu6ZpCCAoRfeoccxeM85usLEsqU5rG3PKO2O09PEQOI= =Ewnh -----END PGP SIGNATURE----- --roh1sLEUvgQbXF3iEQwSW1P0OdTwGq3jq--