qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fabiano Rosas <farosas@suse.de>
To: qemu-devel@nongnu.org
Cc: "Juan Quintela" <quintela@redhat.com>,
	"Peter Xu" <peterx@redhat.com>,
	"Steve Sistare" <steven.sistare@oracle.com>,
	"Daniel P . Berrangé" <berrange@redhat.com>,
	"Leonardo Bras" <leobras@redhat.com>
Subject: [PATCH 1/6] migration: Set migration status early in incoming side
Date: Mon, 26 Jun 2023 15:22:05 -0300	[thread overview]
Message-ID: <20230626182210.8792-2-farosas@suse.de> (raw)
In-Reply-To: <20230626182210.8792-1-farosas@suse.de>

We are sending a migration event of MIGRATION_STATUS_SETUP at
qemu_start_incoming_migration but never actually setting the state.

This creates a window between qmp_migrate_incoming and
process_incoming_migration_co where the migration status is still
MIGRATION_STATUS_NONE. Calling query-migrate during this time will
return an empty response even though the incoming migration command
has already been issued.

Commit 7cf1fe6d68 ("migration: Add migration events on target side")
has added support to the 'events' capability to the incoming part of
migration, but chose to send the SETUP event without setting the
state. I'm assuming this was a mistake.

To avoid introducing a change in behavior, we need to keep sending the
SETUP event, even if the 'events' capability is not set.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
 migration/migration.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/migration/migration.c b/migration/migration.c
index 7c8292d4d4..562b78261d 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -424,13 +424,26 @@ void migrate_add_address(SocketAddress *address)
 static void qemu_start_incoming_migration(const char *uri, Error **errp)
 {
     const char *p = NULL;
+    MigrationIncomingState *mis = migration_incoming_get_current();
 
     /* URI is not suitable for migration? */
     if (!migration_channels_and_uri_compatible(uri, errp)) {
         return;
     }
 
-    qapi_event_send_migration(MIGRATION_STATUS_SETUP);
+    migrate_set_state(&mis->state, MIGRATION_STATUS_NONE,
+                      MIGRATION_STATUS_SETUP);
+    /*
+     * QMP clients should have set the 'events' migration capability
+     * if they want to receive this event, in which case the
+     * migrate_set_state() call above will have already sent the
+     * event. We still need to send the event for compatibility even
+     * if migration events are disabled.
+     */
+    if (!migrate_events()) {
+        qapi_event_send_migration(MIGRATION_STATUS_SETUP);
+    }
+
     if (strstart(uri, "tcp:", &p) ||
         strstart(uri, "unix:", NULL) ||
         strstart(uri, "vsock:", NULL)) {
@@ -524,7 +537,7 @@ process_incoming_migration_co(void *opaque)
 
     mis->largest_page_size = qemu_ram_pagesize_largest();
     postcopy_state_set(POSTCOPY_INCOMING_NONE);
-    migrate_set_state(&mis->state, MIGRATION_STATUS_NONE,
+    migrate_set_state(&mis->state, MIGRATION_STATUS_SETUP,
                       MIGRATION_STATUS_ACTIVE);
 
     mis->loadvm_co = qemu_coroutine_self();
-- 
2.35.3



  reply	other threads:[~2023-06-26 18:23 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-26 18:22 [PATCH 0/6] migration: Test the new "file:" migration Fabiano Rosas
2023-06-26 18:22 ` Fabiano Rosas [this message]
2023-06-27  9:11   ` [PATCH 1/6] migration: Set migration status early in incoming side Juan Quintela
2023-06-27 12:36     ` Fabiano Rosas
2023-06-26 18:22 ` [PATCH 2/6] tests/qtest: migration: Expose migrate_set_capability Fabiano Rosas
2023-06-27  9:12   ` Juan Quintela
2023-06-26 18:22 ` [PATCH 3/6] tests/qtest: migration: Add migrate_incoming_qmp helper Fabiano Rosas
2023-06-26 18:22 ` [PATCH 4/6] tests/qtest: migration: Use migrate_incoming_qmp where appropriate Fabiano Rosas
2023-06-27  9:13   ` Juan Quintela
2023-06-26 18:22 ` [PATCH 5/6] tests/qtest: migration: Add support for negative testing of qmp_migrate Fabiano Rosas
2023-06-26 18:22 ` [PATCH 6/6] tests/qtest: migration-test: Add tests for file-based migration Fabiano Rosas
2023-06-27  9:07   ` Daniel P. Berrangé
2023-06-27 12:54     ` Fabiano Rosas
  -- strict thread matches above, loose matches on Subject: below --
2023-06-28 16:55 [PATCH 0/6] migration: Test the new "file:" migration Fabiano Rosas
2023-06-28 16:55 ` [PATCH 1/6] migration: Set migration status early in incoming side Fabiano Rosas
2023-06-29 19:18   ` Peter Xu
2023-06-30 14:57     ` Fabiano Rosas

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=20230626182210.8792-2-farosas@suse.de \
    --to=farosas@suse.de \
    --cc=berrange@redhat.com \
    --cc=leobras@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=steven.sistare@oracle.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).