migration: Unify block node activation error handling
authorKevin Wolf <kwolf@redhat.com>
Thu, 4 May 2017 16:52:36 +0000 (18:52 +0200)
committerKevin Wolf <kwolf@redhat.com>
Thu, 11 May 2017 10:08:24 +0000 (12:08 +0200)
Migration code activates all block driver nodes on the destination when
the migration completes. It does so by calling
bdrv_invalidate_cache_all() and blk_resume_after_migration(). There is
one code path for precopy and one for postcopy migration, resulting in
four function calls, which used to have three different failure modes.

This patch unifies the behaviour so that failure to activate all block
nodes is non-fatal, but the error message is logged and the VM isn't
automatically started. 'cont' will retry activating the block nodes.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
migration/migration.c
migration/savevm.c
qmp.c

index 799952ce99a41ba2e13d9da30616394fc366238e..04af71988d52694cc175d3b720ef4850d7d3b8ea 100644 (file)
@@ -338,20 +338,14 @@ static void process_incoming_migration_bh(void *opaque)
     Error *local_err = NULL;
     MigrationIncomingState *mis = opaque;
 
-    /* Make sure all file formats flush their mutable metadata */
+    /* Make sure all file formats flush their mutable metadata.
+     * If we get an error here, just don't restart the VM yet. */
     bdrv_invalidate_cache_all(&local_err);
-    if (local_err) {
-        migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE,
-                          MIGRATION_STATUS_FAILED);
-        error_report_err(local_err);
-        migrate_decompress_threads_join();
-        exit(EXIT_FAILURE);
+    if (!local_err) {
+        blk_resume_after_migration(&local_err);
     }
-
-    /* If we get an error here, just don't restart the VM yet. */
-    blk_resume_after_migration(&local_err);
     if (local_err) {
-        error_free(local_err);
+        error_report_err(local_err);
         local_err = NULL;
         autostart = false;
     }
index 352a8f23b5d4f9414c789443a9a40f7711f7a71e..3ca8d11704033644fc3ffb4c4db19c061dff8364 100644 (file)
@@ -1612,16 +1612,14 @@ static void loadvm_postcopy_handle_run_bh(void *opaque)
 
     qemu_announce_self();
 
-    /* Make sure all file formats flush their mutable metadata */
+    /* Make sure all file formats flush their mutable metadata.
+     * If we get an error here, just don't restart the VM yet. */
     bdrv_invalidate_cache_all(&local_err);
-    if (local_err) {
-        error_report_err(local_err);
+    if (!local_err) {
+        blk_resume_after_migration(&local_err);
     }
-
-    /* If we get an error here, just don't restart the VM yet. */
-    blk_resume_after_migration(&local_err);
     if (local_err) {
-        error_free(local_err);
+        error_report_err(local_err);
         local_err = NULL;
         autostart = false;
     }
diff --git a/qmp.c b/qmp.c
index ab74cd729d345fc5c7f975482425f06525db9497..25b5050f9f22967f66c1daf51c46108c5797765b 100644 (file)
--- a/qmp.c
+++ b/qmp.c
@@ -196,15 +196,15 @@ void qmp_cont(Error **errp)
     }
 
     /* Continuing after completed migration. Images have been inactivated to
-     * allow the destination to take control. Need to get control back now. */
-    if (runstate_check(RUN_STATE_FINISH_MIGRATE) ||
-        runstate_check(RUN_STATE_POSTMIGRATE))
-    {
-        bdrv_invalidate_cache_all(&local_err);
-        if (local_err) {
-            error_propagate(errp, local_err);
-            return;
-        }
+     * allow the destination to take control. Need to get control back now.
+     *
+     * If there are no inactive block nodes (e.g. because the VM was just
+     * paused rather than completing a migration), bdrv_inactivate_all() simply
+     * doesn't do anything. */
+    bdrv_invalidate_cache_all(&local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
     }
 
     blk_resume_after_migration(&local_err);