Skip to contentSkip to conversation

Migration/colo.c: Fix upstream bugs when occur failover

PATCH Superseded Zhang Chen 2 participants 10 messages Feb 26, 2019 – Feb 28, 2019

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Zhang Chen

author
#0 lore raw

cover Migration/colo.c: Fix upstream bugs when occur failover

From: Zhang Chen <[email protected]>

Fix three bugs after COLO failover.

Zhang Chen (3):
Migration/colo.c: Fix double close bug when occur COLO failover Migration/colo.c: Fix COLO failover status error Migration/colo.c: Make COLO node running after failover

 migration/colo.c      | 9 +++++----
 migration/migration.c | 3 +++
 2 files changed, 8 insertions(+), 4 deletions(-)
Signature · 1 line
2.17.GIT
author
#1 lore raw

PATCH 1/3 Migration/colo.c: Fix double close bug when occur COLO failover

From: Zhang Chen <[email protected]>

In migration_incoming_state_destroy(void) will check the mis->to_src_file to double close the mis->to_src_file when occur COLO failover.

---
 migration/colo.c | 1 +
 1 file changed, 1 insertion(+)
migration/colo.c +1 -0
index 398b239d1c..a916dc178c 100644
@@ -872,6 +872,7 @@ out:
     /* Must be called after failover BH is completed */
     if (mis->to_src_file) {
         qemu_fclose(mis->to_src_file);
+        mis->to_src_file = NULL;
     }
     migration_incoming_disable_colo();
 
Signature · 1 line
2.17.GIT
Reviewed-by on v1 1/3
#2 lore raw

Re: [Qemu-devel] [PATCH 1/3] Migration/colo.c: Fix double close bug when occur COLO failover

Quoted 6 lines · * Zhang Chen ([email protected]) wrote:

From: Zhang Chen <[email protected]>

In migration_incoming_state_destroy(void) will check the mis->to_src_file to double close the mis->to_src_file when occur COLO failover.

Quoted 19 lines
---
 migration/colo.c | 1 +
 1 file changed, 1 insertion(+)
migration/colo.c +1 -0
index 398b239d1c..a916dc178c 100644
@@ -872,6 +872,7 @@ out:
     /* Must be called after failover BH is completed */
     if (mis->to_src_file) {
         qemu_fclose(mis->to_src_file);
+        mis->to_src_file = NULL;
     }
     migration_incoming_disable_colo();
 
Signature · 1 line
2.17.GIT

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

author
#3 lore raw

PATCH 2/3 Migration/colo.c: Fix COLO failover status error

In reply to Zhang Chen

From: Zhang Chen <[email protected]>

When finished COLO failover, the status is FAILOVER_STATUS_COMPLETED. The origin codes misunderstand the FAILOVER_STATUS_REQUIRE.

---
 migration/colo.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
migration/colo.c +4 -3
index a916dc178c..a13acac192 100644
@@ -121,6 +121,7 @@ static void secondary_vm_do_failover(void)
     }
     /* Notify COLO incoming thread that failover work is finished */
     qemu_sem_post(&mis->colo_incoming_sem);
+
     /* For Secondary VM, jump to incoming co */
     if (mis->migration_incoming_co) {
         qemu_coroutine_enter(mis->migration_incoming_co);
@@ -262,7 +263,7 @@ COLOStatus *qmp_query_colo_status(Error **errp)
     case FAILOVER_STATUS_NONE:
         s->reason = COLO_EXIT_REASON_NONE;
         break;
-    case FAILOVER_STATUS_REQUIRE:
+    case FAILOVER_STATUS_COMPLETED:
         s->reason = COLO_EXIT_REASON_REQUEST;
         break;
     default:
@@ -582,7 +583,7 @@ out:
         qapi_event_send_colo_exit(COLO_MODE_PRIMARY,
                                   COLO_EXIT_REASON_ERROR);
         break;
-    case FAILOVER_STATUS_REQUIRE:
+    case FAILOVER_STATUS_COMPLETED:
         qapi_event_send_colo_exit(COLO_MODE_PRIMARY,
                                   COLO_EXIT_REASON_REQUEST);
         break;
@@ -854,7 +855,7 @@ out:
         qapi_event_send_colo_exit(COLO_MODE_SECONDARY,
                                   COLO_EXIT_REASON_ERROR);
         break;
-    case FAILOVER_STATUS_REQUIRE:
+    case FAILOVER_STATUS_COMPLETED:
         qapi_event_send_colo_exit(COLO_MODE_SECONDARY,
                                   COLO_EXIT_REASON_REQUEST);
         break;
Signature · 1 line
2.17.GIT
#4 lore raw

Re: [Qemu-devel] [PATCH 2/3] Migration/colo.c: Fix COLO failover status error

Quoted 6 lines · * Zhang Chen ([email protected]) wrote:

From: Zhang Chen <[email protected]>

When finished COLO failover, the status is FAILOVER_STATUS_COMPLETED. The origin codes misunderstand the FAILOVER_STATUS_REQUIRE.

Why do these 'case's have to only deal with COMPLETED - what stops the REQUIRE/ACTIVE states appearing when these routines check the status; even if those states only happen for a short amount of time?

Dave

Quoted 46 lines
---
 migration/colo.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
migration/colo.c +4 -3
index a916dc178c..a13acac192 100644
@@ -121,6 +121,7 @@ static void secondary_vm_do_failover(void)
     }
     /* Notify COLO incoming thread that failover work is finished */
     qemu_sem_post(&mis->colo_incoming_sem);
+
     /* For Secondary VM, jump to incoming co */
     if (mis->migration_incoming_co) {
         qemu_coroutine_enter(mis->migration_incoming_co);
@@ -262,7 +263,7 @@ COLOStatus *qmp_query_colo_status(Error **errp)
     case FAILOVER_STATUS_NONE:
         s->reason = COLO_EXIT_REASON_NONE;
         break;
-    case FAILOVER_STATUS_REQUIRE:
+    case FAILOVER_STATUS_COMPLETED:
         s->reason = COLO_EXIT_REASON_REQUEST;
         break;
     default:
@@ -582,7 +583,7 @@ out:
         qapi_event_send_colo_exit(COLO_MODE_PRIMARY,
                                   COLO_EXIT_REASON_ERROR);
         break;
-    case FAILOVER_STATUS_REQUIRE:
+    case FAILOVER_STATUS_COMPLETED:
         qapi_event_send_colo_exit(COLO_MODE_PRIMARY,
                                   COLO_EXIT_REASON_REQUEST);
         break;
@@ -854,7 +855,7 @@ out:
         qapi_event_send_colo_exit(COLO_MODE_SECONDARY,
                                   COLO_EXIT_REASON_ERROR);
         break;
-    case FAILOVER_STATUS_REQUIRE:
+    case FAILOVER_STATUS_COMPLETED:
         qapi_event_send_colo_exit(COLO_MODE_SECONDARY,
                                   COLO_EXIT_REASON_REQUEST);
         break;
Signature · 1 line
2.17.GIT

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

#5 lore raw

Re: [Qemu-devel] [PATCH 2/3] Migration/colo.c: Fix COLO failover status error

-----Original Message-----
From: Dr. David Alan Gilbert [mailto:[email protected]]
Sent: Tuesday, February 26, 2019 6:55 PM
To: Zhang, Chen <[email protected]>
Cc: Li Zhijian <[email protected]>; Zhang Chen <[email protected]>; Juan Quintela <[email protected]>; zhanghailiang <[email protected]>; qemu-dev <[email protected]>
Subject: Re: [PATCH 2/3] Migration/colo.c: Fix COLO failover status error

Quoted 6 lines · * Zhang Chen ([email protected]) wrote:

From: Zhang Chen <[email protected]>

When finished COLO failover, the status is FAILOVER_STATUS_COMPLETED. The origin codes misunderstand the FAILOVER_STATUS_REQUIRE.

Why do these 'case's have to only deal with COMPLETED - what stops the REQUIRE/ACTIVE states appearing when these routines check the status; even if those states only happen for a short amount of time?

Yes, other status just marked the failover processing. We can see colo_failover_bh(), the REQUIRE/ACTIVE only exist for a very short time.

Thanks
Zhang Chen

Dave

Quoted 44 lines
---
 migration/colo.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
migration/colo.c index renamed from migration/colo.c +0 -0

a916dc178c..a13acac192 100644

migration/colo.c +4 -4
@@ -121,6 +121,7 @@ static void secondary_vm_do_failover(void)
     }
     /* Notify COLO incoming thread that failover work is finished */
     qemu_sem_post(&mis->colo_incoming_sem);
+
     /* For Secondary VM, jump to incoming co */
     if (mis->migration_incoming_co) {
         qemu_coroutine_enter(mis->migration_incoming_co);
@@ -262,7 +263,7 @@ COLOStatus *qmp_query_colo_status(Error **errp)
     case FAILOVER_STATUS_NONE:
         s->reason = COLO_EXIT_REASON_NONE;
         break;
-    case FAILOVER_STATUS_REQUIRE:
+    case FAILOVER_STATUS_COMPLETED:
         s->reason = COLO_EXIT_REASON_REQUEST;
         break;
     default:
@@ -582,7 +583,7 @@ out:
         qapi_event_send_colo_exit(COLO_MODE_PRIMARY,
                                   COLO_EXIT_REASON_ERROR);
         break;
-    case FAILOVER_STATUS_REQUIRE:
+    case FAILOVER_STATUS_COMPLETED:
         qapi_event_send_colo_exit(COLO_MODE_PRIMARY,
                                   COLO_EXIT_REASON_REQUEST);
         break;
@@ -854,7 +855,7 @@ out:
         qapi_event_send_colo_exit(COLO_MODE_SECONDARY,
                                   COLO_EXIT_REASON_ERROR);
         break;
-    case FAILOVER_STATUS_REQUIRE:
+    case FAILOVER_STATUS_COMPLETED:
         qapi_event_send_colo_exit(COLO_MODE_SECONDARY,
                                   COLO_EXIT_REASON_REQUEST);
         break;
--
Quoted 2 lines

2.17.GIT

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

#6 lore raw

Re: [Qemu-devel] [PATCH 2/3] Migration/colo.c: Fix COLO failover status error

Quoted 11 lines · * Zhang, Chen ([email protected]) wrote:

-----Original Message-----
From: Dr. David Alan Gilbert [mailto:[email protected]]
Sent: Tuesday, February 26, 2019 6:55 PM
To: Zhang, Chen <[email protected]>
Cc: Li Zhijian <[email protected]>; Zhang Chen <[email protected]>; Juan Quintela <[email protected]>; zhanghailiang <[email protected]>; qemu-dev <[email protected]>
Subject: Re: [PATCH 2/3] Migration/colo.c: Fix COLO failover status error

Quoted 2 lines · * Zhang Chen ([email protected]) wrote:

From: Zhang Chen <[email protected]>

Quoted 8 lines
Quoted 6 lines

When finished COLO failover, the status is FAILOVER_STATUS_COMPLETED. The origin codes misunderstand the FAILOVER_STATUS_REQUIRE.

Why do these 'case's have to only deal with COMPLETED - what stops the REQUIRE/ACTIVE states appearing when these routines check the status; even if those states only happen for a short amount of time?

Yes, other status just marked the failover processing. We can see colo_failover_bh(), the REQUIRE/ACTIVE only exist for a very short time.

But those other states do exist - so don't these case statements have to do something with them?

Dave

Quoted 46 lines

Thanks
Zhang Chen

Dave

Quoted 40 lines
---
 migration/colo.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
migration/colo.c index renamed from migration/colo.c +0 -0

a916dc178c..a13acac192 100644

migration/colo.c +4 -3
@@ -121,6 +121,7 @@ static void secondary_vm_do_failover(void)
     }
     /* Notify COLO incoming thread that failover work is finished */
     qemu_sem_post(&mis->colo_incoming_sem);
+
     /* For Secondary VM, jump to incoming co */
     if (mis->migration_incoming_co) {
         qemu_coroutine_enter(mis->migration_incoming_co);
@@ -262,7 +263,7 @@ COLOStatus *qmp_query_colo_status(Error **errp)
     case FAILOVER_STATUS_NONE:
         s->reason = COLO_EXIT_REASON_NONE;
         break;
-    case FAILOVER_STATUS_REQUIRE:
+    case FAILOVER_STATUS_COMPLETED:
         s->reason = COLO_EXIT_REASON_REQUEST;
         break;
     default:
@@ -582,7 +583,7 @@ out:
         qapi_event_send_colo_exit(COLO_MODE_PRIMARY,
                                   COLO_EXIT_REASON_ERROR);
         break;
-    case FAILOVER_STATUS_REQUIRE:
+    case FAILOVER_STATUS_COMPLETED:
         qapi_event_send_colo_exit(COLO_MODE_PRIMARY,
                                   COLO_EXIT_REASON_REQUEST);
         break;
@@ -854,7 +855,7 @@ out:
         qapi_event_send_colo_exit(COLO_MODE_SECONDARY,
                                   COLO_EXIT_REASON_ERROR);
         break;
-    case FAILOVER_STATUS_REQUIRE:
+    case FAILOVER_STATUS_COMPLETED:
Quoted 8 lines
Quoted 6 lines
migration/colo.c +0 -1
         qapi_event_send_colo_exit(COLO_MODE_SECONDARY,
                                   COLO_EXIT_REASON_REQUEST);
         break;
--

2.17.GIT

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

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

#7 lore raw

Re: [Qemu-devel] [PATCH 2/3] Migration/colo.c: Fix COLO failover status error

-----Original Message-----
From: Dr. David Alan Gilbert [mailto:[email protected]]
Sent: Thursday, February 28, 2019 9:03 PM
To: Zhang, Chen <[email protected]>
Cc: Li Zhijian <[email protected]>; Zhang Chen <[email protected]>; Juan Quintela <[email protected]>; zhanghailiang <[email protected]>; qemu-dev <[email protected]>
Subject: Re: [PATCH 2/3] Migration/colo.c: Fix COLO failover status error

Quoted 15 lines · * Zhang, Chen ([email protected]) wrote:

-----Original Message-----
From: Dr. David Alan Gilbert [mailto:[email protected]]
Sent: Tuesday, February 26, 2019 6:55 PM
To: Zhang, Chen <[email protected]>
Cc: Li Zhijian <[email protected]>; Zhang Chen <[email protected]>; Juan Quintela <[email protected]>; zhanghailiang <[email protected]>; qemu-dev <[email protected]>
Subject: Re: [PATCH 2/3] Migration/colo.c: Fix COLO failover status error

Quoted 2 lines · * Zhang Chen ([email protected]) wrote:

From: Zhang Chen <[email protected]>

Quoted 8 lines
Quoted 6 lines

When finished COLO failover, the status is FAILOVER_STATUS_COMPLETED. The origin codes misunderstand the FAILOVER_STATUS_REQUIRE.

Why do these 'case's have to only deal with COMPLETED - what stops the REQUIRE/ACTIVE states appearing when these routines check the status; even if those states only happen for a short amount of time?

Yes, other status just marked the failover processing. We can see colo_failover_bh(), the REQUIRE/ACTIVE only exist for a very short time.

But those other states do exist - so don't these case statements have to do something with them?

Yes, you are right.
I will add another one patch to handle other states in this series next version.

Thanks
Zhang Chen

Dave

Quoted 46 lines

Thanks
Zhang Chen

Dave

Quoted 40 lines
---
 migration/colo.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
migration/colo.c index renamed from migration/colo.c +0 -0

a916dc178c..a13acac192 100644

migration/colo.c +4 -3
@@ -121,6 +121,7 @@ static void secondary_vm_do_failover(void)
     }
     /* Notify COLO incoming thread that failover work is finished */
     qemu_sem_post(&mis->colo_incoming_sem);
+
     /* For Secondary VM, jump to incoming co */
     if (mis->migration_incoming_co) {
         qemu_coroutine_enter(mis->migration_incoming_co);
@@ -262,7 +263,7 @@ COLOStatus *qmp_query_colo_status(Error **errp)
     case FAILOVER_STATUS_NONE:
         s->reason = COLO_EXIT_REASON_NONE;
         break;
-    case FAILOVER_STATUS_REQUIRE:
+    case FAILOVER_STATUS_COMPLETED:
         s->reason = COLO_EXIT_REASON_REQUEST;
         break;
     default:
@@ -582,7 +583,7 @@ out:
         qapi_event_send_colo_exit(COLO_MODE_PRIMARY,
                                   COLO_EXIT_REASON_ERROR);
         break;
-    case FAILOVER_STATUS_REQUIRE:
+    case FAILOVER_STATUS_COMPLETED:
         qapi_event_send_colo_exit(COLO_MODE_PRIMARY,
                                   COLO_EXIT_REASON_REQUEST);
         break;
@@ -854,7 +855,7 @@ out:
         qapi_event_send_colo_exit(COLO_MODE_SECONDARY,
                                   COLO_EXIT_REASON_ERROR);
         break;
-    case FAILOVER_STATUS_REQUIRE:
+    case FAILOVER_STATUS_COMPLETED:
Quoted 8 lines
Quoted 6 lines
migration/colo.c +0 -1
         qapi_event_send_colo_exit(COLO_MODE_SECONDARY,
                                   COLO_EXIT_REASON_REQUEST);
         break;
--

2.17.GIT

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

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

author
#8 lore raw

PATCH 3/3 Migration/colo.c: Make COLO node running after failover

In reply to Zhang Chen

From: Zhang Chen <[email protected]>

Delay to close COLO for auto start VM after failover.

---
 migration/colo.c      | 1 -
 migration/migration.c | 3 +++
 2 files changed, 3 insertions(+), 1 deletion(-)
migration/colo.c +0 -1
index a13acac192..89325952c7 100644
@@ -875,7 +875,6 @@ out:
         qemu_fclose(mis->to_src_file);
         mis->to_src_file = NULL;
     }
-    migration_incoming_disable_colo();
 
     rcu_unregister_thread();
     return NULL;
migration/migration.c +3 -0
index 37e06b76dc..cec5f529c3 100644
@@ -383,6 +383,9 @@ static void process_incoming_migration_bh(void *opaque)
         } else {
             runstate_set(RUN_STATE_PAUSED);
         }
+    } else if (migration_incoming_colo_enabled()) {
+        migration_incoming_disable_colo();
+        vm_start();
     } else {
         runstate_set(global_state_get_runstate());
     }
Signature · 1 line
2.17.GIT
Reviewed-by on v1 3/3
#9 lore raw

Re: [Qemu-devel] [PATCH 3/3] Migration/colo.c: Make COLO node running after failover

Quoted 5 lines · * Zhang Chen ([email protected]) wrote:

From: Zhang Chen <[email protected]>

Delay to close COLO for auto start VM after failover.

Yes, I guess the state sent over the global state is probably RUN_STATE_COLO so it doesn't autostart on new machine types, and this looks like it would fix it.

Quoted 34 lines
---
 migration/colo.c      | 1 -
 migration/migration.c | 3 +++
 2 files changed, 3 insertions(+), 1 deletion(-)
migration/colo.c +0 -1
index a13acac192..89325952c7 100644
@@ -875,7 +875,6 @@ out:
         qemu_fclose(mis->to_src_file);
         mis->to_src_file = NULL;
     }
-    migration_incoming_disable_colo();
 
     rcu_unregister_thread();
     return NULL;
migration/migration.c +3 -0
index 37e06b76dc..cec5f529c3 100644
@@ -383,6 +383,9 @@ static void process_incoming_migration_bh(void *opaque)
         } else {
             runstate_set(RUN_STATE_PAUSED);
         }
+    } else if (migration_incoming_colo_enabled()) {
+        migration_incoming_disable_colo();
+        vm_start();
     } else {
         runstate_set(global_state_get_runstate());
     }
Signature · 1 line
2.17.GIT

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