From 02f3d7916ee98bdd77193833f06501c02deb47f0 Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Wed, 19 Oct 2011 23:47:51 +0200 Subject: [PATCH 16/19] migration: make *save_live return errors RH-Author: Juan Quintela Message-id: Patchwork-id: 34442 O-Subject: [PATCH qemu-kvm RHEL-6.2 16/16] migration: make *save_live return errors Bugzilla: 669581 RH-Acked-by: Amit Shah RH-Acked-by: Orit Wasserman RH-Acked-by: Markus Armbruster Make *save_live() return negative values when there is one error, and updates all callers to check for the error. Signed-off-by: Juan Quintela Conflicts: arch_init.c moved to vl.c block-migration.c code changed upstream. --- block-migration.c | 17 +++++++++++------ savevm.c | 14 +++++++++++--- vl.c | 11 +++++++---- 3 files changed, 29 insertions(+), 13 deletions(-) Signed-off-by: Michal Novotny --- block-migration.c | 17 +++++++++++------ savevm.c | 14 +++++++++++--- vl.c | 11 +++++++---- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/block-migration.c b/block-migration.c index 1628def..15e8b53 100644 --- a/block-migration.c +++ b/block-migration.c @@ -406,6 +406,8 @@ static void blk_mig_cleanup(Monitor *mon) static int block_save_live(Monitor *mon, 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); @@ -429,9 +431,10 @@ static int block_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) flush_blks(f); - if (qemu_file_get_error(f)) { + ret = qemu_file_get_error(f); + if (ret) { blk_mig_cleanup(mon); - return 0; + return ret; } /* control the rate of transfer */ @@ -446,9 +449,10 @@ static int block_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) flush_blks(f); - if (qemu_file_get_error(f)) { + ret = qemu_file_get_error(f); + if (ret) { blk_mig_cleanup(mon); - return 0; + return ret; } if (stage == 3) { @@ -462,8 +466,9 @@ static int block_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) /* report completion */ qemu_put_be64(f, (100 << BDRV_SECTOR_BITS) | BLK_MIG_FLAG_PROGRESS); - if (qemu_file_get_error(f)) { - return 0; + ret = qemu_file_get_error(f); + if (ret) { + return ret; } monitor_printf(mon, "Block migration completed\n"); diff --git a/savevm.c b/savevm.c index 4306144..c995d28 100644 --- a/savevm.c +++ b/savevm.c @@ -1519,7 +1519,11 @@ int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable, qemu_put_be32(f, se->instance_id); qemu_put_be32(f, se->version_id); - se->save_live_state(mon, f, QEMU_VM_SECTION_START, se->opaque); + ret = se->save_live_state(mon, f, QEMU_VM_SECTION_START, se->opaque); + if (ret < 0) { + qemu_savevm_state_cancel(mon, f); + return ret; + } } ret = qemu_file_get_error(f); if (ret != 0) { @@ -1557,7 +1561,7 @@ int qemu_savevm_state_iterate(Monitor *mon, QEMUFile *f) qemu_put_be32(f, se->section_id); ret = se->save_live_state(mon, f, QEMU_VM_SECTION_PART, se->opaque); - if (!ret) { + if (ret <= 0) { /* Do not proceed to the next vmstate before this one reported completion of the current stage. This serializes the migration and reduces the probability that a faster changing state is @@ -1578,6 +1582,7 @@ int qemu_savevm_state_iterate(Monitor *mon, QEMUFile *f) int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f) { SaveStateEntry *se; + int ret; QTAILQ_FOREACH(se, &savevm_handlers, entry) { if (se->save_live_state == NULL) @@ -1587,7 +1592,10 @@ int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f) qemu_put_byte(f, QEMU_VM_SECTION_END); qemu_put_be32(f, se->section_id); - se->save_live_state(mon, f, QEMU_VM_SECTION_END, se->opaque); + ret = se->save_live_state(mon, f, QEMU_VM_SECTION_END, se->opaque); + if (ret < 0) { + return ret; + } } QTAILQ_FOREACH(se, &savevm_handlers, entry) { diff --git a/vl.c b/vl.c index 3aee379..5087b7e 100644 --- a/vl.c +++ b/vl.c @@ -2929,6 +2929,7 @@ static int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) uint64_t t0; double bwidth = 0; int i; + int ret; if (stage < 0) { cpu_physical_memory_set_dirty_tracking(0); @@ -2937,7 +2938,7 @@ static int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) if (cpu_physical_sync_dirty_bitmap(0, TARGET_PHYS_ADDR_MAX) != 0) { qemu_file_set_error(f, -EINVAL); - return 0; + return -EINVAL; } if (stage == 1) { @@ -2972,9 +2973,7 @@ static int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) t0 = get_clock(); i = 0; - while (!qemu_file_rate_limit(f)) { - int ret; - + while ((ret = qemu_file_rate_limit(f)) == 0) { ret = ram_save_block(f); bytes_transferred += ret * TARGET_PAGE_SIZE; if (ret == 0) /* no more blocks */ @@ -2993,6 +2992,10 @@ static int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) i++; } + if (ret < 0) { + return ret; + } + t0 = get_clock() - t0; bwidth = (bytes_transferred - bytes_transferred_last) / t0; -- 1.7.4.4