All of lore.kernel.org
 help / color / mirror / Atom feed
From: Md Haris Iqbal <haris.phnx@gmail.com>
To: qemu-devel@nongnu.org
Cc: dgilbert@redhat.com, Md Haris Iqbal <haris.phnx@gmail.com>
Subject: [Qemu-devel] [Qemu-devel [RFC] [WIP] v1] Keeping the Source side alive incase of network failure (Migration recover from network failure)
Date: Wed,  1 Jun 2016 00:41:06 +0530	[thread overview]
Message-ID: <1464721866-28275-1-git-send-email-haris.phnx@gmail.com> (raw)

---
 include/migration/migration.h |  1 +
 migration/migration.c         | 41 ++++++++++++++++++++++++++++++++++++-----
 vl.c                          |  4 ++++
 3 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/include/migration/migration.h b/include/migration/migration.h
index ac2c12c..33da695 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -325,6 +325,7 @@ void global_state_store_running(void);
 void flush_page_queue(MigrationState *ms);
 int ram_save_queue_pages(MigrationState *ms, const char *rbname,
                          ram_addr_t start, ram_addr_t len);
+int qemu_migrate_postcopy_outgoing_recovery(MigrationState *ms);
 
 PostcopyState postcopy_state_get(void);
 /* Set the state and return the old state */
diff --git a/migration/migration.c b/migration/migration.c
index 991313a..ee0c2a8 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -539,6 +539,7 @@ static bool migration_is_setup_or_active(int state)
     case MIGRATION_STATUS_ACTIVE:
     case MIGRATION_STATUS_POSTCOPY_ACTIVE:
     case MIGRATION_STATUS_SETUP:
+    case MIGRATION_STATUS_POSTCOPY_RECOVERY:
         return true;
 
     default:
@@ -1634,6 +1635,8 @@ static void *migration_thread(void *opaque)
     /* The active state we expect to be in; ACTIVE or POSTCOPY_ACTIVE */
     enum MigrationStatus current_active_state = MIGRATION_STATUS_ACTIVE;
 
+    int32_t ret;
+
     rcu_register_thread();
 
     qemu_savevm_state_header(s->to_dst_file);
@@ -1700,11 +1703,26 @@ static void *migration_thread(void *opaque)
             }
         }
 
-        if (qemu_file_get_error(s->to_dst_file)) {
-            migrate_set_state(&s->state, current_active_state,
-                              MIGRATION_STATUS_FAILED);
-            trace_migration_thread_file_err();
-            break;
+        if ((ret = qemu_file_get_error(s->to_dst_file))) {
+            fprintf(stderr, "1 : Error %s %d\n", strerror(-ret), -ret);
+            if(ret != -EIO && s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE) {
+                /* Network Failure during postcopy */
+
+                current_active_state = MIGRATION_STATUS_POSTCOPY_RECOVERY;
+                runstate_set(RUN_STATE_POSTMIGRATE_RECOVERY);
+                fprintf(stderr, "1.1 : Error %s %d\n", strerror(-ret), -ret);
+                ret = qemu_migrate_postcopy_outgoing_recovery(s);
+                if(ret < 0) {
+                    break;
+                }
+
+            } else {
+                migrate_set_state(&s->state, current_active_state,
+                                             MIGRATION_STATUS_FAILED);
+                fprintf(stderr, "1.2 : Error %s %d\n", strerror(-ret), -ret);
+                trace_migration_thread_file_err();
+                break;
+            }
         }
         current_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
         if (current_time >= initial_time + BUFFER_DELAY) {
@@ -1797,6 +1815,19 @@ void migrate_fd_connect(MigrationState *s)
     s->migration_thread_running = true;
 }
 
+int qemu_migrate_postcopy_outgoing_recovery(MigrationState* ms)
+{
+    migrate_set_state(&ms->state, MIGRATION_STATUS_POSTCOPY_ACTIVE,
+                                  MIGRATION_STATUS_POSTCOPY_RECOVERY);
+
+    /* Code for network recovery to be added here */
+    while(1) {
+        fprintf(stderr, "Not letting it fail\n");
+        sleep(2);
+    }
+
+}
+
 PostcopyState  postcopy_state_get(void)
 {
     return atomic_mb_read(&incoming_postcopy_state);
diff --git a/vl.c b/vl.c
index 5fd22cb..c237140 100644
--- a/vl.c
+++ b/vl.c
@@ -618,6 +618,10 @@ static const RunStateTransition runstate_transitions_def[] = {
     { RUN_STATE_FINISH_MIGRATE, RUN_STATE_RUNNING },
     { RUN_STATE_FINISH_MIGRATE, RUN_STATE_POSTMIGRATE },
     { RUN_STATE_FINISH_MIGRATE, RUN_STATE_PRELAUNCH },
+    { RUN_STATE_FINISH_MIGRATE, RUN_STATE_POSTMIGRATE_RECOVERY },
+
+    { RUN_STATE_POSTMIGRATE_RECOVERY, RUN_STATE_FINISH_MIGRATE },
+    { RUN_STATE_POSTMIGRATE_RECOVERY, RUN_STATE_SHUTDOWN },
 
     { RUN_STATE_RESTORE_VM, RUN_STATE_RUNNING },
     { RUN_STATE_RESTORE_VM, RUN_STATE_PRELAUNCH },
-- 
2.7.4

             reply	other threads:[~2016-05-31 19:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-31 19:11 Md Haris Iqbal [this message]
2016-06-01 16:15 ` [Qemu-devel] [Qemu-devel [RFC] [WIP] v1] Keeping the Source side alive incase of network failure (Migration recover from network failure) Dr. David Alan Gilbert
2016-06-02  8:57   ` haris iqbal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1464721866-28275-1-git-send-email-haris.phnx@gmail.com \
    --to=haris.phnx@gmail.com \
    --cc=dgilbert@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.