Fix calculation of number of bits in the migration bitmap
PATCH 1/1 Fix calculation of number of bits in the migration bitmap
The number of bits is off by one, for example if last_ram_offset is 0x1000 (the guest has one page) we get 0 bits instead of 1.
--- arch_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch_init.c +1 -1
@@ -565,7 +565,7 @@ static void reset_ram_globals(void)static int ram_save_setup (QEMUFile *f,void *opaque) {RAMBlock *block; -int64_t ram_pages =last_ram_offset () >>TARGET_PAGE_BITS ; +int64_t ram_pages = (last_ram_offset () >>TARGET_PAGE_BITS ) +1 ; migration_bitmap =bitmap_new (ram_pages);bitmap_set (migration_bitmap,0 , ram_pages);
Signature · 1 line
1.7.11.7
Quoted 13 lines · Orit Wasserman
The number of bits is off by one, for example if
last_ram_offsetis0x1000(the guest has one page) we get 0 bits instead of 1.Signed-off-by Orit Wasserman <[email protected]>--- arch_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch_init.c +0
-0
arch_init.c static void reset_ram_globals(void) · line 569
Quoted 6 lines
arch_init.c +1
-1@@ -565,7 +565,7 @@ static void reset_ram_globals(void)static int ram_save_setup (QEMUFile *f,void *opaque) {RAMBlock *block; -int64_t ram_pages =last_ram_offset () >>TARGET_PAGE_BITS ; +int64_t ram_pages = (last_ram_offset () >>TARGET_PAGE_BITS ) +1 ;
The original code calculates 1 for your example case.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 9 lines · Avi Kivity
Quoted 8 lines · Orit Wasserman
The number of bits is off by one, for example if
last_ram_offsetis0x1000(the guest has one page) we get 0 bits instead of 1.Signed-off-by Orit Wasserman <[email protected]>--- arch_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines
arch_init.c static void reset_ram_globals(void) · line 569
Quoted 11 lines
arch_init.c +1
-1@@ -565,7 +565,7 @@ static void reset_ram_globals(void)static int ram_save_setup (QEMUFile *f,void *opaque) {RAMBlock *block; -int64_t ram_pages =last_ram_offset () >>TARGET_PAGE_BITS ; +int64_t ram_pages = (last_ram_offset () >>TARGET_PAGE_BITS ) +1 ;The original code calculates 1 for your example case.
You correct ...
sorry ...
Quoted 2 lines
Quoted 13 lines · Orit Wasserman
The number of bits is off by one, for example if
last_ram_offsetis0x1000(the guest has one page) we get 0 bits instead of 1.Signed-off-by Orit Wasserman <[email protected]>--- arch_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch_init.c +0
-0
arch_init.c static void reset_ram_globals(void) · line 568
Quoted 5 lines
arch_init.c +1
-1@@ -565,7 +565,7 @@ static void reset_ram_globals(void)static int ram_save_setup (QEMUFile *f,void *opaque) {RAMBlock *block; -int64_t ram_pages =last_ram_offset () >>TARGET_PAGE_BITS ; +int64_t ram_pages = (last_ram_offset () >>TARGET_PAGE_BITS ) +1 ;
This will give you an extra bit if the last_ram_offset()
is an exact multiple of the page size, though. Try
int64_t ram_pages = DIV_ROUND_UP(last_ram_offset(), TARGET_PAGE_SIZE);
?
-- PMM
Quoted 9 lines · Peter Maydell
Quoted 8 lines · Orit Wasserman
The number of bits is off by one, for example if
last_ram_offsetis0x1000(the guest has one page) we get 0 bits instead of 1.Signed-off-by Orit Wasserman <[email protected]>--- arch_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines
arch_init.c static void reset_ram_globals(void) · line 568
Quoted 10 lines
arch_init.c +1
-1@@ -565,7 +565,7 @@ static void reset_ram_globals(void)static int ram_save_setup (QEMUFile *f,void *opaque) {RAMBlock *block; -int64_t ram_pages =last_ram_offset () >>TARGET_PAGE_BITS ; +int64_t ram_pages = (last_ram_offset () >>TARGET_PAGE_BITS ) +1 ;This will give you an extra bit if the
last_ram_offset()
is an exact multiple of the page size, though. Try
int64_tram_pages=DIV_ROUND_UP(last_ram_offset(), TARGET_PAGE_SIZE);
Good idea ...
Quoted 4 lines
?
-- PMM