Skip to contentSkip to conversation

v1] Keeping the Destination side alive incase of network failure (Migration recover from network failure)

RFC In review Md Haris Iqbal 2 participants 2 messages May 31, 2016 – Jun 1, 2016

lore
Share & tools
lore
#0 lore raw

RFC 1/1 v1] Keeping the Destination side alive incase of network failure (Migration recover from network failure)

---
 include/migration/migration.h |  3 +++
 migration/migration.c         | 12 ++++++++++++
 migration/savevm.c            | 25 +++++++++++++++++--------
 3 files changed, 32 insertions(+), 8 deletions(-)
include/migration/migration.h +3 -0
index ac2c12c..73832ac 100644
@@ -326,6 +326,9 @@ void flush_page_queue(MigrationState *ms);
 int ram_save_queue_pages(MigrationState *ms, const char *rbname,
                          ram_addr_t start, ram_addr_t len);
 
+// New added function for postcopy migration recovery in case of failure
+void qemu_postcopy_migration_recovery(QEMUFile **f,MigrationIncomingState* mis);
+
 PostcopyState postcopy_state_get(void);
 /* Set the state and return the old state */
 PostcopyState postcopy_state_set(PostcopyState new_state);
migration/migration.c +12 -0
index 991313a..4301972 100644
@@ -1797,6 +1797,18 @@ void migrate_fd_connect(MigrationState *s)
     s->migration_thread_running = true;
 }
 
+void qemu_postcopy_migration_recovery(QEMUFile **f,
+                                      MigrationIncomingState* mis)
+{
+    migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE,
+                                   MIGRATION_STATUS_POSTCOPY_RECOVERING);
+    /* 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);
migration/savevm.c +17 -8
index 16ba443..03467da 100644
@@ -1832,7 +1832,8 @@ qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis)
 static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis)
 {
     uint8_t section_type;
-    int ret;
+    PostcopyState ps;
+    int32_t ret;
 
     while ((section_type = qemu_get_byte(f)) != QEMU_VM_EOF) {
 
@@ -1841,21 +1842,16 @@ static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis)
         case QEMU_VM_SECTION_START:
         case QEMU_VM_SECTION_FULL:
             ret = qemu_loadvm_section_start_full(f, mis);
-            if (ret < 0) {
-                return ret;
-            }
             break;
         case QEMU_VM_SECTION_PART:
         case QEMU_VM_SECTION_END:
             ret = qemu_loadvm_section_part_end(f, mis);
-            if (ret < 0) {
-                return ret;
-            }
             break;
         case QEMU_VM_COMMAND:
             ret = loadvm_process_command(f);
             trace_qemu_loadvm_state_section_command(ret);
-            if ((ret < 0) || (ret & LOADVM_QUIT)) {
+            if (ret & LOADVM_QUIT) {
+                fprintf(stderr, "LOADVM_QUIT\n");
                 return ret;
             }
             break;
@@ -1863,6 +1859,19 @@ static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis)
             error_report("Unknown savevm section type %d", section_type);
             return -EINVAL;
         }
+
+        if (ret < 0) {
+            fprintf(stderr,  "Failure\n");
+
+            ps = postcopy_state_get();
+            ret = qemu_file_get_error(f);
+            fprintf(stderr, "Error %s %d\n", strerror(-ret), -ret);
+
+            if(ret != -EIO && ps == POSTCOPY_INCOMING_RUNNING)
+                qemu_postcopy_migration_recovery(&f, mis);
+            else
+                return ret;
+        }
     }
 
     return 0;
Signature · 1 line
2.7.4
#1 lore raw
Quoted 11 lines · * Md Haris Iqbal ([email protected]) wrote:
---
 include/migration/migration.h |  3 +++
 migration/migration.c         | 12 ++++++++++++
 migration/savevm.c            | 25 +++++++++++++++++--------
 3 files changed, 32 insertions(+), 8 deletions(-)
include/migration/migration.h +0 -0
index ac2c12c..73832ac 100644

include/migration/migration.h void flush_page_queue(MigrationState *ms); · line 329

Quoted 4 lines
include/migration/migration.h +1 -0
@@ -326,6 +326,9 @@ void flush_page_queue(MigrationState *ms);
 int ram_save_queue_pages(MigrationState *ms, const char *rbname,
                          ram_addr_t start, ram_addr_t len);
 
+// New added function for postcopy migration recovery in case of failure

Note the comment style is always /* not //

Quoted 33 lines
include/migration/migration.h +2 -0
+void qemu_postcopy_migration_recovery(QEMUFile **f,MigrationIncomingState* mis);
+
 PostcopyState postcopy_state_get(void);
 /* Set the state and return the old state */
 PostcopyState postcopy_state_set(PostcopyState new_state);
migration/migration.c +12 -0
index 991313a..4301972 100644
@@ -1797,6 +1797,18 @@ void migrate_fd_connect(MigrationState *s)
     s->migration_thread_running = true;
 }
 
+void qemu_postcopy_migration_recovery(QEMUFile **f,
+                                      MigrationIncomingState* mis)
+{
+    migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE,
+                                   MIGRATION_STATUS_POSTCOPY_RECOVERING);
+    /* 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);
migration/savevm.c +0 -0
index 16ba443..03467da 100644

migration/savevm.c qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis) · line 1836

Quoted 6 lines
migration/savevm.c +2 -1
@@ -1832,7 +1832,8 @@ qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis)
 static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis)
 {
     uint8_t section_type;
-    int ret;
+    PostcopyState ps;
+    int32_t ret;

Again match up the 'ret' type.

Quoted 30 lines
migration/savevm.c +2 -7
     while ((section_type = qemu_get_byte(f)) != QEMU_VM_EOF) {
 
@@ -1841,21 +1842,16 @@ static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis)
         case QEMU_VM_SECTION_START:
         case QEMU_VM_SECTION_FULL:
             ret = qemu_loadvm_section_start_full(f, mis);
-            if (ret < 0) {
-                return ret;
-            }
             break;
         case QEMU_VM_SECTION_PART:
         case QEMU_VM_SECTION_END:
             ret = qemu_loadvm_section_part_end(f, mis);
-            if (ret < 0) {
-                return ret;
-            }
             break;
         case QEMU_VM_COMMAND:
             ret = loadvm_process_command(f);
             trace_qemu_loadvm_state_section_command(ret);
-            if ((ret < 0) || (ret & LOADVM_QUIT)) {
+            if (ret & LOADVM_QUIT) {
+                fprintf(stderr, "LOADVM_QUIT\n");
                 return ret;
             }
             break;
@@ -1863,6 +1859,19 @@ static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis)
             error_report("Unknown savevm section type %d", section_type);
             return -EINVAL;
         }

migration/savevm.c static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis) · line 1871

Quoted 10 lines
migration/savevm.c +10 -0
+
+        if (ret < 0) {
+            fprintf(stderr,  "Failure\n");
+
+            ps = postcopy_state_get();
+            ret = qemu_file_get_error(f);
+            fprintf(stderr, "Error %s %d\n", strerror(-ret), -ret);
+
+            if(ret != -EIO && ps == POSTCOPY_INCOMING_RUNNING)
+                qemu_postcopy_migration_recovery(&f, mis);

Qemu's if style always puts {'s in even for one line if.

ps == POSTCOPY_INCOMING_RUNNING is a reasonable test; I wonder if we should also combine it with the run-state; if the destination was started with -S and got to RUNNING but libvirt hadn't actually told it to run yet, then I think it's still safe to fail to migration right up to the point the destination is started running.

Dave

Quoted 9 lines
migration/savevm.c +3 -0
+            else
+                return ret;
+        }
     }
 
     return 0;
Signature · 1 line
2.7.4

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK