qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH COLO-Frame v6 28/31] COLO NIC: Implement NIC checkpo


From: zhanghailiang
Subject: [Qemu-devel] [PATCH COLO-Frame v6 28/31] COLO NIC: Implement NIC checkpoint and failover
Date: Thu, 18 Jun 2015 16:58:52 +0800

Signed-off-by: zhanghailiang <address@hidden>
Signed-off-by: Li Zhijian <address@hidden>
---
 include/net/colo-nic.h |  2 ++
 migration/colo.c       | 21 ++++++++++++++++++---
 net/colo-nic.c         | 23 +++++++++++++++++++++++
 3 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/include/net/colo-nic.h b/include/net/colo-nic.h
index 17f8800..252b3ae 100644
--- a/include/net/colo-nic.h
+++ b/include/net/colo-nic.h
@@ -28,5 +28,7 @@ int colo_proxy_init(enum COLOMode mode);
 void colo_proxy_destroy(enum COLOMode mode);
 
 int colo_proxy_compare(void);
+int colo_proxy_failover(void);
+int colo_proxy_checkpoint(enum COLOMode mode);
 
 #endif
diff --git a/migration/colo.c b/migration/colo.c
index f446827..0fcadcd 100644
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -120,6 +120,11 @@ static void secondary_vm_do_failover(void)
         ;
     }
 
+    if (colo_proxy_failover() != 0) {
+        error_report("colo proxy failed to do failover");
+    }
+    colo_proxy_destroy(COLO_MODE_SECONDARY);
+
     colo = NULL;
 
     if (!autostart) {
@@ -142,6 +147,8 @@ static void primary_vm_do_failover(void)
         vm_stop_force_state(RUN_STATE_COLO);
     }
 
+    colo_proxy_destroy(COLO_MODE_PRIMARY);
+
     if (s->state != MIGRATION_STATUS_FAILED) {
         migrate_set_state(s, MIGRATION_STATUS_COLO, 
MIGRATION_STATUS_COMPLETED);
     }
@@ -265,6 +272,11 @@ static int colo_do_checkpoint_transaction(MigrationState 
*s, QEMUFile *control)
 
     qemu_fflush(trans);
 
+    ret = colo_proxy_checkpoint(COLO_MODE_PRIMARY);
+    if (ret < 0) {
+        goto out;
+    }
+
     ret = colo_ctl_put(s->file, COLO_CHECKPOINT_SEND);
     if (ret < 0) {
         goto out;
@@ -424,8 +436,6 @@ out:
     qemu_bh_schedule(s->cleanup_bh);
     qemu_mutex_unlock_iothread();
 
-    colo_proxy_destroy(COLO_MODE_PRIMARY);
-
     return NULL;
 }
 
@@ -551,6 +561,11 @@ void *colo_process_incoming_checkpoints(void *opaque)
             goto out;
         }
 
+        ret = colo_proxy_checkpoint(COLO_MODE_SECONDARY);
+        if (ret < 0) {
+            goto out;
+        }
+
         ret = colo_ctl_get(f, COLO_CHECKPOINT_SEND);
         if (ret < 0) {
             goto out;
@@ -634,6 +649,7 @@ out:
         * just kill Secondary VM
         */
         error_report("SVM is going to exit in default!");
+        colo_proxy_destroy(COLO_MODE_SECONDARY);
         exit(1);
     } else {
         /* if we went here, means Primary VM may dead, we are doing failover */
@@ -658,6 +674,5 @@ out:
 
     loadvm_exit_colo();
 
-    colo_proxy_destroy(COLO_MODE_SECONDARY);
     return NULL;
 }
diff --git a/net/colo-nic.c b/net/colo-nic.c
index e395c13..4ddc9dc 100644
--- a/net/colo-nic.c
+++ b/net/colo-nic.c
@@ -373,6 +373,29 @@ void colo_proxy_destroy(enum COLOMode mode)
     teardown_nic(mode, getpid());
 }
 
+/*
+* Note: Weird, Only the VM in slave side need to do failover work !!!
+*/
+int colo_proxy_failover(void)
+{
+    if (colo_proxy_send(NFCOLO_DO_FAILOVER, COLO_MODE_SECONDARY, 0, NULL) < 0) 
{
+        return -1;
+    }
+
+    return 0;
+}
+
+/*
+* Note: Only the VM in master side need to do checkpoint
+*/
+int colo_proxy_checkpoint(enum COLOMode  mode)
+{
+    if (colo_proxy_send(NFCOLO_DO_CHECKPOINT, mode, 0, NULL) < 0) {
+        return -1;
+    }
+    return 0;
+}
+
 int colo_proxy_compare(void)
 {
     return atomic_xchg(&packet_compare_different, 0);
-- 
1.7.12.4





reply via email to

[Prev in Thread] Current Thread [Next in Thread]