mirror of https://github.com/xemu-project/xemu.git
block/dirty-bitmap: add deserialize_ones func
Add bdrv_dirty_bitmap_deserialize_ones() function, which is needed for qcow2 bitmap loading, to handle unallocated bitmap parts, marked as all-ones. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Message-id: 20170628120530.31251-7-vsementsov@virtuozzo.com Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
ba06ff1a5c
commit
6bdc8b719a
|
@ -586,6 +586,13 @@ void bdrv_dirty_bitmap_deserialize_zeroes(BdrvDirtyBitmap *bitmap,
|
||||||
hbitmap_deserialize_zeroes(bitmap->bitmap, start, count, finish);
|
hbitmap_deserialize_zeroes(bitmap->bitmap, start, count, finish);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bdrv_dirty_bitmap_deserialize_ones(BdrvDirtyBitmap *bitmap,
|
||||||
|
uint64_t start, uint64_t count,
|
||||||
|
bool finish)
|
||||||
|
{
|
||||||
|
hbitmap_deserialize_ones(bitmap->bitmap, start, count, finish);
|
||||||
|
}
|
||||||
|
|
||||||
void bdrv_dirty_bitmap_deserialize_finish(BdrvDirtyBitmap *bitmap)
|
void bdrv_dirty_bitmap_deserialize_finish(BdrvDirtyBitmap *bitmap)
|
||||||
{
|
{
|
||||||
hbitmap_deserialize_finish(bitmap->bitmap);
|
hbitmap_deserialize_finish(bitmap->bitmap);
|
||||||
|
|
|
@ -66,6 +66,9 @@ void bdrv_dirty_bitmap_deserialize_part(BdrvDirtyBitmap *bitmap,
|
||||||
void bdrv_dirty_bitmap_deserialize_zeroes(BdrvDirtyBitmap *bitmap,
|
void bdrv_dirty_bitmap_deserialize_zeroes(BdrvDirtyBitmap *bitmap,
|
||||||
uint64_t start, uint64_t count,
|
uint64_t start, uint64_t count,
|
||||||
bool finish);
|
bool finish);
|
||||||
|
void bdrv_dirty_bitmap_deserialize_ones(BdrvDirtyBitmap *bitmap,
|
||||||
|
uint64_t start, uint64_t count,
|
||||||
|
bool finish);
|
||||||
void bdrv_dirty_bitmap_deserialize_finish(BdrvDirtyBitmap *bitmap);
|
void bdrv_dirty_bitmap_deserialize_finish(BdrvDirtyBitmap *bitmap);
|
||||||
|
|
||||||
/* Functions that require manual locking. */
|
/* Functions that require manual locking. */
|
||||||
|
|
|
@ -228,6 +228,21 @@ void hbitmap_deserialize_part(HBitmap *hb, uint8_t *buf,
|
||||||
void hbitmap_deserialize_zeroes(HBitmap *hb, uint64_t start, uint64_t count,
|
void hbitmap_deserialize_zeroes(HBitmap *hb, uint64_t start, uint64_t count,
|
||||||
bool finish);
|
bool finish);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hbitmap_deserialize_ones
|
||||||
|
* @hb: HBitmap to operate on.
|
||||||
|
* @start: First bit to restore.
|
||||||
|
* @count: Number of bits to restore.
|
||||||
|
* @finish: Whether to call hbitmap_deserialize_finish automatically.
|
||||||
|
*
|
||||||
|
* Fills the bitmap with ones.
|
||||||
|
*
|
||||||
|
* If @finish is false, caller must call hbitmap_serialize_finish before using
|
||||||
|
* the bitmap.
|
||||||
|
*/
|
||||||
|
void hbitmap_deserialize_ones(HBitmap *hb, uint64_t start, uint64_t count,
|
||||||
|
bool finish);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hbitmap_deserialize_finish
|
* hbitmap_deserialize_finish
|
||||||
* @hb: HBitmap to operate on.
|
* @hb: HBitmap to operate on.
|
||||||
|
|
|
@ -551,6 +551,23 @@ void hbitmap_deserialize_zeroes(HBitmap *hb, uint64_t start, uint64_t count,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void hbitmap_deserialize_ones(HBitmap *hb, uint64_t start, uint64_t count,
|
||||||
|
bool finish)
|
||||||
|
{
|
||||||
|
uint64_t el_count;
|
||||||
|
unsigned long *first;
|
||||||
|
|
||||||
|
if (!count) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
serialization_chunk(hb, start, count, &first, &el_count);
|
||||||
|
|
||||||
|
memset(first, 0xff, el_count * sizeof(unsigned long));
|
||||||
|
if (finish) {
|
||||||
|
hbitmap_deserialize_finish(hb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void hbitmap_deserialize_finish(HBitmap *bitmap)
|
void hbitmap_deserialize_finish(HBitmap *bitmap)
|
||||||
{
|
{
|
||||||
int64_t i, size, prev_size;
|
int64_t i, size, prev_size;
|
||||||
|
|
Loading…
Reference in New Issue