summaryrefslogtreecommitdiff
path: root/block-migration.c
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2009-11-30 18:21:21 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2009-12-03 10:48:53 -0600
commit4ec7fcc7da214d48d39b63fd2c6a4d19ac42ae04 (patch)
tree5bb2081c5fbf6349a8241e715a0cece055105e72 /block-migration.c
parent9a743e5ba32f7a620baa0b3d3808e88d2433e861 (diff)
live migration: Allow cleanup after cancellation or error
Introduce qemu_savevm_state_cancel and inject a stage -1 to cancel a live migration. This gives the involved subsystems a chance to clean up dynamically allocated resources. Namely, the block migration layer can now free its device descriptors and pending blocks. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'block-migration.c')
-rw-r--r--block-migration.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/block-migration.c b/block-migration.c
index 5997f9bc6..5274c5ec3 100644
--- a/block-migration.c
+++ b/block-migration.c
@@ -317,11 +317,37 @@ static int is_stage2_completed(void)
return 1;
}
+static void blk_mig_cleanup(void)
+{
+ BlkMigDevState *bmds, *next_bmds;
+ BlkMigBlock *blk, *next_blk;
+
+ QTAILQ_FOREACH_SAFE(bmds, &block_mig_state.dev_list, entry, next_bmds) {
+ QTAILQ_REMOVE(&block_mig_state.dev_list, bmds, entry);
+ qemu_free(bmds);
+ }
+
+ QTAILQ_FOREACH_SAFE(blk, &block_mig_state.blk_list, entry, next_blk) {
+ QTAILQ_REMOVE(&block_mig_state.blk_list, blk, entry);
+ qemu_free(blk->buf);
+ qemu_free(blk);
+ }
+
+ set_dirty_tracking(0);
+
+ printf("\n");
+}
+
static int block_save_live(QEMUFile *f, int stage, void *opaque)
{
dprintf("Enter save live stage %d submitted %d transferred %d\n",
stage, block_mig_state.submitted, block_mig_state.transferred);
+ if (stage < 0) {
+ blk_mig_cleanup();
+ return 0;
+ }
+
if (block_mig_state.blk_enable != 1) {
/* no need to migrate storage */
qemu_put_be64(f, BLK_MIG_FLAG_EOS);
@@ -338,7 +364,7 @@ static int block_save_live(QEMUFile *f, int stage, void *opaque)
flush_blks(f);
if (qemu_file_has_error(f)) {
- set_dirty_tracking(0);
+ blk_mig_cleanup();
return 0;
}
@@ -355,7 +381,7 @@ static int block_save_live(QEMUFile *f, int stage, void *opaque)
flush_blks(f);
if (qemu_file_has_error(f)) {
- set_dirty_tracking(0);
+ blk_mig_cleanup();
return 0;
}
@@ -365,15 +391,13 @@ static int block_save_live(QEMUFile *f, int stage, void *opaque)
}
blk_mig_save_dirty_blocks(f);
-
- /* stop track dirty blocks */
- set_dirty_tracking(0);
+ blk_mig_cleanup();
if (qemu_file_has_error(f)) {
return 0;
}
- printf("\nBlock migration completed\n");
+ printf("Block migration completed\n");
}
qemu_put_be64(f, BLK_MIG_FLAG_EOS);