On 22/05/2015 05:40, Fam Zheng wrote: > +{ > + BlockDriverState *p; > + int64_t ret; > + > + assert(bs != base); > + for (p = bs; p != base; p = p->backing_hd) { > + ret = bdrv_co_get_block_status(p, sector_num, nb_sectors, pnum);
It's a bit ugly to have different parameters for bdrv_get_block_status and bdrv_co_get_block_status. > + if (ret < 0 || ret & BDRV_BLOCK_ALLOCATED) { > + break; > + } > + } > + return ret; > +} > + I think BDRV_BLOCK_ALLOCATED will always be true if passing NULL as the base, so patch 3 still needs a tweak. But, more important, you need extra logic to correct the output value of pnum, as in bdrv_is_allocated_above. If you want, you can also reimplemented bdrv_is_allocated_above on top of bdrv_get_block_status. Paolo