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>,
"Thomas Huth" <thuth@redhat.com>,
"Laurent Vivier" <lvivier@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [PATCH v3 2/6] tests/qtest: migration: Add migrate_incoming_qmp helper
Date: Fri, 30 Jun 2023 18:28:58 -0300 [thread overview]
Message-ID: <20230630212902.19925-3-farosas@suse.de> (raw)
In-Reply-To: <20230630212902.19925-1-farosas@suse.de>
file-based migration requires the target to initiate its migration after
the source has finished writing out the data in the file. Currently
there's no easy way to initiate 'migrate-incoming', allow this by
introducing migrate_incoming_qmp helper, similarly to migrate_qmp.
Also make sure migration events are enabled and wait for the incoming
migration to start before returning. This avoid a race when querying
the migration status too soon after issuing the command.
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
tests/qtest/migration-helpers.c | 29 +++++++++++++++++++++++++++++
tests/qtest/migration-helpers.h | 4 ++++
2 files changed, 33 insertions(+)
diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.c
index 2df198c99e..08f5ee1179 100644
--- a/tests/qtest/migration-helpers.c
+++ b/tests/qtest/migration-helpers.c
@@ -81,6 +81,35 @@ void migrate_set_capability(QTestState *who, const char *capability,
capability, value);
}
+void migrate_incoming_qmp(QTestState *to, const char *uri, const char *fmt, ...)
+{
+ va_list ap;
+ QDict *args, *rsp, *data;
+
+ va_start(ap, fmt);
+ args = qdict_from_vjsonf_nofail(fmt, ap);
+ va_end(ap);
+
+ g_assert(!qdict_haskey(args, "uri"));
+ qdict_put_str(args, "uri", uri);
+
+ migrate_set_capability(to, "events", true);
+
+ rsp = qtest_qmp(to, "{ 'execute': 'migrate-incoming', 'arguments': %p}",
+ args);
+ g_assert(qdict_haskey(rsp, "return"));
+ qobject_unref(rsp);
+
+ rsp = qtest_qmp_eventwait_ref(to, "MIGRATION");
+ g_assert(qdict_haskey(rsp, "data"));
+
+ data = qdict_get_qdict(rsp, "data");
+ g_assert(qdict_haskey(data, "status"));
+ g_assert_cmpstr(qdict_get_str(data, "status"), ==, "setup");
+
+ qobject_unref(rsp);
+}
+
/*
* Note: caller is responsible to free the returned object via
* qobject_unref() after use
diff --git a/tests/qtest/migration-helpers.h b/tests/qtest/migration-helpers.h
index 484d7c960f..57d295a4fe 100644
--- a/tests/qtest/migration-helpers.h
+++ b/tests/qtest/migration-helpers.h
@@ -23,6 +23,10 @@ bool migrate_watch_for_resume(QTestState *who, const char *name,
G_GNUC_PRINTF(3, 4)
void migrate_qmp(QTestState *who, const char *uri, const char *fmt, ...);
+G_GNUC_PRINTF(3, 4)
+void migrate_incoming_qmp(QTestState *who, const char *uri,
+ const char *fmt, ...);
+
void migrate_set_capability(QTestState *who, const char *capability,
bool value);
--
2.35.3
next prev parent reply other threads:[~2023-06-30 21:30 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-30 21:28 [PATCH v3 0/6] migration: Test the new "file:" migration Fabiano Rosas
2023-06-30 21:28 ` [PATCH v3 1/6] tests/qtest: migration: Expose migrate_set_capability Fabiano Rosas
2023-07-06 18:39 ` Peter Xu
2023-06-30 21:28 ` Fabiano Rosas [this message]
2023-07-06 18:38 ` [PATCH v3 2/6] tests/qtest: migration: Add migrate_incoming_qmp helper Peter Xu
2023-06-30 21:28 ` [PATCH v3 3/6] tests/qtest: migration: Use migrate_incoming_qmp where appropriate Fabiano Rosas
2023-07-06 18:38 ` Peter Xu
2023-06-30 21:29 ` [PATCH v3 4/6] migration: Set migration status early in incoming side Fabiano Rosas
2023-07-06 18:40 ` Peter Xu
2023-06-30 21:29 ` [PATCH v3 5/6] tests/qtest: migration: Add support for negative testing of qmp_migrate Fabiano Rosas
2023-07-06 18:49 ` Peter Xu
2023-06-30 21:29 ` [PATCH v3 6/6] tests/qtest: migration-test: Add tests for file-based migration Fabiano Rosas
2023-07-06 18:49 ` Peter Xu
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=20230630212902.19925-3-farosas@suse.de \
--to=farosas@suse.de \
--cc=berrange@redhat.com \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=steven.sistare@oracle.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).