All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
To: qemu-devel@nongnu.org
Cc: lukasstraub2@web.de, quintela@redhat.com, chen.zhang@intel.com,
	vsementsov@yandex-team.ru,
	Hailiang Zhang <zhanghailiang@xfusion.com>,
	Peter Xu <peterx@redhat.com>, Leonardo Bras <leobras@redhat.com>
Subject: [PATCH v4 02/10] colo: make colo_checkpoint_notify static and provide simpler API
Date: Fri, 28 Apr 2023 22:49:20 +0300	[thread overview]
Message-ID: <20230428194928.1426370-3-vsementsov@yandex-team.ru> (raw)
In-Reply-To: <20230428194928.1426370-1-vsementsov@yandex-team.ru>

colo_checkpoint_notify() is mostly used in colo.c. Outside we use it
once when x-checkpoint-delay migration parameter is set. So, let's
simplify the external API to only that function - notify COLO that
parameter was set. This make external API more robust and hides
implementation details from external callers. Also this helps us to
make COLO module optional in further patch (i.e. we are going to add
possibility not build the COLO module).

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
 include/migration/colo.h |  9 ++++++++-
 migration/colo.c         | 29 ++++++++++++++++++-----------
 migration/options.c      |  4 +---
 3 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/include/migration/colo.h b/include/migration/colo.h
index 5fbe1a6d5d..7ef315473e 100644
--- a/include/migration/colo.h
+++ b/include/migration/colo.h
@@ -36,6 +36,13 @@ COLOMode get_colo_mode(void);
 /* failover */
 void colo_do_failover(void);
 
-void colo_checkpoint_notify(void *opaque);
+/*
+ * colo_checkpoint_delay_set
+ *
+ * Handles change of x-checkpoint-delay migration parameter, called from
+ * migrate_params_apply() to notify COLO module about the change.
+ */
+void colo_checkpoint_delay_set(void);
+
 void colo_shutdown(void);
 #endif
diff --git a/migration/colo.c b/migration/colo.c
index 07bfa21fea..c9e0b909b9 100644
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -65,6 +65,24 @@ static bool colo_runstate_is_stopped(void)
     return runstate_check(RUN_STATE_COLO) || !runstate_is_running();
 }
 
+static void colo_checkpoint_notify(void *opaque)
+{
+    MigrationState *s = opaque;
+    int64_t next_notify_time;
+
+    qemu_event_set(&s->colo_checkpoint_event);
+    s->colo_checkpoint_time = qemu_clock_get_ms(QEMU_CLOCK_HOST);
+    next_notify_time = s->colo_checkpoint_time + migrate_checkpoint_delay();
+    timer_mod(s->colo_delay_timer, next_notify_time);
+}
+
+void colo_checkpoint_delay_set(void)
+{
+    if (migration_in_colo_state()) {
+        colo_checkpoint_notify(migrate_get_current());
+    }
+}
+
 static void secondary_vm_do_failover(void)
 {
 /* COLO needs enable block-replication */
@@ -644,17 +662,6 @@ out:
     }
 }
 
-void colo_checkpoint_notify(void *opaque)
-{
-    MigrationState *s = opaque;
-    int64_t next_notify_time;
-
-    qemu_event_set(&s->colo_checkpoint_event);
-    s->colo_checkpoint_time = qemu_clock_get_ms(QEMU_CLOCK_HOST);
-    next_notify_time = s->colo_checkpoint_time + migrate_checkpoint_delay();
-    timer_mod(s->colo_delay_timer, next_notify_time);
-}
-
 void migrate_start_colo_process(MigrationState *s)
 {
     qemu_mutex_unlock_iothread();
diff --git a/migration/options.c b/migration/options.c
index 53b7fc5d5d..865a0214d8 100644
--- a/migration/options.c
+++ b/migration/options.c
@@ -1246,9 +1246,7 @@ static void migrate_params_apply(MigrateSetParameters *params, Error **errp)
 
     if (params->has_x_checkpoint_delay) {
         s->parameters.x_checkpoint_delay = params->x_checkpoint_delay;
-        if (migration_in_colo_state()) {
-            colo_checkpoint_notify(s);
-        }
+        colo_checkpoint_delay_set();
     }
 
     if (params->has_block_incremental) {
-- 
2.34.1



  parent reply	other threads:[~2023-04-28 19:50 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-28 19:49 [PATCH v4 00/10] COLO: improve build options Vladimir Sementsov-Ogievskiy
2023-04-28 19:49 ` [PATCH v4 01/10] block/meson.build: prefer positive condition for replication Vladimir Sementsov-Ogievskiy
2023-05-04  7:31   ` Zhang, Chen
2023-04-28 19:49 ` Vladimir Sementsov-Ogievskiy [this message]
2023-05-02 18:24   ` [PATCH v4 02/10] colo: make colo_checkpoint_notify static and provide simpler API Juan Quintela
2023-05-02 20:58   ` Peter Xu
2023-05-04  7:35   ` Zhang, Chen
2023-04-28 19:49 ` [PATCH v4 03/10] build: move COLO under CONFIG_REPLICATION Vladimir Sementsov-Ogievskiy
2023-05-02 16:41   ` Peter Xu
2023-05-03 22:43     ` Vladimir Sementsov-Ogievskiy
2023-05-09 18:17   ` Juan Quintela
2023-04-28 19:49 ` [PATCH v4 04/10] configure: add --disable-colo-proxy option Vladimir Sementsov-Ogievskiy
2023-05-04  7:45   ` Zhang, Chen
2023-05-09 18:42     ` Juan Quintela
2023-05-10 11:36       ` Vladimir Sementsov-Ogievskiy
2023-05-10 12:18         ` Juan Quintela
2023-05-10 12:48           ` Vladimir Sementsov-Ogievskiy
2023-05-10 13:48             ` Juan Quintela
2023-04-28 19:49 ` [PATCH v4 05/10] migration: drop colo_incoming_thread from MigrationIncomingState Vladimir Sementsov-Ogievskiy
2023-05-02 16:43   ` Peter Xu
2023-05-02 18:19   ` Juan Quintela
2023-05-04  7:46   ` Zhang, Chen
2023-04-28 19:49 ` [PATCH v4 06/10] migration: process_incoming_migration_co: simplify code flow around ret Vladimir Sementsov-Ogievskiy
2023-05-02 16:52   ` Peter Xu
2023-05-02 18:20   ` Juan Quintela
2023-05-04  7:48   ` Zhang, Chen
2023-04-28 19:49 ` [PATCH v4 07/10] migration: split migration_incoming_co Vladimir Sementsov-Ogievskiy
2023-05-02 20:48   ` Peter Xu
2023-05-03 22:51     ` Vladimir Sementsov-Ogievskiy
2023-05-04  7:51       ` Zhang, Chen
2023-04-28 19:49 ` [PATCH v4 08/10] migration: process_incoming_migration_co(): move colo part to colo Vladimir Sementsov-Ogievskiy
2023-05-02 20:54   ` Peter Xu
2023-05-03  9:15     ` Vladimir Sementsov-Ogievskiy
2023-04-28 19:49 ` [PATCH v4 09/10] migration: disallow change capabilities in COLO state Vladimir Sementsov-Ogievskiy
2023-05-02 20:57   ` Peter Xu
2023-05-04  8:09   ` Zhang, Chen
2023-05-04  8:23     ` Vladimir Sementsov-Ogievskiy
2023-05-04  9:03       ` Zhang, Chen
2023-05-09 18:22         ` Juan Quintela
2023-05-09 18:46   ` Juan Quintela
2023-04-28 19:49 ` [PATCH v4 10/10] migration: block incoming colo when capability is disabled Vladimir Sementsov-Ogievskiy
2023-05-02 20:57   ` Peter Xu
2023-05-04  9:25   ` Zhang, Chen
2023-05-04 22:10   ` Lukas Straub
2023-05-04 22:30     ` Vladimir Sementsov-Ogievskiy
2023-05-04 22:46       ` Lukas Straub
2023-05-05  7:51         ` Zhang, Chen
2023-05-09 18:23   ` Juan Quintela
2023-05-05  7:56 ` [PATCH v4 00/10] COLO: improve build options Zhang, Chen
2023-05-05  8:21   ` Vladimir Sementsov-Ogievskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230428194928.1426370-3-vsementsov@yandex-team.ru \
    --to=vsementsov@yandex-team.ru \
    --cc=chen.zhang@intel.com \
    --cc=leobras@redhat.com \
    --cc=lukasstraub2@web.de \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=zhanghailiang@xfusion.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.