qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Steve Sistare <steven.sistare@oracle.com>
To: qemu-devel@nongnu.org
Cc: Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>,
	David Hildenbrand <david@redhat.com>,
	Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
	Eduardo Habkost <eduardo@habkost.net>,
	Philippe Mathieu-Daude <philmd@linaro.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	"Daniel P. Berrange" <berrange@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Steve Sistare <steven.sistare@oracle.com>
Subject: [PATCH V2 03/11] migration: save cpr mode
Date: Sun, 30 Jun 2024 12:40:26 -0700	[thread overview]
Message-ID: <1719776434-435013-4-git-send-email-steven.sistare@oracle.com> (raw)
In-Reply-To: <1719776434-435013-1-git-send-email-steven.sistare@oracle.com>

Save the mode in CPR state, so the user does not need to explicitly specify
it for the target.  Modify migrate_mode() so it returns the incoming mode on
the target.

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
 include/migration/cpr.h |  7 +++++++
 migration/cpr.c         | 23 ++++++++++++++++++++++-
 migration/migration.c   |  1 +
 migration/options.c     |  9 +++++++--
 4 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/include/migration/cpr.h b/include/migration/cpr.h
index 8e7e705..42b4019 100644
--- a/include/migration/cpr.h
+++ b/include/migration/cpr.h
@@ -8,6 +8,13 @@
 #ifndef MIGRATION_CPR_H
 #define MIGRATION_CPR_H
 
+#include "qapi/qapi-types-migration.h"
+
+#define MIG_MODE_NONE MIG_MODE__MAX
+
+MigMode cpr_get_incoming_mode(void);
+void cpr_set_incoming_mode(MigMode mode);
+
 typedef int (*cpr_walk_fd_cb)(int fd);
 void cpr_save_fd(const char *name, int id, int fd);
 void cpr_delete_fd(const char *name, int id);
diff --git a/migration/cpr.c b/migration/cpr.c
index 313e74e..1c296c6 100644
--- a/migration/cpr.c
+++ b/migration/cpr.c
@@ -21,10 +21,23 @@
 typedef QLIST_HEAD(CprFdList, CprFd) CprFdList;
 
 typedef struct CprState {
+    MigMode mode;
     CprFdList fds;
 } CprState;
 
-static CprState cpr_state;
+static CprState cpr_state = {
+    .mode = MIG_MODE_NONE,
+};
+
+MigMode cpr_get_incoming_mode(void)
+{
+    return cpr_state.mode;
+}
+
+void cpr_set_incoming_mode(MigMode mode)
+{
+    cpr_state.mode = mode;
+}
 
 /****************************************************************************/
 
@@ -124,11 +137,19 @@ void cpr_resave_fd(const char *name, int id, int fd)
 /*************************************************************************/
 #define CPR_STATE "CprState"
 
+static int cpr_state_presave(void *opaque)
+{
+    cpr_state.mode = migrate_mode();
+    return 0;
+}
+
 static const VMStateDescription vmstate_cpr_state = {
     .name = CPR_STATE,
     .version_id = 1,
     .minimum_version_id = 1,
+    .pre_save = cpr_state_presave,
     .fields = (VMStateField[]) {
+        VMSTATE_UINT32(mode, CprState),
         VMSTATE_QLIST_V(fds, CprState, 1, vmstate_cpr_fd, CprFd, next),
         VMSTATE_END_OF_LIST()
     }
diff --git a/migration/migration.c b/migration/migration.c
index e394ad7..0f47765 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -411,6 +411,7 @@ void migration_incoming_state_destroy(void)
         mis->postcopy_qemufile_dst = NULL;
     }
 
+    cpr_set_incoming_mode(MIG_MODE_NONE);
     yank_unregister_instance(MIGRATION_YANK_INSTANCE);
 }
 
diff --git a/migration/options.c b/migration/options.c
index 645f550..305397a 100644
--- a/migration/options.c
+++ b/migration/options.c
@@ -22,6 +22,7 @@
 #include "qapi/qmp/qnull.h"
 #include "sysemu/runstate.h"
 #include "migration/colo.h"
+#include "migration/cpr.h"
 #include "migration/misc.h"
 #include "migration.h"
 #include "migration-stats.h"
@@ -758,8 +759,12 @@ uint64_t migrate_max_postcopy_bandwidth(void)
 
 MigMode migrate_mode(void)
 {
-    MigrationState *s = migrate_get_current();
-    MigMode mode = s->parameters.mode;
+    MigMode mode = cpr_get_incoming_mode();
+
+    if (mode == MIG_MODE_NONE) {
+        MigrationState *s = migrate_get_current();
+        mode = s->parameters.mode;
+    }
 
     assert(mode >= 0 && mode < MIG_MODE__MAX);
     return mode;
-- 
1.8.3.1



  parent reply	other threads:[~2024-06-30 19:41 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-30 19:40 [PATCH V2 00/11] Live update: cpr-exec Steve Sistare
2024-06-30 19:40 ` [PATCH V2 01/11] machine: alloc-anon option Steve Sistare
2024-07-15 17:52   ` Fabiano Rosas
2024-07-16  9:19   ` Igor Mammedov
2024-07-17 19:24     ` Peter Xu
2024-07-18 15:43       ` Steven Sistare
2024-07-18 16:22         ` Peter Xu
2024-07-20 20:35       ` Steven Sistare
2024-08-04 16:20         ` Peter Xu
2024-07-20 20:28     ` Steven Sistare
2024-07-22  9:10       ` David Hildenbrand
2024-07-29 12:29       ` Igor Mammedov
2024-08-08 18:32         ` Steven Sistare
2024-08-12 18:37           ` Steven Sistare
2024-08-13 15:35             ` Peter Xu
2024-08-13 17:00               ` Alex Williamson
2024-08-13 18:45                 ` Peter Xu
2024-08-13 18:56                   ` Steven Sistare
2024-08-13 18:46                 ` Steven Sistare
2024-08-13 18:49                   ` Steven Sistare
2024-08-13 17:34               ` Steven Sistare
2024-08-13 19:02                 ` Peter Xu
2024-06-30 19:40 ` [PATCH V2 02/11] migration: cpr-state Steve Sistare
2024-07-17 18:39   ` Fabiano Rosas
2024-07-19 15:03   ` Peter Xu
2024-07-20 19:53     ` Steven Sistare
2024-06-30 19:40 ` Steve Sistare [this message]
2024-07-17 18:39   ` [PATCH V2 03/11] migration: save cpr mode Fabiano Rosas
2024-07-18 15:47     ` Steven Sistare
2024-06-30 19:40 ` [PATCH V2 04/11] migration: stop vm earlier for cpr Steve Sistare
2024-07-17 18:59   ` Fabiano Rosas
2024-07-20 20:00     ` Steven Sistare
2024-07-22 13:42       ` Fabiano Rosas
2024-08-06 20:52         ` Steven Sistare
2024-06-30 19:40 ` [PATCH V2 05/11] physmem: preserve ram blocks " Steve Sistare
2024-06-30 19:40 ` [PATCH V2 06/11] migration: fix mismatched GPAs during cpr Steve Sistare
2024-07-19 16:28   ` Peter Xu
2024-07-20 21:28     ` Steven Sistare
2024-08-07 21:04     ` Steven Sistare
2024-08-13 20:43       ` Peter Xu
2024-08-15 20:54         ` Steven Sistare
2024-08-16 14:43           ` Peter Xu
2024-08-16 17:10             ` Steven Sistare
2024-08-21 16:57               ` Peter Xu
2024-06-30 19:40 ` [PATCH V2 07/11] oslib: qemu_clear_cloexec Steve Sistare
2024-06-30 19:40 ` [PATCH V2 08/11] vl: helper to request exec Steve Sistare
2024-06-30 19:40 ` [PATCH V2 09/11] migration: cpr-exec-command parameter Steve Sistare
2024-06-30 19:40 ` [PATCH V2 10/11] migration: cpr-exec save and load Steve Sistare
2024-06-30 19:40 ` [PATCH V2 11/11] migration: cpr-exec mode Steve Sistare
2024-07-18 15:56 ` [PATCH V2 00/11] Live update: cpr-exec Peter Xu
2024-07-20 21:26   ` Steven Sistare
2024-08-04 16:10     ` Peter Xu
2024-08-07 19:47       ` Steven Sistare
2024-08-13 20:12         ` Peter Xu
2024-08-20 16:28           ` [PATCH V2 00/11] Live update: cpr-exec (reconnections) Steven Sistare
2024-07-22  8:59   ` [PATCH V2 00/11] Live update: cpr-exec David Hildenbrand
2024-08-04 15:43     ` Peter Xu
2024-08-05  9:52       ` David Hildenbrand
2024-08-05 10:06         ` David Hildenbrand
2024-08-05 10:01   ` Daniel P. Berrangé
2024-08-06 20:56     ` Steven Sistare
2024-08-13 19:46       ` Peter Xu
2024-08-15 20:55         ` Steven Sistare
2024-08-16 15:06           ` Peter Xu
2024-08-16 15:16             ` Daniel P. Berrangé
2024-08-16 15:19               ` Steven Sistare
2024-08-16 15:34               ` Peter Xu
2024-08-16 16:00                 ` Daniel P. Berrangé
2024-08-16 16:17                   ` Peter Xu
2024-08-16 16:28                     ` Daniel P. Berrangé
2024-08-16 17:09                     ` Steven Sistare
2024-08-21 18:34                       ` Peter Xu
2024-09-04 20:58                         ` Steven Sistare
2024-09-04 22:23                           ` Peter Xu
2024-09-05  9:49                             ` Daniel P. Berrangé
2024-09-05  9:43                           ` Daniel P. Berrangé
2024-09-05  9:30                       ` Daniel P. Berrangé

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=1719776434-435013-4-git-send-email-steven.sistare@oracle.com \
    --to=steven.sistare@oracle.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=david@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=farosas@suse.de \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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).