[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 11/14] qemu-io: Use BlockBackend
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v3 11/14] qemu-io: Use BlockBackend |
Date: |
Tue, 27 Jan 2015 10:08:31 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 |
On 01/26/2015 08:00 AM, Max Reitz wrote:
> qemu-io should behave like a guest, therefore it should use BlockBackend
> to access the block layer.
>
> 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 excempt
s/excempt/exempt/
> from this).
>
> Second, bdrv_get_info() and bdrv_get_specific_info() work on a single
> BDS alone, therefore they should stay BDS-specific.
>
> 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 just
> zero).
>
> Signed-off-by: Max Reitz <address@hidden>
> ---
> -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;
>
> offset = 0;
> - nb_sectors = bs->total_sectors;
> + total_sectors = blk_getlength(blk);
> + if (total_sectors < 0) {
> + error_report("Failed to query image length: %s",
> + strerror(-total_sectors));
> + return 0;
> + }
> +
> + total_sectors /= BDRV_SECTOR_SIZE;
Another spot that would benefit from a (possibly temporary)
bdrv_nb_sectors().
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCH v3 07/14] qemu-img: Use BlockBackend as far as possible, (continued)
[Qemu-devel] [PATCH v3 14/14] block: Keep bdrv_check*_request()'s return value, Max Reitz, 2015/01/26
[Qemu-devel] [PATCH v3 12/14] block: Clamp BlockBackend requests, Max Reitz, 2015/01/26
[Qemu-devel] [PATCH v3 13/14] block: Remove "growable" from BDS, Max Reitz, 2015/01/26
[Qemu-devel] [PATCH v3 11/14] qemu-io: Use BlockBackend, Max Reitz, 2015/01/26
- Re: [Qemu-devel] [PATCH v3 11/14] qemu-io: Use BlockBackend,
Eric Blake <=
[Qemu-devel] [PATCH v3 02/14] block: Add blk_new_open(), Max Reitz, 2015/01/26
[Qemu-devel] [PATCH v3 01/14] block: Lift some BDS functions to the BlockBackend, Max Reitz, 2015/01/26
Re: [Qemu-devel] [PATCH v3 00/14] block: Remove "growable", add blk_new_open(), Stefano Stabellini, 2015/01/26