On Mon, Jun 08, 2015 at 06:21:22PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> +BdrvDirtyBitmap *bdrv_load_dirty_bitmap(BlockDriverState *bs,
> +                                        BlockDriverState *file,
> +                                        int granularity,
> +                                        const char *name,
> +                                        Error **errp)
> +{
> +    BlockDriver *drv = file->drv;
> +    if (!drv) {
> +        return NULL;
> +    }
> +    if (drv->bdrv_dirty_bitmap_load) {
> +        BdrvDirtyBitmap *bitmap;
> +        uint64_t bitmap_size = bdrv_nb_sectors(bs);
> +        uint8_t *buf = drv->bdrv_dirty_bitmap_load(file, name, bitmap_size,
> +                                                   granularity);
> +        if (buf == NULL) {
> +            return NULL;
> +        }
> +
> +        bitmap = bdrv_create_dirty_bitmap(bs, granularity, name, errp);
> +        if (bitmap == NULL) {
> +            g_free(buf);
> +            return NULL;
> +        }
> +
> +        hbitmap_deserialize_part(bitmap->bitmap, buf, 0, bitmap_size);
> +        hbitmap_deserialize_finish(bitmap->bitmap);

How about passing bitmap and errp into drv->bdrv_dirty_bitmap_load?
That way bdrv_dirty_bitmap_load() can stream using
hbitmap_deserialize_part() and does not need to allocate the full
bitmap.  It can also report errors properly.

Attachment: pgpp5AzsY6fRN.pgp
Description: PGP signature

Reply via email to