Skip to content

Commit 3dec966

Browse files
JurajMarcinFabiano Rosas
authored andcommitted
tests/qtest/migration: Use out-of-band execution for migrate-recover
In real use cases, the migrate-recover command requires out-of-band execution, because the thread processing normal commands is blocked by a page fault in the guest memory. With this change, the tests will be closer to real use cases and could help detect regressions and other bugs in migration recovery. Signed-off-by: Juraj Marcin <jmarcin@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com> Signed-off-by: Fabiano Rosas <farosas@suse.de>
1 parent 99baa5d commit 3dec966

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

tests/qtest/migration/framework.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,16 @@ static void cleanup(const char *filename)
194194
unlink(path);
195195
}
196196

197+
static QList *migrate_start_get_qmp_capabilities(const MigrateStart *args)
198+
{
199+
QList *capabilities = qlist_new();
200+
201+
if (args->oob) {
202+
qlist_append_str(capabilities, "oob");
203+
}
204+
return capabilities;
205+
}
206+
197207
int migrate_start(QTestState **from, QTestState **to, const char *uri,
198208
MigrateStart *args)
199209
{
@@ -210,6 +220,7 @@ int migrate_start(QTestState **from, QTestState **to, const char *uri,
210220
const char *machine_alias, *machine_opts = "";
211221
g_autofree char *machine = NULL;
212222
const char *bootpath;
223+
g_autoptr(QList) capabilities = migrate_start_get_qmp_capabilities(args);
213224

214225
if (args->use_shmem) {
215226
if (!g_file_test("/dev/shm", G_FILE_TEST_IS_DIR)) {
@@ -314,7 +325,8 @@ int migrate_start(QTestState **from, QTestState **to, const char *uri,
314325
args->opts_source ? args->opts_source : "",
315326
ignore_stderr);
316327
if (!args->only_target) {
317-
*from = qtest_init_with_env(QEMU_ENV_SRC, cmd_source);
328+
*from = qtest_init_with_env_and_capabilities(QEMU_ENV_SRC, cmd_source,
329+
capabilities);
318330
qtest_qmp_set_event_callback(*from,
319331
migrate_watch_for_events,
320332
&src_state);
@@ -334,7 +346,8 @@ int migrate_start(QTestState **from, QTestState **to, const char *uri,
334346
shmem_opts ? shmem_opts : "",
335347
args->opts_target ? args->opts_target : "",
336348
ignore_stderr);
337-
*to = qtest_init_with_env(QEMU_ENV_DST, cmd_target);
349+
*to = qtest_init_with_env_and_capabilities(QEMU_ENV_DST, cmd_target,
350+
capabilities);
338351
qtest_qmp_set_event_callback(*to,
339352
migrate_watch_for_events,
340353
&dst_state);
@@ -601,6 +614,12 @@ void test_postcopy_recovery_common(MigrateCommon *args)
601614
QTestState *from, *to;
602615
g_autofree char *uri = NULL;
603616

617+
/*
618+
* Always enable OOB QMP capability for recovery tests, migrate-recover is
619+
* executed out-of-band
620+
*/
621+
args->start.oob = true;
622+
604623
/* Always hide errors for postcopy recover tests since they're expected */
605624
args->start.hide_stderr = true;
606625

tests/qtest/migration/framework.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ typedef struct {
109109
const char *opts_target;
110110
/* suspend the src before migrating to dest. */
111111
bool suspend_me;
112+
/* enable OOB QMP capability */
113+
bool oob;
112114
} MigrateStart;
113115

114116
typedef enum PostcopyRecoveryFailStage {

tests/qtest/migration/migration-qmp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ void migrate_continue(QTestState *who, const char *state)
464464
void migrate_recover(QTestState *who, const char *uri)
465465
{
466466
qtest_qmp_assert_success(who,
467-
"{ 'execute': 'migrate-recover', "
467+
"{ 'exec-oob': 'migrate-recover', "
468468
" 'id': 'recover-cmd', "
469469
" 'arguments': { 'uri': %s } }",
470470
uri);

0 commit comments

Comments
 (0)