From: Juan Quintela <quintela@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Dr. David Alan Gilbert" <dave@treblig.org>,
Leonardo Bras <leobras@redhat.com>,
Hanna Reitz <hreitz@redhat.com>, Kevin Wolf <kwolf@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Hailiang Zhang <zhanghailiang@xfusion.com>,
Eric Blake <eblake@redhat.com>,
Juan Quintela <quintela@redhat.com>,
qemu-block@nongnu.org, Peter Xu <peterx@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>,
Zhang Chen <chen.zhang@intel.com>
Subject: [PULL 05/10] colo: make colo_checkpoint_notify static and provide simpler API
Date: Tue, 9 May 2023 21:17:19 +0200 [thread overview]
Message-ID: <20230509191724.86159-6-quintela@redhat.com> (raw)
In-Reply-To: <20230509191724.86159-1-quintela@redhat.com>
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.0
next prev parent reply other threads:[~2023-05-09 19:19 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-09 19:17 [PULL 00/10] Migration 20230509 patches Juan Quintela
2023-05-09 19:17 ` [PULL 01/10] ram: Add public helper to set colo bitmap Juan Quintela
2023-05-09 19:17 ` [PULL 02/10] ram: Let colo_flush_ram_cache take the bitmap_mutex Juan Quintela
2023-05-09 19:17 ` [PULL 03/10] multifd: Add the ramblock to MultiFDRecvParams Juan Quintela
2023-05-09 19:17 ` [PULL 04/10] block/meson.build: prefer positive condition for replication Juan Quintela
2023-05-09 19:17 ` Juan Quintela [this message]
2023-05-09 19:17 ` [PULL 06/10] build: move COLO under CONFIG_REPLICATION Juan Quintela
2023-05-09 19:17 ` [PULL 07/10] migration: drop colo_incoming_thread from MigrationIncomingState Juan Quintela
2023-05-09 19:17 ` [PULL 08/10] migration: process_incoming_migration_co: simplify code flow around ret Juan Quintela
2023-05-09 19:17 ` [PULL 09/10] migration: disallow change capabilities in COLO state Juan Quintela
2023-05-09 19:17 ` [PULL 10/10] migration: block incoming colo when capability is disabled Juan Quintela
2023-05-10 10:17 ` [PULL 00/10] Migration 20230509 patches Richard Henderson
2023-05-10 12:20 ` Juan Quintela
2023-05-10 12:35 ` Richard Henderson
2023-05-10 14:08 ` Juan Quintela
2023-05-10 14:46 ` Richard Henderson
-- strict thread matches above, loose matches on Subject: below --
2023-05-10 18:09 Juan Quintela
2023-05-10 18:09 ` [PULL 05/10] colo: make colo_checkpoint_notify static and provide simpler API Juan Quintela
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=20230509191724.86159-6-quintela@redhat.com \
--to=quintela@redhat.com \
--cc=armbru@redhat.com \
--cc=chen.zhang@intel.com \
--cc=dave@treblig.org \
--cc=eblake@redhat.com \
--cc=hreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=leobras@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@yandex-team.ru \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).