[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 15/35] arch_init/ram_save_setup: factor out bitma
From: |
Isaku Yamahata |
Subject: |
[Qemu-devel] [PATCH v3 15/35] arch_init/ram_save_setup: factor out bitmap alloc/free |
Date: |
Tue, 30 Oct 2012 17:32:51 +0900 |
This will be used by postcopy.
Signed-off-by: Isaku Yamahata <address@hidden>
---
Changes v2 -> v3:
- new
---
arch_init.c | 25 ++++++++++++++++++-------
migration.h | 2 ++
2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/arch_init.c b/arch_init.c
index ad1b01b..7e6d84e 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -330,6 +330,22 @@ static unsigned long *migration_bitmap;
static uint64_t migration_dirty_pages;
static uint32_t last_version;
+void migration_bitmap_init(void)
+{
+ int64_t ram_pages = last_ram_offset() >> TARGET_PAGE_BITS;
+ if (!migration_bitmap) {
+ migration_bitmap = bitmap_new(ram_pages);
+ }
+ bitmap_set(migration_bitmap, 1, ram_pages);
+ migration_dirty_pages = ram_pages;
+}
+
+void migration_bitmap_free(void)
+{
+ g_free(migration_bitmap);
+ migration_bitmap = NULL;
+}
+
static inline bool migration_bitmap_test_and_reset_dirty(MemoryRegion *mr,
ram_addr_t offset)
{
@@ -575,11 +591,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;
-
- migration_bitmap = bitmap_new(ram_pages);
- bitmap_set(migration_bitmap, 1, ram_pages);
- migration_dirty_pages = ram_pages;
+ migration_bitmap_init();
qemu_mutex_lock_ramlist();
bytes_transferred = 0;
@@ -704,8 +716,7 @@ static int ram_save_complete(QEMUFile *f, void *opaque)
qemu_mutex_unlock_ramlist();
qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
- g_free(migration_bitmap);
- migration_bitmap = NULL;
+ migration_bitmap_free();
return 0;
}
diff --git a/migration.h b/migration.h
index 7d1b62d..73416ba 100644
--- a/migration.h
+++ b/migration.h
@@ -95,6 +95,8 @@ bool ram_save_block(QEMUFile *f, bool last_stage);
uint64_t ram_bytes_remaining(void);
uint64_t ram_bytes_transferred(void);
uint64_t ram_bytes_total(void);
+void migration_bitmap_init(void);
+void migration_bitmap_free(void);
extern SaveVMHandlers savevm_ram_handlers;
--
1.7.10.4
- [Qemu-devel] [PATCH v3 10/35] savevm/QEMUFile: add read/write QEMUFile on memory buffer, (continued)
- [Qemu-devel] [PATCH v3 10/35] savevm/QEMUFile: add read/write QEMUFile on memory buffer, Isaku Yamahata, 2012/10/30
- [Qemu-devel] [PATCH v3 12/35] arch_init: export RAM_SAVE_xxx flags for postcopy, Isaku Yamahata, 2012/10/30
- [Qemu-devel] [PATCH v3 20/35] osdep: add QEMU_MADV_REMOVE and tirivial fix, Isaku Yamahata, 2012/10/30
- [Qemu-devel] [PATCH v3 01/35] migration.c: remove redundant line in migrate_init(), Isaku Yamahata, 2012/10/30
- [Qemu-devel] [PATCH v3 14/35] arch_init: refactor ram_save_block() and export ram_save_block(), Isaku Yamahata, 2012/10/30
- [Qemu-devel] [PATCH v3 11/35] savevm, buffered_file: introduce method to drain buffer of buffered file, Isaku Yamahata, 2012/10/30
- [Qemu-devel] [PATCH v3 33/35] arch_init: export migration_bitmap_sync and helper method to get bitmap, Isaku Yamahata, 2012/10/30
- [Qemu-devel] [PATCH v3 29/35] postcopy/outgoing: add movebg mode(-m) to migration command, Isaku Yamahata, 2012/10/30
- [Qemu-devel] [PATCH v3 24/35] postcopy outgoing: add -p option to migrate command, Isaku Yamahata, 2012/10/30
- [Qemu-devel] [PATCH v3 07/35] savevm: export qemu_peek_buffer, qemu_peek_byte, qemu_file_skip, qemu_fflush, Isaku Yamahata, 2012/10/30
- [Qemu-devel] [PATCH v3 15/35] arch_init/ram_save_setup: factor out bitmap alloc/free,
Isaku Yamahata <=
- [Qemu-devel] [PATCH v3 19/35] uvmem.h: import Linux uvmem.h and teach update-linux-headers.sh, Isaku Yamahata, 2012/10/30
- [Qemu-devel] [PATCH v3 31/35] arch_init: export ram_save_iterate(), Isaku Yamahata, 2012/10/30
- [Qemu-devel] [PATCH v3 28/35] arch_init: factor out setting last_block, last_offset, Isaku Yamahata, 2012/10/30
- [Qemu-devel] [PATCH v3 17/35] arch_init: factor out logic to find ram block with id string, Isaku Yamahata, 2012/10/30
- [Qemu-devel] [PATCH v3 18/35] migration: export migrate_fd_completed() and migrate_fd_cleanup(), Isaku Yamahata, 2012/10/30
- [Qemu-devel] [PATCH v3 34/35] postcopy/outgoing: introduce precopy_count parameter, Isaku Yamahata, 2012/10/30
- [Qemu-devel] [PATCH v3 16/35] arch_init/ram_load: refactor ram_load, Isaku Yamahata, 2012/10/30
- [Qemu-devel] [PATCH v3 13/35] arch_init/ram_save: introduce constant for ram save version = 4, Isaku Yamahata, 2012/10/30
- [Qemu-devel] [PATCH v3 30/35] arch_init: factor out ram_load, Isaku Yamahata, 2012/10/30
- [Qemu-devel] [PATCH v3 22/35] savevm: add new section that is used by postcopy, Isaku Yamahata, 2012/10/30