Blame SOURCES/kvm-migration-Fail-migration-on-bdrv_flush_all-error.patch

0a122b
From 0262e36cb9326586a82985b1c26ee8cf9c6e0578 Mon Sep 17 00:00:00 2001
0a122b
Message-Id: <0262e36cb9326586a82985b1c26ee8cf9c6e0578.1387382496.git.minovotn@redhat.com>
0a122b
In-Reply-To: <c5386144fbf09f628148101bc674e2421cdd16e3.1387382496.git.minovotn@redhat.com>
0a122b
References: <c5386144fbf09f628148101bc674e2421cdd16e3.1387382496.git.minovotn@redhat.com>
0a122b
From: Nigel Croxon <ncroxon@redhat.com>
0a122b
Date: Thu, 14 Nov 2013 22:52:39 +0100
0a122b
Subject: [PATCH 03/46] migration: Fail migration on bdrv_flush_all() error
0a122b
0a122b
RH-Author: Nigel Croxon <ncroxon@redhat.com>
0a122b
Message-id: <1384469598-13137-4-git-send-email-ncroxon@redhat.com>
0a122b
Patchwork-id: 55687
0a122b
O-Subject: [RHEL7.0 PATCH 03/42] migration: Fail migration on bdrv_flush_all() error
0a122b
Bugzilla: 1011720
0a122b
RH-Acked-by: Orit Wasserman <owasserm@redhat.com>
0a122b
RH-Acked-by: Amit Shah <amit.shah@redhat.com>
0a122b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
0a122b
0a122b
Bugzilla: 1011720
0a122b
https://bugzilla.redhat.com/show_bug.cgi?id=1011720
0a122b
0a122b
>From commit ID:
0a122b
commit 0e1146a7a011a69d8cbc958b4f7ebad186730fc3
0a122b
Author: Kevin Wolf <kwolf@redhat.com>
0a122b
Date:   Fri Jul 5 13:54:55 2013 +0200
0a122b
0a122b
    migration: Fail migration on bdrv_flush_all() error
0a122b
0a122b
    If bdrv_flush_all() returns an error, there is an inconsistency in the
0a122b
    view of an image file between the source and the destination host.
0a122b
    Completing the migration would lead to corruption. Better abort
0a122b
    migration in this case.
0a122b
0a122b
    To reproduce this case, try the following (ensures that there is
0a122b
    something to flush, and then fails that flush):
0a122b
0a122b
    $ qemu-img create -f qcow2 test.qcow2 1G
0a122b
    $ cat blkdebug.cfg
0a122b
    [inject-error]
0a122b
    event = "flush_to_os"
0a122b
    errno = "5"
0a122b
    $ qemu-system-x86_64 -hda blkdebug:blkdebug.cfg:test.qcow2 -monitor stdio
0a122b
    (qemu) qemu-io ide0-hd0 "write 0 4k"
0a122b
    (qemu) migrate ...
0a122b
0a122b
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
0a122b
    Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
---
0a122b
 migration.c |   17 ++++++++++++++---
0a122b
 1 files changed, 14 insertions(+), 3 deletions(-)
0a122b
0a122b
Signed-off-by: Michal Novotny <minovotn@redhat.com>
0a122b
---
0a122b
 migration.c | 17 ++++++++++++++---
0a122b
 1 file changed, 14 insertions(+), 3 deletions(-)
0a122b
0a122b
diff --git a/migration.c b/migration.c
0a122b
index d91e702..3520776 100644
0a122b
--- a/migration.c
0a122b
+++ b/migration.c
0a122b
@@ -542,15 +542,26 @@ static void *migration_thread(void *opaque)
0a122b
             if (pending_size && pending_size >= max_size) {
0a122b
                 qemu_savevm_state_iterate(s->file);
0a122b
             } else {
0a122b
+                int ret;
0a122b
+
0a122b
                 DPRINTF("done iterating\n");
0a122b
                 qemu_mutex_lock_iothread();
0a122b
                 start_time = qemu_get_clock_ms(rt_clock);
0a122b
                 qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
0a122b
                 old_vm_running = runstate_is_running();
0a122b
-                vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
0a122b
-                qemu_file_set_rate_limit(s->file, INT_MAX);
0a122b
-                qemu_savevm_state_complete(s->file);
0a122b
+
0a122b
+                ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
0a122b
+                if (ret >= 0) {
0a122b
+                    qemu_file_set_rate_limit(s->file, INT_MAX);
0a122b
+                    qemu_savevm_state_complete(s->file);
0a122b
+                }
0a122b
                 qemu_mutex_unlock_iothread();
0a122b
+
0a122b
+                if (ret < 0) {
0a122b
+                    migrate_finish_set_state(s, MIG_STATE_ERROR);
0a122b
+                    break;
0a122b
+                }
0a122b
+
0a122b
                 if (!qemu_file_get_error(s->file)) {
0a122b
                     migrate_finish_set_state(s, MIG_STATE_COMPLETED);
0a122b
                     break;
0a122b
-- 
0a122b
1.7.11.7
0a122b