From: David Hildenbrand <david@redhat.com>
To: qemu-devel@nongnu.org
Cc: David Hildenbrand <david@redhat.com>,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
Juan Quintela <quintela@redhat.com>, Peter Xu <peterx@redhat.com>,
"Michael S . Tsirkin" <mst@redhat.com>,
Michal Privoznik <mprivozn@redhat.com>
Subject: [PATCH v3 3/6] migration: Factor out checks for advised and listening incomming postcopy
Date: Thu, 22 Dec 2022 12:02:12 +0100 [thread overview]
Message-ID: <20221222110215.130392-4-david@redhat.com> (raw)
In-Reply-To: <20221222110215.130392-1-david@redhat.com>
Let's factor out both checks, to be used in virtio-mem context next.
While at it, fix a spelling error in a related comment.
Signed-off-by: David Hildenbrand <david@redhat.com>
---
include/migration/misc.h | 6 +++++-
migration/migration.c | 14 ++++++++++++++
migration/ram.c | 16 ++--------------
3 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/include/migration/misc.h b/include/migration/misc.h
index 465906710d..c7e67a6804 100644
--- a/include/migration/misc.h
+++ b/include/migration/misc.h
@@ -67,8 +67,12 @@ bool migration_has_failed(MigrationState *);
/* ...and after the device transmission */
bool migration_in_postcopy_after_devices(MigrationState *);
void migration_global_dump(Monitor *mon);
-/* True if incomming migration entered POSTCOPY_INCOMING_DISCARD */
+/* True if incoming migration entered POSTCOPY_INCOMING_DISCARD */
bool migration_in_incoming_postcopy(void);
+/* True if incoming migration entered POSTCOPY_INCOMING_ADVISE */
+bool migration_incoming_postcopy_advised(void);
+/* True if incoming migration entered POSTCOPY_INCOMING_LISTENING */
+bool migration_incoming_postcopy_listening(void);
/* True if background snapshot is active */
bool migration_in_bg_snapshot(void);
diff --git a/migration/migration.c b/migration/migration.c
index 78b6bb8765..7a69bb93b0 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -2094,6 +2094,20 @@ bool migration_in_incoming_postcopy(void)
return ps >= POSTCOPY_INCOMING_DISCARD && ps < POSTCOPY_INCOMING_END;
}
+bool migration_incoming_postcopy_advised(void)
+{
+ PostcopyState ps = postcopy_state_get();
+
+ return ps >= POSTCOPY_INCOMING_ADVISE && ps < POSTCOPY_INCOMING_END;
+}
+
+bool migration_incoming_postcopy_listening(void)
+{
+ PostcopyState ps = postcopy_state_get();
+
+ return ps >= POSTCOPY_INCOMING_LISTENING && ps < POSTCOPY_INCOMING_END;
+}
+
bool migration_in_bg_snapshot(void)
{
MigrationState *s = migrate_get_current();
diff --git a/migration/ram.c b/migration/ram.c
index 334309f1c6..44b063eccd 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -4091,18 +4091,6 @@ int ram_load_postcopy(QEMUFile *f, int channel)
return ret;
}
-static bool postcopy_is_advised(void)
-{
- PostcopyState ps = postcopy_state_get();
- return ps >= POSTCOPY_INCOMING_ADVISE && ps < POSTCOPY_INCOMING_END;
-}
-
-static bool postcopy_is_running(void)
-{
- PostcopyState ps = postcopy_state_get();
- return ps >= POSTCOPY_INCOMING_LISTENING && ps < POSTCOPY_INCOMING_END;
-}
-
/*
* Flush content of RAM cache into SVM's memory.
* Only flush the pages that be dirtied by PVM or SVM or both.
@@ -4167,7 +4155,7 @@ static int ram_load_precopy(QEMUFile *f)
MigrationIncomingState *mis = migration_incoming_get_current();
int flags = 0, ret = 0, invalid_flags = 0, len = 0, i = 0;
/* ADVISE is earlier, it shows the source has the postcopy capability on */
- bool postcopy_advised = postcopy_is_advised();
+ bool postcopy_advised = migration_incoming_postcopy_advised();
if (!migrate_use_compression()) {
invalid_flags |= RAM_SAVE_FLAG_COMPRESS_PAGE;
}
@@ -4365,7 +4353,7 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
* If system is running in postcopy mode, page inserts to host memory must
* be atomic
*/
- bool postcopy_running = postcopy_is_running();
+ bool postcopy_running = migration_incoming_postcopy_listening();
seq_iter++;
--
2.38.1
next prev parent reply other threads:[~2022-12-22 11:11 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-22 11:02 [PATCH v3 0/6] virtio-mem: Handle preallocation with migration David Hildenbrand
2022-12-22 11:02 ` [PATCH v3 1/6] migration: Allow immutable device state to be migrated early (i.e., before RAM) David Hildenbrand
2022-12-23 9:34 ` David Hildenbrand
2023-01-05 1:27 ` Michael S. Tsirkin
2023-01-05 8:20 ` David Hildenbrand
2023-01-04 17:23 ` Peter Xu
2023-01-05 8:35 ` David Hildenbrand
2023-01-05 17:15 ` Peter Xu
2023-01-09 14:34 ` David Hildenbrand
2023-01-09 19:54 ` Peter Xu
2023-01-10 10:18 ` David Hildenbrand
2023-01-10 11:52 ` David Hildenbrand
2023-01-10 20:03 ` Peter Xu
2023-01-11 13:48 ` David Hildenbrand
2023-01-11 16:35 ` Peter Xu
2023-01-11 16:58 ` David Hildenbrand
2023-01-11 17:28 ` Peter Xu
2023-01-11 17:44 ` David Hildenbrand
2022-12-22 11:02 ` [PATCH v3 2/6] migration/vmstate: Introduce VMSTATE_WITH_TMP_TEST() and VMSTATE_BITMAP_TEST() David Hildenbrand
2023-01-05 17:33 ` Dr. David Alan Gilbert
2022-12-22 11:02 ` David Hildenbrand [this message]
2023-01-05 17:18 ` [PATCH v3 3/6] migration: Factor out checks for advised and listening incomming postcopy Peter Xu
2023-01-09 14:39 ` David Hildenbrand
2023-01-09 14:42 ` David Hildenbrand
2022-12-22 11:02 ` [PATCH v3 4/6] virtio-mem: Fail if a memory backend with "prealloc=on" is specified David Hildenbrand
2022-12-22 11:02 ` [PATCH v3 5/6] virtio-mem: Migrate bitmap, size and sanity checks early David Hildenbrand
2022-12-22 11:02 ` [PATCH v3 6/6] virtio-mem: Proper support for preallocation with migration David Hildenbrand
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=20221222110215.130392-4-david@redhat.com \
--to=david@redhat.com \
--cc=dgilbert@redhat.com \
--cc=mprivozn@redhat.com \
--cc=mst@redhat.com \
--cc=peterx@redhat.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 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).