From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: peterx@redhat.com, Fabiano Rosas <farosas@suse.de>,
Joao Martins <joao.m.martins@oracle.com>,
Juan Quintela <quintela@redhat.com>
Subject: [PATCH v2 4/5] migration: migration_stop_vm() helper
Date: Mon, 30 Oct 2023 12:33:45 -0400 [thread overview]
Message-ID: <20231030163346.765724-5-peterx@redhat.com> (raw)
In-Reply-To: <20231030163346.765724-1-peterx@redhat.com>
Provide a helper for non-COLO use case of migration to stop a VM. This
prepares for adding some downtime relevant tracepoints to migration, where
they may or may not apply to COLO.
Signed-off-by: Peter Xu <peterx@redhat.com>
---
migration/migration.h | 2 ++
migration/migration.c | 11 ++++++++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/migration/migration.h b/migration/migration.h
index ae82004892..5944107ad5 100644
--- a/migration/migration.h
+++ b/migration/migration.h
@@ -544,4 +544,6 @@ void migration_rp_wait(MigrationState *s);
*/
void migration_rp_kick(MigrationState *s);
+int migration_stop_vm(RunState state);
+
#endif
diff --git a/migration/migration.c b/migration/migration.c
index 70d775942a..9013c1b500 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -149,6 +149,11 @@ static gint page_request_addr_cmp(gconstpointer ap, gconstpointer bp)
return (a > b) - (a < b);
}
+int migration_stop_vm(RunState state)
+{
+ return vm_stop_force_state(state);
+}
+
void migration_object_init(void)
{
/* This can only be called once. */
@@ -2164,7 +2169,7 @@ static int postcopy_start(MigrationState *ms, Error **errp)
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL);
global_state_store();
- ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
+ ret = migration_stop_vm(RUN_STATE_FINISH_MIGRATE);
if (ret < 0) {
goto fail;
}
@@ -2366,7 +2371,7 @@ static int migration_completion_precopy(MigrationState *s,
s->vm_old_state = runstate_get();
global_state_store();
- ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
+ ret = migration_stop_vm(RUN_STATE_FINISH_MIGRATE);
trace_migration_completion_vm_stop(ret);
if (ret < 0) {
goto out_unlock;
@@ -3217,7 +3222,7 @@ static void *bg_migration_thread(void *opaque)
global_state_store();
/* Forcibly stop VM before saving state of vCPUs and devices */
- if (vm_stop_force_state(RUN_STATE_PAUSED)) {
+ if (migration_stop_vm(RUN_STATE_PAUSED)) {
goto fail;
}
/*
--
2.41.0
next prev parent reply other threads:[~2023-10-30 16:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-30 16:33 [PATCH v2 0/5] migration: Downtime tracepoints Peter Xu
2023-10-30 16:33 ` [PATCH v2 1/5] migration: Set downtime_start even for postcopy Peter Xu
2023-10-31 11:38 ` Juan Quintela
2023-10-30 16:33 ` [PATCH v2 2/5] migration: Add migration_downtime_start|end() helpers Peter Xu
2023-10-31 11:39 ` Juan Quintela
2023-10-30 16:33 ` [PATCH v2 3/5] migration: Add per vmstate downtime tracepoints Peter Xu
2023-10-31 12:52 ` Juan Quintela
2023-10-30 16:33 ` Peter Xu [this message]
2023-10-31 12:53 ` [PATCH v2 4/5] migration: migration_stop_vm() helper Juan Quintela
2023-10-30 16:33 ` [PATCH v2 5/5] migration: Add tracepoints for downtime checkpoints Peter Xu
2023-10-31 12:54 ` 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=20231030163346.765724-5-peterx@redhat.com \
--to=peterx@redhat.com \
--cc=farosas@suse.de \
--cc=joao.m.martins@oracle.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.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.