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 > --- > -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 -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org