Skip to contentSkip to conversation

savevm: Use QEMU_VM_SECTION_* macros in ram_save_live()

PATCH New Fernando Luis Vázquez Cao 1 participant 1 message Jun 4, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 savevm: Use QEMU_VM_SECTION_* macros in ram_save_live()

In ram_save_live() the stage is determined directly from its numerical value instead of using the corresponding macro associated with each stage. Move the QEMU_VM_SECTION_* macros to a header file so that they are available to ram_save_live() and potential future users.

---

savevm.c +0 -6
diff -urNp qemu-0.10.5-orig/savevm.c qemu-0.10.5/savevm.c
@@ -663,12 +663,6 @@ void unregister_savevm(const char *idstr
 #define QEMU_VM_FILE_VERSION_COMPAT  0x00000002
 #define QEMU_VM_FILE_VERSION         0x00000003
 
-#define QEMU_VM_EOF                  0x00
-#define QEMU_VM_SECTION_START        0x01
-#define QEMU_VM_SECTION_PART         0x02
-#define QEMU_VM_SECTION_END          0x03
-#define QEMU_VM_SECTION_FULL         0x04
-
 int qemu_savevm_state_begin(QEMUFile *f)
 {
     SaveStateEntry *se;
sysemu.h +6 -0
diff -urNp qemu-0.10.5-orig/sysemu.h qemu-0.10.5/sysemu.h
@@ -39,6 +39,12 @@ void qemu_system_powerdown(void);
 #endif
 void qemu_system_reset(void);
 
+#define QEMU_VM_EOF                  0x00
+#define QEMU_VM_SECTION_START        0x01
+#define QEMU_VM_SECTION_PART         0x02
+#define QEMU_VM_SECTION_END          0x03
+#define QEMU_VM_SECTION_FULL         0x04
+
 void do_savevm(const char *name);
 void do_loadvm(const char *name);
 void do_delvm(const char *name);
vl.c +4 -3
diff -urNp qemu-0.10.5-orig/vl.c qemu-0.10.5/vl.c
@@ -3201,7 +3201,7 @@ static int ram_save_live(QEMUFile *f, in
 {
     ram_addr_t addr;
 
-    if (stage == 1) {
+    if (stage == QEMU_VM_SECTION_START) {
         /* Make sure all dirty bits are set */
         for (addr = 0; addr < phys_ram_size; addr += TARGET_PAGE_SIZE) {
             if (!cpu_physical_memory_get_dirty(addr, MIGRATION_DIRTY_FLAG))
@@ -3224,7 +3224,7 @@ static int ram_save_live(QEMUFile *f, in
 
     /* try transferring iterative blocks of memory */
 
-    if (stage == 3) {
+    if (stage == QEMU_VM_SECTION_END) {
 
         /* flush all remaining blocks regardless of rate limiting */
         while (ram_save_block(f) != 0);
@@ -3233,7 +3233,8 @@ static int ram_save_live(QEMUFile *f, in
 
     qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
 
-    return (stage == 2) && (ram_save_remaining() < ram_save_threshold);
+    return (stage == QEMU_VM_SECTION_PART) &&
+            (ram_save_remaining() < ram_save_threshold);
 }
 
 static int ram_load_dead(QEMUFile *f, void *opaque)