diff options
author | Marcelo Tosatti <mtosatti@redhat.com> | 2010-11-08 17:02:54 -0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2010-11-21 09:16:56 -0600 |
commit | 6d59fec11eeff8a784dc4991c8fe4f8538510475 (patch) | |
tree | 90176a918177fe211c8beedea2b935bb7db79c09 | |
parent | c276b17da65b7ff01627722a1abf2b7a684c8fd8 (diff) | |
download | hqemu-6d59fec11eeff8a784dc4991c8fe4f8538510475.zip hqemu-6d59fec11eeff8a784dc4991c8fe4f8538510475.tar.gz |
block: fix shift in dirty bitmap calculation
Otherwise upper 32 bits of bitmap entries are not correctly calculated.
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r-- | block.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -930,14 +930,14 @@ static void set_dirty_bitmap(BlockDriverState *bs, int64_t sector_num, bit = start % (sizeof(unsigned long) * 8); val = bs->dirty_bitmap[idx]; if (dirty) { - if (!(val & (1 << bit))) { + if (!(val & (1UL << bit))) { bs->dirty_count++; - val |= 1 << bit; + val |= 1UL << bit; } } else { - if (val & (1 << bit)) { + if (val & (1UL << bit)) { bs->dirty_count--; - val &= ~(1 << bit); + val &= ~(1UL << bit); } } bs->dirty_bitmap[idx] = val; @@ -2685,8 +2685,8 @@ int bdrv_get_dirty(BlockDriverState *bs, int64_t sector) if (bs->dirty_bitmap && (sector << BDRV_SECTOR_BITS) < bdrv_getlength(bs)) { - return bs->dirty_bitmap[chunk / (sizeof(unsigned long) * 8)] & - (1 << (chunk % (sizeof(unsigned long) * 8))); + return !!(bs->dirty_bitmap[chunk / (sizeof(unsigned long) * 8)] & + (1UL << (chunk % (sizeof(unsigned long) * 8)))); } else { return 0; } |