qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Steven Sistare <steven.sistare@oracle.com>
To: Peter Xu <peterx@redhat.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>
Subject: Re: [PATCH V3 00/10] fix migration of suspended runstate
Date: Thu, 24 Aug 2023 17:09:30 -0400	[thread overview]
Message-ID: <f26b44e5-ef9a-60fc-1172-559ff5ea70de@oracle.com> (raw)
In-Reply-To: <ZN5lrPF9bY4acpvM@x1n>

On 8/17/2023 2:23 PM, Peter Xu wrote:
> On Mon, Aug 14, 2023 at 11:54:26AM -0700, Steve Sistare wrote:
>> Migration of a guest in the suspended runstate is broken.  The incoming
>> migration code automatically tries to wake the guest, which is wrong;
>> the guest should end migration in the same runstate it started.  Further,
>> for a restored snapshot, the automatic wakeup fails.  The runstate is
>> RUNNING, but the guest is not.  See the commit messages for the details.
> 
> Hi Steve,
> 
> I drafted two small patches to show what I meant, on top of this series.
> Before applying these two, one needs to revert patch 1 in this series.
> 
> After applied, it should also pass all three new suspend tests.  We can
> continue the discussion here based on the patches.

Your 2 patches look good.  I suggest we keep patch 1, and I squash patch 2
into the other patches.

There is one more fix needed: on the sending side, if the state is suspended,
then ticks must be disabled so the tick globals are updated before they are
written to vmstate.  Otherwise, tick starts at 0 in the receiver when
cpu_enable_ticks is called.

-------------------------------------------
diff --git a/migration/migration.c b/migration/migration.c
index b004475..89d56a8 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -63,6 +63,7 @@
 #include "sysemu/cpus.h"
 #include "yank_functions.h"
 #include "sysemu/qtest.h"
+#include "sysemu/cpu-timers.h"
 #include "options.h"
 #include "sysemu/dirtylimit.h"

@@ -2125,6 +2126,9 @@ static int postcopy_start(MigrationState *ms, Error **errp
     trace_postcopy_start_set_run();

     global_state_store();
+    if (runstate_check(RUN_STATE_SUSPENDED)) {
+        cpu_disable_ticks();
+    }
     ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
     if (ret < 0) {
         goto fail;
@@ -2333,6 +2337,9 @@ static void migration_completion(MigrationState *s)
         s->vm_old_state = runstate_get();
         global_state_store();

+        if (runstate_check(RUN_STATE_SUSPENDED)) {
+            cpu_disable_ticks();
+        }
         ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
         trace_migration_completion_vm_stop(ret);
         if (ret >= 0) {
diff --git a/migration/savevm.c b/migration/savevm.c
index 7b9c477..eff6976 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -58,6 +58,7 @@
 #include "qemu/cutils.h"
 #include "io/channel-buffer.h"
 #include "io/channel-file.h"
+#include "sysemu/cpu-timers.h"
 #include "sysemu/replay.h"
 #include "sysemu/runstate.h"
 #include "sysemu/sysemu.h"
@@ -2969,6 +2970,9 @@ bool save_snapshot(const char *name, bool overwrite, const
     saved_vm_running = runstate_is_running();

     global_state_store();
+    if (runstate_check(RUN_STATE_SUSPENDED)) {
+        cpu_disable_ticks();
+    }
     vm_stop(RUN_STATE_SAVE_VM);

     bdrv_drain_all_begin();
@@ -3037,6 +3041,8 @@ bool save_snapshot(const char *name, bool overwrite, const

     if (saved_vm_running) {
         vm_start();
+    } else if (runstate_check(RUN_STATE_SUSPENDED)) {
+        cpu_enable_ticks();
     }
     return ret == 0;
 }

-------------------------------------------

- Steve


  reply	other threads:[~2023-08-24 21:10 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-14 18:54 [PATCH V3 00/10] fix migration of suspended runstate Steve Sistare
2023-08-14 18:54 ` [PATCH V3 01/10] vl: start on wakeup request Steve Sistare
2023-08-17 18:27   ` Peter Xu
2023-08-24 20:54     ` Steven Sistare
2023-08-14 18:54 ` [PATCH V3 02/10] migration: preserve suspended runstate Steve Sistare
2023-08-14 18:54 ` [PATCH V3 03/10] migration: add runstate function Steve Sistare
2023-08-14 18:54 ` [PATCH V3 04/10] migration: preserve suspended for snapshot Steve Sistare
2023-08-14 18:54 ` [PATCH V3 05/10] migration: preserve suspended for bg_migration Steve Sistare
2023-08-14 18:54 ` [PATCH V3 06/10] tests/qtest: migration events Steve Sistare
2023-08-14 18:54 ` [PATCH V3 07/10] tests/qtest: option to suspend during migration Steve Sistare
2023-08-14 18:54 ` [PATCH V3 08/10] tests/qtest: precopy migration with suspend Steve Sistare
2023-08-14 18:54 ` [PATCH V3 09/10] tests/qtest: postcopy " Steve Sistare
2023-08-14 18:54 ` [PATCH V3 10/10] tests/qtest: background " Steve Sistare
2023-08-17 18:23 ` [PATCH V3 00/10] fix migration of suspended runstate Peter Xu
2023-08-24 21:09   ` Steven Sistare [this message]
2023-08-25 13:28     ` Steven Sistare
2023-08-25 15:07       ` Peter Xu
2023-08-25 17:56         ` Steven Sistare

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=f26b44e5-ef9a-60fc-1172-559ff5ea70de@oracle.com \
    --to=steven.sistare@oracle.com \
    --cc=berrange@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.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).