diff mbox

[v2,12/41] arch_init: factor out setting last_block, last_offset

Message ID 4025eae9bf1060ff5e8e6de24c7d31ed3d523c7f.1338802192.git.yamahata@valinux.co.jp
State New
Headers show

Commit Message

Isaku Yamahata June 4, 2012, 9:57 a.m. UTC
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
 arch_init.c |   13 ++++++++-----
 arch_init.h |    1 +
 2 files changed, 9 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/arch_init.c b/arch_init.c
index 2617478..22d9691 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -203,6 +203,12 @@  int ram_save_page(QEMUFile *f, RAMBlock *block, ram_addr_t offset)
 static RAMBlock *last_block;
 static ram_addr_t last_offset;
 
+void ram_save_set_last_block(RAMBlock *block, ram_addr_t offset)
+{
+    last_block = block;
+    last_offset = offset;
+}
+
 int ram_save_block(QEMUFile *f)
 {
     RAMBlock *block = last_block;
@@ -230,9 +236,7 @@  int ram_save_block(QEMUFile *f)
         }
     } while (block != last_block || offset != last_offset);
 
-    last_block = block;
-    last_offset = offset;
-
+    ram_save_set_last_block(block, offset);
     return bytes_sent;
 }
 
@@ -349,8 +353,7 @@  int ram_save_live(QEMUFile *f, int stage, void *opaque)
     if (stage == 1) {
         bytes_transferred = 0;
         last_block_sent = NULL;
-        last_block = NULL;
-        last_offset = 0;
+        ram_save_set_last_block(NULL, 0);
         sort_ram_list();
 
         /* Make sure all dirty bits are set */
diff --git a/arch_init.h b/arch_init.h
index 7f5c77a..15548cd 100644
--- a/arch_init.h
+++ b/arch_init.h
@@ -40,6 +40,7 @@  int xen_available(void);
 #define RAM_SAVE_VERSION_ID     4 /* currently version 4 */
 
 #if defined(NEED_CPU_H) && !defined(CONFIG_USER_ONLY)
+void ram_save_set_last_block(RAMBlock *block, ram_addr_t offset);
 int ram_save_page(QEMUFile *f, RAMBlock *block, ram_addr_t offset);
 RAMBlock *ram_find_block(const char *id, uint8_t len);
 void *ram_load_host_from_stream_offset(QEMUFile *f,