Skip to contentSkip to conversation

migration/colo: Optimize COLO framework code

PATCH In review Zhang Chen 3 participants 10 messages Jun 7, 2020 – Jul 8, 2020

lore
Share & tools
lore

Zhang Chen

author
#0 lore raw

v3 cover migration/colo: Optimize COLO framework code

From: Zhang Chen <[email protected]>

This series optimize some code of COLO, please review.

Zhang Chen (3):
migration/colo: Optimize COLO boot code path migration/colo: Update checkpoint time lately migration/migration.c: Remove MIGRATION_STATUS_ACTIVE in
migration_iteration_finish

 migration/colo.c      |  7 ++-----
 migration/migration.c | 12 +++++-------
 2 files changed, 7 insertions(+), 12 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v3 1/3 migration/colo: Optimize COLO boot code path

From: Zhang Chen <[email protected]>

No need to reuse MIGRATION_STATUS_ACTIVE boot COLO.

---
 migration/colo.c      |  2 --
 migration/migration.c | 17 ++++++++++-------
 2 files changed, 10 insertions(+), 9 deletions(-)
migration/colo.c +0 -2
index ea7d1e9d4e..91c76789fa 100644
@@ -670,8 +670,6 @@ void migrate_start_colo_process(MigrationState *s)
                                 colo_checkpoint_notify, s);
 
     qemu_sem_init(&s->colo_exit_sem, 0);
-    migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE,
-                      MIGRATION_STATUS_COLO);
     colo_process_checkpoint(s);
     qemu_mutex_lock_iothread();
 }
migration/migration.c +10 -7
index b63ad91d34..9059238e3d 100644
@@ -2972,7 +2972,10 @@ static void migration_completion(MigrationState *s)
         goto fail_invalidate;
     }
 
-    if (!migrate_colo_enabled()) {
+    if (migrate_colo_enabled()) {
+        migrate_set_state(&s->state, current_active_state,
+                          MIGRATION_STATUS_COLO);
+    } else {
         migrate_set_state(&s->state, current_active_state,
                           MIGRATION_STATUS_COMPLETED);
     }
@@ -3304,12 +3307,7 @@ static void migration_iteration_finish(MigrationState *s)
         migration_calculate_complete(s);
         runstate_set(RUN_STATE_POSTMIGRATE);
         break;
-
-    case MIGRATION_STATUS_ACTIVE:
-        /*
-         * We should really assert here, but since it's during
-         * migration, let's try to reduce the usage of assertions.
-         */
+    case MIGRATION_STATUS_COLO:
         if (!migrate_colo_enabled()) {
             error_report("%s: critical error: calling COLO code without "
                          "COLO enabled", __func__);
@@ -3321,6 +3319,11 @@ static void migration_iteration_finish(MigrationState *s)
          */
         s->vm_was_running = true;
         /* Fallthrough */
+    case MIGRATION_STATUS_ACTIVE:
+        /*
+         * We should really assert here, but since it's during
+         * migration, let's try to reduce the usage of assertions.
+         */
     case MIGRATION_STATUS_FAILED:
     case MIGRATION_STATUS_CANCELLED:
     case MIGRATION_STATUS_CANCELLING:
Signature · 1 line
2.17.1
Reviewed-by Tested-by on v3 1/3
#2 lore raw

Re: [PATCH V3 1/3] migration/colo: Optimize COLO boot code path

Quoted 7 lines · On Mon, 8 Jun 2020 03:46:09 +0800 Zhang Chen <[email protected] > wrote:

From: Zhang Chen <[email protected]>

No need to reuse MIGRATION_STATUS_ACTIVE boot COLO.

---

Looks good and works well in my tests.

Regards,
Lukas Straub

author
#3 lore raw

PATCH v3 2/3 migration/colo: Update checkpoint time lately

In reply to Zhang Chen

From: Zhang Chen <[email protected]>

Previous operation(like vm_start and replication_start_all) will consume extra time for first forced synchronization, so reduce it in this patch.

---
 migration/colo.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
migration/colo.c +2 -3
index 91c76789fa..2b837e1255 100644
@@ -532,7 +532,6 @@ static void colo_process_checkpoint(MigrationState *s)
 {
     QIOChannelBuffer *bioc;
     QEMUFile *fb = NULL;
-    int64_t current_time = qemu_clock_get_ms(QEMU_CLOCK_HOST);
     Error *local_err = NULL;
     int ret;
 
@@ -581,8 +580,8 @@ static void colo_process_checkpoint(MigrationState *s)
     qemu_mutex_unlock_iothread();
     trace_colo_vm_state_change("stop", "run");
 
-    timer_mod(s->colo_delay_timer,
-            current_time + s->parameters.x_checkpoint_delay);
+    timer_mod(s->colo_delay_timer, qemu_clock_get_ms(QEMU_CLOCK_HOST) +
+              s->parameters.x_checkpoint_delay);
 
     while (s->state == MIGRATION_STATUS_COLO) {
         if (failover_get_state() != FAILOVER_STATUS_NONE) {
Signature · 1 line
2.17.1
author
#4 lore raw

PATCH v3 3/3 migration/migration.c: Remove MIGRATION_STATUS_ACTIVE in migration_iteration_finish

In reply to Zhang Chen

From: Zhang Chen <[email protected]>

MIGRATION_STATUS_ACTIVE is invalid here, handle it by default case.

---
 migration/migration.c | 5 -----
 1 file changed, 5 deletions(-)
migration/migration.c +0 -5
index 9059238e3d..9958b15202 100644
@@ -3319,11 +3319,6 @@ static void migration_iteration_finish(MigrationState *s)
          */
         s->vm_was_running = true;
         /* Fallthrough */
-    case MIGRATION_STATUS_ACTIVE:
-        /*
-         * We should really assert here, but since it's during
-         * migration, let's try to reduce the usage of assertions.
-         */
     case MIGRATION_STATUS_FAILED:
     case MIGRATION_STATUS_CANCELLED:
     case MIGRATION_STATUS_CANCELLING:
Signature · 1 line
2.17.1
Reviewed-by Tested-by on v3 3/3
#5 lore raw

Re: [PATCH V3 3/3] migration/migration.c: Remove MIGRATION_STATUS_ACTIVE in migration_iteration_finish

Quoted 7 lines · On Mon, 8 Jun 2020 03:46:11 +0800 Zhang Chen <[email protected] > wrote:

From: Zhang Chen <[email protected]>

MIGRATION_STATUS_ACTIVE is invalid here, handle it by default case.

---

Looks good and works well in my tests.

Regards,
Lukas Straub

#6 lore raw
In reply to Zhang Chen

Hi Dave,

Any comments for this series?

Thanks
Zhang Chen

Quoted 25 lines

-----Original Message-----
From: Zhang, Chen <[email protected]>
Sent: Monday, June 8, 2020 3:46 AM
To: Dr . David Alan Gilbert <[email protected]>; qemu-dev <qemu- [email protected]>
Cc: Zhang Chen <[email protected]>; Zhanghailiang <[email protected]>; Zhang, Chen <[email protected]>
Subject: [PATCH V3 0/3] migration/colo: Optimize COLO framework code

From: Zhang Chen <[email protected]>

This series optimize some code of COLO, please review.

Zhang Chen (3):
migration/colo: Optimize COLO boot code path migration/colo: Update checkpoint time lately migration/migration.c: Remove MIGRATION_STATUS_ACTIVE in
migration_iteration_finish

 migration/colo.c      |  7 ++-----
 migration/migration.c | 12 +++++-------
 2 files changed, 7 insertions(+), 12 deletions(-)

--
2.17.1

#7 lore raw
Quoted 2 lines · * Zhang, Chen ([email protected]) wrote:

Hi Dave,

I think it's OK; I guess Zhanghailiang is going to do a pull for it? One thought about the change of use of MIGRATION_STATUS_ACTIVE; I think it's OK at the moment - but the migration states and the way they change becomes part of the API - changing which states we use can confuse management applications; since there's no libvirt support, I'll leave it to Zhanghailiang to know if that's OK.

Dave

Quoted 30 lines

Thanks
Zhang Chen

Quoted 25 lines

-----Original Message-----
From: Zhang, Chen <[email protected]>
Sent: Monday, June 8, 2020 3:46 AM
To: Dr . David Alan Gilbert <[email protected]>; qemu-dev <qemu- [email protected]>
Cc: Zhang Chen <[email protected]>; Zhanghailiang <[email protected]>; Zhang, Chen <[email protected]>
Subject: [PATCH V3 0/3] migration/colo: Optimize COLO framework code

From: Zhang Chen <[email protected]>

This series optimize some code of COLO, please review.

Zhang Chen (3):
migration/colo: Optimize COLO boot code path migration/colo: Update checkpoint time lately migration/migration.c: Remove MIGRATION_STATUS_ACTIVE in
migration_iteration_finish

 migration/colo.c      |  7 ++-----
 migration/migration.c | 12 +++++-------
 2 files changed, 7 insertions(+), 12 deletions(-)

--
2.17.1

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

#8 lore raw
Quoted 14 lines

-----Original Message-----
From: Dr. David Alan Gilbert <[email protected]>
Sent: Wednesday, June 17, 2020 8:26 PM
To: Zhang, Chen <[email protected]>
Cc: qemu-dev <[email protected]>; Zhang Chen <[email protected]>; Zhanghailiang <[email protected]>
Subject: Re: [PATCH V3 0/3] migration/colo: Optimize COLO framework code

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

Hi Dave,

Quoted 6 lines

I think it's OK; I guess Zhanghailiang is going to do a pull for it? One thought about the change of use of MIGRATION_STATUS_ACTIVE; I think it's OK at the moment - but the migration states and the way they change becomes part of the API - changing which states we use can confuse management applications; since there's no libvirt support, I'll leave it to Zhanghailiang to know if that's OK.

Hi Hailiang/Dave,

Current upstream libvirt can't support COLO, it looks no new issue for normal migration process. For the future, new COLO migration status is good for COLO enable work on libvirt and upper layer.

Thanks
Zhang Chen

Quoted 37 lines

Dave

Quoted 11 lines

Thanks
Zhang Chen

Quoted 7 lines

-----Original Message-----
From: Zhang, Chen <[email protected]>
Sent: Monday, June 8, 2020 3:46 AM
To: Dr . David Alan Gilbert <[email protected]>; qemu-dev <qemu- [email protected]>
Cc: Zhang Chen <[email protected]>; Zhanghailiang <[email protected]>; Zhang, Chen

<[email protected]>

Quoted 12 lines
Quoted 12 lines

Subject: [PATCH V3 0/3] migration/colo: Optimize COLO framework code

From: Zhang Chen <[email protected]>

This series optimize some code of COLO, please review.

Zhang Chen (3):
migration/colo: Optimize COLO boot code path migration/colo: Update checkpoint time lately migration/migration.c: Remove MIGRATION_STATUS_ACTIVE in
migration_iteration_finish

Quoted 7 lines
Quoted 6 lines
 migration/colo.c      |  7 ++-----
 migration/migration.c | 12 +++++-------
 2 files changed, 7 insertions(+), 12 deletions(-)

--
2.17.1

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

#9 lore raw

Hi Hailiang/Dave,

No news for a while, any comments?

Thanks
Zhang Chen

Quoted 81 lines

-----Original Message-----
From: Qemu-devel <qemu-devel- [email protected]> On Behalf Of Zhang, Chen
Sent: Monday, June 22, 2020 2:53 PM
To: Dr. David Alan Gilbert <[email protected]>
Cc: Zhanghailiang <[email protected]>; qemu-dev <qemu- [email protected]>; Zhang Chen <[email protected]>
Subject: RE: [PATCH V3 0/3] migration/colo: Optimize COLO framework code

Quoted 6 lines

-----Original Message-----
From: Dr. David Alan Gilbert <[email protected]>
Sent: Wednesday, June 17, 2020 8:26 PM
To: Zhang, Chen <[email protected]>
Cc: qemu-dev <[email protected]>; Zhang Chen <[email protected]>; Zhanghailiang

<[email protected]>

Quoted 7 lines

Subject: Re: [PATCH V3 0/3] migration/colo: Optimize COLO framework code

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

Hi Dave,

Quoted 6 lines

I think it's OK; I guess Zhanghailiang is going to do a pull for it? One thought about the change of use of MIGRATION_STATUS_ACTIVE; I think it's OK at the moment - but the migration states and the way they change becomes part of the API - changing which states we use can confuse management applications; since there's no libvirt support, I'll leave it to Zhanghailiang to know if that's OK.

Hi Hailiang/Dave,

Current upstream libvirt can't support COLO, it looks no new issue for normal migration process.
For the future, new COLO migration status is good for COLO enable work on libvirt and upper layer.

Thanks
Zhang Chen

Quoted 38 lines

Dave

Quoted 11 lines

Thanks
Zhang Chen

Quoted 7 lines

-----Original Message-----
From: Zhang, Chen <[email protected]>
Sent: Monday, June 8, 2020 3:46 AM
To: Dr . David Alan Gilbert <[email protected]>; qemu-dev <qemu- [email protected]>
Cc: Zhang Chen <[email protected]>; Zhanghailiang <[email protected]>; Zhang, Chen

<[email protected]>

Quoted 13 lines
Quoted 13 lines

Subject: [PATCH V3 0/3] migration/colo: Optimize COLO framework code

From: Zhang Chen <[email protected]>

This series optimize some code of COLO, please review.

Zhang Chen (3):
migration/colo: Optimize COLO boot code path migration/colo: Update checkpoint time lately migration/migration.c: Remove MIGRATION_STATUS_ACTIVE in
migration_iteration_finish

Quoted 7 lines
Quoted 6 lines
 migration/colo.c      |  7 ++-----
 migration/migration.c | 12 +++++-------
 2 files changed, 7 insertions(+), 12 deletions(-)

--
2.17.1

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