Re: [Qemu-devel] [PULL 14/15] Migration/colo.c: Make user obtain the last COLO mode info after failover

2019-03-26 Thread Zhang, Chen



> -Original Message-
> From: Eric Blake [mailto:ebl...@redhat.com]
> Sent: Tuesday, March 26, 2019 10:41 PM
> To: Juan Quintela ; qemu-devel@nongnu.org
> Cc: Dr. David Alan Gilbert ; zhanghailiang
> ; Markus Armbruster
> ; Zhang, Chen 
> Subject: Re: [PULL 14/15] Migration/colo.c: Make user obtain the last COLO
> mode info after failover
> 
> On 3/25/19 12:47 PM, Juan Quintela wrote:
> > From: Zhang Chen 
> >
> > Add the last_colo_mode to save the status after failover.
> > This patch can solve the issue that user want to get last colo mode
> > use query_colo_status after failover.
> >
> > Signed-off-by: Zhang Chen 
> > Reviewed-by: Juan Quintela 
> > Signed-off-by: Juan Quintela 
> > ---
> 
> > +++ b/qapi/migration.json
> > @@ -1380,12 +1380,17 @@
> >  # @mode: COLO running mode. If COLO is running, this field will return
> >  #'primary' or 'secondary'.
> >  #
> > +# @last_mode: COLO last running mode. If COLO is running, this field
> > +# will return same like mode field, after failover we can
> > +# use this field to get last colo mode. (since 4.1)
> 
> s/4.1/4.0/ - now that this pull request is applied, we'll need a followup 
> patch.
> (Safe for 4.0, as fixing documentation is doable during
> freeze)

OK, I will send a patch for this issue.

Thanks
Zhang Chen

> 
> --
> Eric Blake, Principal Software Engineer
> Red Hat, Inc.   +1-919-301-3226
> Virtualization:  qemu.org | libvirt.org



Re: [Qemu-devel] [PULL 14/15] Migration/colo.c: Make user obtain the last COLO mode info after failover

2019-03-26 Thread Eric Blake
On 3/25/19 12:47 PM, Juan Quintela wrote:
> From: Zhang Chen 
> 
> Add the last_colo_mode to save the status after failover.
> This patch can solve the issue that user want to get last colo mode
> use query_colo_status after failover.
> 
> Signed-off-by: Zhang Chen 
> Reviewed-by: Juan Quintela 
> Signed-off-by: Juan Quintela 
> ---

> +++ b/qapi/migration.json
> @@ -1380,12 +1380,17 @@
>  # @mode: COLO running mode. If COLO is running, this field will return
>  #'primary' or 'secondary'.
>  #
> +# @last_mode: COLO last running mode. If COLO is running, this field
> +# will return same like mode field, after failover we can
> +# use this field to get last colo mode. (since 4.1)

s/4.1/4.0/ - now that this pull request is applied, we'll need a
followup patch. (Safe for 4.0, as fixing documentation is doable during
freeze)

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] [PULL 14/15] Migration/colo.c: Make user obtain the last COLO mode info after failover

2019-03-25 Thread Juan Quintela
From: Zhang Chen 

Add the last_colo_mode to save the status after failover.
This patch can solve the issue that user want to get last colo mode
use query_colo_status after failover.

Signed-off-by: Zhang Chen 
Reviewed-by: Juan Quintela 
Signed-off-by: Juan Quintela 
---
 migration/colo.c| 16 
 qapi/migration.json |  7 ++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/migration/colo.c b/migration/colo.c
index d1ae2e6d11..238a6d62c7 100644
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -38,6 +38,9 @@
 static bool vmstate_loading;
 static Notifier packets_compare_notifier;
 
+/* User need to know colo mode after COLO failover */
+static COLOMode last_colo_mode;
+
 #define COLO_BUFFER_BASE_SIZE (4 * 1024 * 1024)
 
 bool migration_in_colo_state(void)
@@ -264,6 +267,7 @@ COLOStatus *qmp_query_colo_status(Error **errp)
 COLOStatus *s = g_new0(COLOStatus, 1);
 
 s->mode = get_colo_mode();
+s->last_mode = last_colo_mode;
 
 switch (failover_get_state()) {
 case FAILOVER_STATUS_NONE:
@@ -515,6 +519,12 @@ static void colo_process_checkpoint(MigrationState *s)
 Error *local_err = NULL;
 int ret;
 
+last_colo_mode = get_colo_mode();
+if (last_colo_mode != COLO_MODE_PRIMARY) {
+error_report("COLO mode must be COLO_MODE_PRIMARY");
+return;
+}
+
 failover_init_state();
 
 s->rp_state.from_dst_file = qemu_file_get_return_path(s->to_dst_file);
@@ -688,6 +698,12 @@ void *colo_process_incoming_thread(void *opaque)
 migrate_set_state(>state, MIGRATION_STATUS_ACTIVE,
   MIGRATION_STATUS_COLO);
 
+last_colo_mode = get_colo_mode();
+if (last_colo_mode != COLO_MODE_SECONDARY) {
+error_report("COLO mode must be COLO_MODE_SECONDARY");
+return NULL;
+}
+
 failover_init_state();
 
 mis->to_src_file = qemu_file_get_return_path(mis->from_src_file);
diff --git a/qapi/migration.json b/qapi/migration.json
index e383951765..cfde29acf8 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -1380,12 +1380,17 @@
 # @mode: COLO running mode. If COLO is running, this field will return
 #'primary' or 'secondary'.
 #
+# @last_mode: COLO last running mode. If COLO is running, this field
+# will return same like mode field, after failover we can
+# use this field to get last colo mode. (since 4.1)
+#
 # @reason: describes the reason for the COLO exit.
 #
 # Since: 3.1
 ##
 { 'struct': 'COLOStatus',
-  'data': { 'mode': 'COLOMode', 'reason': 'COLOExitReason' } }
+  'data': { 'mode': 'COLOMode', 'last_mode': 'COLOMode',
+'reason': 'COLOExitReason' } }
 
 ##
 # @query-colo-status:
-- 
2.20.1