Peter Xu <pet...@redhat.com> writes: > On Wed, Jun 28, 2023 at 01:55:39PM -0300, Fabiano Rosas wrote: >> 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 <faro...@suse.de> >> --- >> tests/qtest/migration-helpers.c | 28 ++++++++++++++++++++++++++++ >> tests/qtest/migration-helpers.h | 4 ++++ >> 2 files changed, 32 insertions(+) >> >> diff --git a/tests/qtest/migration-helpers.c >> b/tests/qtest/migration-helpers.c >> index 2df198c99e..bc54b29184 100644 >> --- a/tests/qtest/migration-helpers.c >> +++ b/tests/qtest/migration-helpers.c >> @@ -81,6 +81,34 @@ 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")); > > rsp leaked? >
Good catch. I'll fix it.