savevm: Use QEMU_VM_SECTION_* macros in ram_save_live()
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.
Signed-off-by Fernando Luis Vazquez Cao <[email protected]>
---
savevm.c +0 -6
@@ -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
@@ -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
@@ -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, inqemu_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)