From: Peter Xu <peterx@redhat.com>
To: Steve Sistare <steven.sistare@oracle.com>
Cc: qemu-devel@nongnu.org, "Juan Quintela" <quintela@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Thomas Huth" <thuth@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Fabiano Rosas" <farosas@suse.de>,
"Leonardo Bras" <leobras@redhat.com>
Subject: Re: [PATCH V6 05/14] migration: propagate suspended runstate
Date: Thu, 30 Nov 2023 18:06:22 -0500 [thread overview]
Message-ID: <ZWkVbiQNl16hC1LW@x1n> (raw)
In-Reply-To: <1701380247-340457-6-git-send-email-steven.sistare@oracle.com>
On Thu, Nov 30, 2023 at 01:37:18PM -0800, Steve Sistare wrote:
> If the outgoing machine was previously suspended, propagate that to the
> incoming side via global_state, so a subsequent vm_start restores the
> suspended state. To maintain backward and forward compatibility, define
> the new field in a zero'd hole in the GlobalState struct.
>
> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
> ---
> migration/global_state.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/migration/global_state.c b/migration/global_state.c
> index 4e2a9d8..de2532c 100644
> --- a/migration/global_state.c
> +++ b/migration/global_state.c
> @@ -25,6 +25,7 @@ typedef struct {
> uint8_t runstate[100];
> RunState state;
> bool received;
> + bool vm_was_suspended;
> } GlobalState;
>
> static GlobalState global_state;
> @@ -35,6 +36,7 @@ static void global_state_do_store(RunState state)
> assert(strlen(state_str) < sizeof(global_state.runstate));
> strpadcpy((char *)global_state.runstate, sizeof(global_state.runstate),
> state_str, '\0');
> + global_state.vm_was_suspended = vm_get_suspended();
> }
>
> void global_state_store(void)
> @@ -68,6 +70,12 @@ static bool global_state_needed(void *opaque)
> return true;
> }
>
> + /* If the suspended state must be remembered, it is needed */
> +
> + if (vm_get_suspended()) {
> + return true;
> + }
> +
> /* If state is running or paused, it is not needed */
>
> if (strcmp(runstate, "running") == 0 ||
> @@ -109,6 +117,7 @@ static int global_state_post_load(void *opaque, int version_id)
> return -EINVAL;
> }
> s->state = r;
> + vm_set_suspended(s->vm_was_suspended || r == RUN_STATE_SUSPENDED);
IIUC current vm_was_suspended (based on my read of your patch) was not the
same as a boolean representing "whether VM is suspended", but only a
temporary field to remember that for a VM stop request. To be explicit, I
didn't see this flag set in qemu_system_suspend() in your previous patch.
If so, we can already do:
vm_set_suspended(s->vm_was_suspended);
Irrelevant of RUN_STATE_SUSPENDED?
>
> return 0;
> }
> @@ -134,6 +143,7 @@ static const VMStateDescription vmstate_globalstate = {
> .fields = (VMStateField[]) {
> VMSTATE_UINT32(size, GlobalState),
> VMSTATE_BUFFER(runstate, GlobalState),
> + VMSTATE_BOOL(vm_was_suspended, GlobalState),
> VMSTATE_END_OF_LIST()
> },
> };
I think this will break migration between old/new, unfortunately. And
since the global state exist mostly for every VM, all VM setup should be
affected, and over all archs.
We used to have the version_id field right above for adding fields, but I
_think_ that will still break backward migration fron new->old binary, so
not wanted. Juan can keep me honest.
The best thing is still machine compat properties, afaict, to fix. It's
slightly involved, but let me attach a sample diff for you (at the end,
possibly working with your current patch kind-of squashed, but not ever
tested), hopefully make it slightly easier.
I'm wondering how bad it is to just ignore it, it's not as bad as if we
don't fix stop-during-suspend, in this case the worst case of forgetting
this field over migration is: if VM stopped (and used to be suspended) then
after migration it'll keep being stopped, however after "cont" it'll forget
the suspended state. Not that bad! IIUC SPR should always migrate with
suspended (rather than any fully stopped state), right? Then shouldn't be
affected. If risk is low, maybe we can leave this one for later?
Thanks,
===8<===
diff --git a/migration/migration.h b/migration/migration.h
index cf2c9c88e0..c3fd1f8347 100644
--- a/migration/migration.h
+++ b/migration/migration.h
@@ -470,6 +470,8 @@ struct MigrationState {
bool switchover_acked;
/* Is this a rdma migration */
bool rdma_migration;
+ /* Whether remember global vm_was_suspended field? */
+ bool store_vm_was_suspended;
};
void migrate_set_state(int *state, int old_state, int new_state);
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 0c17398141..365e01c1c9 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -37,6 +37,7 @@ GlobalProperty hw_compat_8_1[] = {
{ "ramfb", "x-migrate", "off" },
{ "vfio-pci-nohotplug", "x-ramfb-migrate", "off" },
{ "igb", "x-pcie-flr-init", "off" },
+ { "migration", "store-vm-was-suspended", false },
};
const size_t hw_compat_8_1_len = G_N_ELEMENTS(hw_compat_8_1);
diff --git a/migration/global_state.c b/migration/global_state.c
index 4e2a9d8ec0..ffa7bf82ca 100644
--- a/migration/global_state.c
+++ b/migration/global_state.c
@@ -25,6 +25,7 @@ typedef struct {
uint8_t runstate[100];
RunState state;
bool received;
+ bool vm_was_suspended;
} GlobalState;
static GlobalState global_state;
@@ -124,6 +125,25 @@ static int global_state_pre_save(void *opaque)
return 0;
}
+static bool global_state_has_vm_was_suspended(void *opaque)
+{
+ return migrate_get_current()->store_vm_was_suspended;
+}
+
+static const VMStateDescription vmstate_vm_was_suspended = {
+ .name = "globalstate/vm_was_suspended",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ /* TODO: Fill these in */
+ .pre_save = NULL,
+ .post_load = NULL,
+ .needed = global_state_has_vm_was_suspended,
+ .fields = (VMStateField[]) {
+ VMSTATE_BOOL(vm_was_suspended, GlobalState),
+ VMSTATE_END_OF_LIST()
+ },
+};
+
static const VMStateDescription vmstate_globalstate = {
.name = "globalstate",
.version_id = 1,
@@ -136,6 +156,10 @@ static const VMStateDescription vmstate_globalstate = {
VMSTATE_BUFFER(runstate, GlobalState),
VMSTATE_END_OF_LIST()
},
+ .subsections = (const VMStateDescription*[]) {
+ &vmstate_vm_was_suspended,
+ NULL
+ },
};
void register_global_state(void)
diff --git a/migration/options.c b/migration/options.c
index 8d8ec73ad9..5f9998d3e8 100644
--- a/migration/options.c
+++ b/migration/options.c
@@ -88,6 +88,8 @@
Property migration_properties[] = {
DEFINE_PROP_BOOL("store-global-state", MigrationState,
store_global_state, true),
+ DEFINE_PROP_BOOL("store-vm-was-suspended", MigrationState,
+ store_vm_was_suspended, true),
DEFINE_PROP_BOOL("send-configuration", MigrationState,
send_configuration, true),
DEFINE_PROP_BOOL("send-section-footer", MigrationState,
--
Peter Xu
next prev parent reply other threads:[~2023-11-30 23:07 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-30 21:37 [PATCH V6 00/14] fix migration of suspended runstate Steve Sistare
2023-11-30 21:37 ` [PATCH V6 01/14] cpus: pass runstate to vm_prepare_start Steve Sistare
2023-11-30 21:37 ` [PATCH V6 02/14] cpus: vm_was_suspended Steve Sistare
2023-11-30 22:03 ` Peter Xu
2023-11-30 21:37 ` [PATCH V6 03/14] cpus: stop vm in suspended runstate Steve Sistare
2023-11-30 22:10 ` Peter Xu
2023-12-01 17:11 ` Steven Sistare
2023-12-04 16:35 ` Peter Xu
2023-12-04 16:41 ` Steven Sistare
2023-12-22 12:20 ` Markus Armbruster
2023-12-22 15:53 ` Steven Sistare
2023-12-23 5:41 ` Markus Armbruster
2024-01-03 13:09 ` Peter Xu
2024-01-03 13:32 ` Steven Sistare
2024-01-03 14:47 ` Steven Sistare
2024-01-08 7:43 ` Markus Armbruster
2023-11-30 21:37 ` [PATCH V6 04/14] cpus: vm_resume Steve Sistare
2023-12-05 21:36 ` Peter Xu
2023-11-30 21:37 ` [PATCH V6 05/14] migration: propagate suspended runstate Steve Sistare
2023-11-30 23:06 ` Peter Xu [this message]
2023-12-01 16:23 ` Steven Sistare
2023-12-04 17:24 ` Peter Xu
2023-12-04 19:31 ` Fabiano Rosas
2023-12-04 20:02 ` Peter Xu
2023-12-04 21:09 ` Fabiano Rosas
2023-12-04 22:04 ` Peter Xu
2023-12-05 12:44 ` Fabiano Rosas
2023-12-05 14:14 ` Steven Sistare
2023-12-05 16:18 ` Peter Xu
2023-12-05 16:52 ` Fabiano Rosas
2023-12-05 17:04 ` Steven Sistare
2023-12-04 22:23 ` Steven Sistare
2023-12-05 16:50 ` Peter Xu
2023-12-05 17:48 ` Steven Sistare
2023-11-30 21:37 ` [PATCH V6 06/14] migration: preserve " Steve Sistare
2023-12-05 21:34 ` Peter Xu
2023-11-30 21:37 ` [PATCH V6 07/14] migration: preserve suspended for snapshot Steve Sistare
2023-12-05 21:35 ` Peter Xu
2023-11-30 21:37 ` [PATCH V6 08/14] migration: preserve suspended for bg_migration Steve Sistare
2023-12-05 21:35 ` Peter Xu
2023-11-30 21:37 ` [PATCH V6 09/14] tests/qtest: migration events Steve Sistare
2023-11-30 21:37 ` [PATCH V6 10/14] tests/qtest: option to suspend during migration Steve Sistare
2023-12-04 21:14 ` Fabiano Rosas
2023-11-30 21:37 ` [PATCH V6 11/14] tests/qtest: precopy migration with suspend Steve Sistare
2023-12-04 20:49 ` Peter Xu
2023-12-05 16:14 ` Steven Sistare
2023-12-05 21:07 ` Peter Xu
2023-11-30 21:37 ` [PATCH V6 12/14] tests/qtest: postcopy " Steve Sistare
2023-11-30 21:37 ` [PATCH V6 13/14] tests/qtest: bootfile per vm Steve Sistare
2023-12-04 21:13 ` Fabiano Rosas
2023-12-04 22:37 ` Peter Xu
2023-12-05 18:43 ` Steven Sistare
2023-11-30 21:37 ` [PATCH V6 14/14] tests/qtest: background migration with suspend Steve Sistare
2023-12-04 21:14 ` Fabiano Rosas
2023-12-05 18:52 ` [PATCH V6 00/14] fix migration of suspended runstate Steven Sistare
2023-12-05 19:19 ` Fabiano Rosas
2023-12-05 21:37 ` Peter Xu
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=ZWkVbiQNl16hC1LW@x1n \
--to=peterx@redhat.com \
--cc=berrange@redhat.com \
--cc=farosas@suse.de \
--cc=leobras@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=steven.sistare@oracle.com \
--cc=thuth@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 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).