qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 4/5] block: add read-only support to VHDX ima


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH v2 4/5] block: add read-only support to VHDX image format.
Date: Wed, 24 Apr 2013 16:38:37 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Tue, Apr 23, 2013 at 10:24:23AM -0400, Jeff Cody wrote:
> +static void vhdx_block_translate(BDRVVHDXState *s, int64_t sector_num,
> +                                 int nb_sectors, vhdx_sector_info *sinfo)
> +{
> +    uint32_t block_offset;
> +
> +    sinfo->bat_idx = sector_num >> s->sectors_per_block_bits;
> +    /* effectively a modulo - this gives us the offset into the block
> +     * (in sector sizes) for our sector number */
> +    block_offset = sector_num - (sinfo->bat_idx << 
> s->sectors_per_block_bits);
> +    /* the chunk ratio gives us the interleaving of the sector
> +     * bitmaps, so we need to advance our page block index by the
> +     * sector bitmaps entry number */
> +    sinfo->bat_idx += sinfo->bat_idx >> s->chunk_ratio_bits;
> +
> +    /* the number of sectors we can read/write in this cycle */
> +    sinfo->sectors_avail = s->sectors_per_block - block_offset;
> +
> +    sinfo->bytes_left = sinfo->sectors_avail << s->logical_sector_size_bits;
> +
> +    if (sinfo->sectors_avail > nb_sectors) {
> +        sinfo->sectors_avail = nb_sectors;
> +    }
> +
> +    sinfo->bytes_avail = sinfo->sectors_avail << s->logical_sector_size_bits;
> +
> +    sinfo->file_offset = s->bat[sinfo->bat_idx] >> VHDX_BAT_FILE_OFF_BITS;

If my calculation is correct, a 2 TB image would result in 16 MB of BAT
entries for payload blocks.  The BAT entries for sector bitmap blocks
would be smaller.

On a slow disk the startup time with many VHDX files could be be several
seconds though since we need to read all this data into memory.

Perhaps something to consider for the future but not critical right now.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]