From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>, passt-dev@passt.top
Cc: David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH 4/6] migrate: Handle sending header section from data sections
Date: Mon, 3 Feb 2025 20:26:13 +1100 [thread overview]
Message-ID: <20250203092615.500163-5-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20250203092615.500163-1-david@gibson.dropbear.id.au>
Currently the global state header is included in the list of data sections
to send for migration. This makes for an asymmetry between the source and
target sides: for the source, the header is sent after the 'pre' handlers
along with all the rest of the data. For the target side, the header must
be read first (before the 'pre' handlers), so that we know the version
which determines what all the rest of the data will be.
Change this so that the header is handled explicitly on both the source and
target side. This will make some future changes simpler as well.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
migrate.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/migrate.c b/migrate.c
index 2d9f77ef..025f3b71 100644
--- a/migrate.c
+++ b/migrate.c
@@ -50,7 +50,6 @@ static union migrate_header header = {
/* Data sections for version 1 */
static struct iovec sections_v1[] = {
- { &header, sizeof(header) },
{ &flow_first_free, sizeof(flow_first_free) },
{ flowtab, sizeof(flowtab) },
{ flow_hashtab, sizeof(flow_hashtab) },
@@ -172,6 +171,12 @@ static int migrate_source(struct ctx *c, int fd)
struct migrate_meta m;
int rc;
+ rc = write_all_buf(fd, &header, sizeof(header));
+ if (rc) {
+ err("Failed to send migration header: %s, abort", strerror_(rc));
+ return rc;
+ }
+
if ((rc = migrate_source_pre(c, &m))) {
err("Source pre-migration failed: %s, abort", strerror_(rc));
return rc;
@@ -279,10 +284,10 @@ static int migrate_target_state(int fd, const struct migrate_meta *m)
for (d = data_versions; d->v != m->v && d->v; d++);
- for (cnt = 0; d->sections[cnt + 1 /* skip header */].iov_len; cnt++);
+ for (cnt = 0; d->sections[cnt].iov_len; cnt++);
debug("Reading %u migration sections", cnt);
- rc = read_remainder(fd, d->sections + 1, cnt, 0);
+ rc = read_remainder(fd, d->sections, cnt, 0);
if (rc < 0)
return errno;
--
@@ -50,7 +50,6 @@ static union migrate_header header = {
/* Data sections for version 1 */
static struct iovec sections_v1[] = {
- { &header, sizeof(header) },
{ &flow_first_free, sizeof(flow_first_free) },
{ flowtab, sizeof(flowtab) },
{ flow_hashtab, sizeof(flow_hashtab) },
@@ -172,6 +171,12 @@ static int migrate_source(struct ctx *c, int fd)
struct migrate_meta m;
int rc;
+ rc = write_all_buf(fd, &header, sizeof(header));
+ if (rc) {
+ err("Failed to send migration header: %s, abort", strerror_(rc));
+ return rc;
+ }
+
if ((rc = migrate_source_pre(c, &m))) {
err("Source pre-migration failed: %s, abort", strerror_(rc));
return rc;
@@ -279,10 +284,10 @@ static int migrate_target_state(int fd, const struct migrate_meta *m)
for (d = data_versions; d->v != m->v && d->v; d++);
- for (cnt = 0; d->sections[cnt + 1 /* skip header */].iov_len; cnt++);
+ for (cnt = 0; d->sections[cnt].iov_len; cnt++);
debug("Reading %u migration sections", cnt);
- rc = read_remainder(fd, d->sections + 1, cnt, 0);
+ rc = read_remainder(fd, d->sections, cnt, 0);
if (rc < 0)
return errno;
--
2.48.1
next prev parent reply other threads:[~2025-02-03 9:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-03 9:26 [PATCH 0/6] More migration improvements David Gibson
2025-02-03 9:26 ` [PATCH 1/6] vhost-user: Change different vhost-user messages to trace() level David Gibson
2025-02-04 0:42 ` Stefano Brivio
2025-02-03 9:26 ` [PATCH 2/6] migrate, flow: Abort migration on repair_flush() failure David Gibson
2025-02-03 9:26 ` [PATCH 3/6] migrate: Clearer debug message in migrate_request() David Gibson
2025-02-03 9:26 ` David Gibson [this message]
2025-02-03 9:26 ` [PATCH 5/6] util: read_remainder should take const pointer to iovec David Gibson
2025-02-04 0:42 ` Stefano Brivio
2025-02-03 9:26 ` [PATCH 6/6] migrate: Make migration handlers simpler and more flexible David Gibson
2025-02-03 10:20 ` Stefano Brivio
2025-02-03 23:55 ` David Gibson
2025-02-04 0:12 ` Stefano Brivio
2025-02-04 3:36 ` David Gibson
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=20250203092615.500163-5-david@gibson.dropbear.id.au \
--to=david@gibson.dropbear.id.au \
--cc=passt-dev@passt.top \
--cc=sbrivio@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.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
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 IMAP folder(s).