[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 05/10] colo: make colo_checkpoint_notify static and provide simple
From: |
Juan Quintela |
Subject: |
[PULL 05/10] colo: make colo_checkpoint_notify static and provide simpler API |
Date: |
Wed, 10 May 2023 20:09:33 +0200 |
From: Vladimir Sementsov-Ogievskiy <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>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Zhang Chen <chen.zhang@intel.com>
Message-Id: <20230428194928.1426370-3-vsementsov@yandex-team.ru>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
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 2e759cc306..9d92b15b76 100644
--- a/migration/options.c
+++ b/migration/options.c
@@ -1253,9 +1253,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.40.1
- [PULL 10/10] migration: block incoming colo when capability is disabled, (continued)
[PULL 00/10] Migration 20230509 patches, Juan Quintela, 2023/05/10
- [PULL 02/10] ram: Let colo_flush_ram_cache take the bitmap_mutex, Juan Quintela, 2023/05/10
- [PULL 01/10] ram: Add public helper to set colo bitmap, Juan Quintela, 2023/05/10
- [PULL 03/10] multifd: Add the ramblock to MultiFDRecvParams, Juan Quintela, 2023/05/10
- [PULL 05/10] colo: make colo_checkpoint_notify static and provide simpler API,
Juan Quintela <=
- [PULL 04/10] block/meson.build: prefer positive condition for replication, Juan Quintela, 2023/05/10
- [PULL 07/10] migration: drop colo_incoming_thread from MigrationIncomingState, Juan Quintela, 2023/05/10
- [PULL 08/10] migration: process_incoming_migration_co: simplify code flow around ret, Juan Quintela, 2023/05/10
- [PULL 06/10] build: move COLO under CONFIG_REPLICATION, Juan Quintela, 2023/05/10
- [PULL 09/10] migration: disallow change capabilities in COLO state, Juan Quintela, 2023/05/10
- [PULL 10/10] migration: block incoming colo when capability is disabled, Juan Quintela, 2023/05/10
- Re: [PULL 00/10] Migration 20230509 patches, Richard Henderson, 2023/05/11