From d1315aac6e4df1f472a6f87ef6e310b8c109f498 Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Thu, 28 Jun 2012 15:11:57 +0200 Subject: savevm: split save_live_setup from save_live_state This patch splits stage 1 to its own function for both save_live users, ram and block. It is just a copy of the function, removing the parts of the other stages. Optimizations would came later. Signed-off-by: Juan Quintela --- block-migration.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) (limited to 'block-migration.c') diff --git a/block-migration.c b/block-migration.c index 6d37dc1..fc3d1f4 100644 --- a/block-migration.c +++ b/block-migration.c @@ -541,20 +541,40 @@ static void block_migration_cancel(void *opaque) blk_mig_cleanup(); } -static int block_save_live(QEMUFile *f, int stage, void *opaque) +static int block_save_setup(QEMUFile *f, void *opaque) { int ret; - DPRINTF("Enter save live stage %d submitted %d transferred %d\n", - stage, block_mig_state.submitted, block_mig_state.transferred); + DPRINTF("Enter save live setup submitted %d transferred %d\n", + block_mig_state.submitted, block_mig_state.transferred); - if (stage == 1) { - init_blk_migration(f); + init_blk_migration(f); + + /* start track dirty blocks */ + set_dirty_tracking(1); + + flush_blks(f); - /* start track dirty blocks */ - set_dirty_tracking(1); + ret = qemu_file_get_error(f); + if (ret) { + blk_mig_cleanup(); + return ret; } + blk_mig_reset_dirty_cursor(); + + qemu_put_be64(f, BLK_MIG_FLAG_EOS); + + return 0; +} + +static int block_save_live(QEMUFile *f, int stage, void *opaque) +{ + int ret; + + DPRINTF("Enter save live stage %d submitted %d transferred %d\n", + stage, block_mig_state.submitted, block_mig_state.transferred); + flush_blks(f); ret = qemu_file_get_error(f); @@ -710,6 +730,7 @@ static bool block_is_active(void *opaque) SaveVMHandlers savevm_block_handlers = { .set_params = block_set_params, + .save_live_setup = block_save_setup, .save_live_state = block_save_live, .load_state = block_load, .cancel = block_migration_cancel, -- cgit v1.1