Re: [Qemu-devel] [PATCH v2 5/9] hbitmap: Add hbitmap_copy

2014-03-20 Thread Fam Zheng
On Thu, 03/20 11:22, Paolo Bonzini wrote: > Il 12/03/2014 07:31, Fam Zheng ha scritto: > >+HBitmap *hbitmap_copy(const HBitmap *bitmap) > >+{ > >+int i; > >+HBitmap *hb = g_memdup(bitmap, sizeof(struct HBitmap)); > >+ > >+for (i = HBITMAP_LEVELS; i-- > 0; ) { > >+hb->levels[i] =

Re: [Qemu-devel] [PATCH v2 5/9] hbitmap: Add hbitmap_copy

2014-03-20 Thread Paolo Bonzini
Il 12/03/2014 07:31, Fam Zheng ha scritto: +HBitmap *hbitmap_copy(const HBitmap *bitmap) +{ +int i; +HBitmap *hb = g_memdup(bitmap, sizeof(struct HBitmap)); + +for (i = HBITMAP_LEVELS; i-- > 0; ) { +hb->levels[i] = g_memdup(bitmap->levels[i], +

Re: [Qemu-devel] [PATCH v2 5/9] hbitmap: Add hbitmap_copy

2014-03-13 Thread Paolo Bonzini
Il 13/03/2014 14:45, Benoît Canet ha scritto: This feel wrong: struct HBitmap { /* Number of total bits in the bottom level. */ uint64_t size; The comment about size imply that size apply only to the bottom level. Moreover the bitmaps are progressivelly less coarse so I think the size

Re: [Qemu-devel] [PATCH v2 5/9] hbitmap: Add hbitmap_copy

2014-03-13 Thread Benoît Canet
The Wednesday 12 Mar 2014 à 14:31:00 (+0800), Fam Zheng wrote : > This makes a deep copy of an HBitmap. > > Signed-off-by: Fam Zheng > --- > include/qemu/hbitmap.h | 8 > util/hbitmap.c | 13 + > 2 files changed, 21 insertions(+) > > diff --git a/include/qemu/hbitmap

[Qemu-devel] [PATCH v2 5/9] hbitmap: Add hbitmap_copy

2014-03-11 Thread Fam Zheng
This makes a deep copy of an HBitmap. Signed-off-by: Fam Zheng --- include/qemu/hbitmap.h | 8 util/hbitmap.c | 13 + 2 files changed, 21 insertions(+) diff --git a/include/qemu/hbitmap.h b/include/qemu/hbitmap.h index 550d7ce..b645cfc 100644 --- a/include/qemu/hbi