From: Denis V. Lunev <[email protected]> Add /migration/mode/exec/numa. The source VM has a memory backend bound to host node 0 and the exec'd QEMU asks for host node 127 on the same backend. mbind() rejects that node just as it rejects one the cpuset dropped while the VM ran, so the new QEMU survives only if it leaves the inherited memory alone. This reproduces the failure without root or a cgroup.
set_cpr_exec_args() now uses opts_target, unused by cpr-exec tests so far, as the options of the exec'd QEMU. Signed-off-by: Denis V. Lunev <[email protected]> Cc: "Maciej S. Szmigiero" <[email protected]> Cc: Peter Xu <[email protected]> Cc: Fabiano Rosas <[email protected]> Cc: Mark Kanda <[email protected]> Cc: Ben Chaney <[email protected]> Cc: Steve Sistare <[email protected]> Cc: Laurent Vivier <[email protected]> Cc: Paolo Bonzini <[email protected]> --- tests/qtest/migration/cpr-tests.c | 38 ++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/tests/qtest/migration/cpr-tests.c b/tests/qtest/migration/cpr-tests.c index 0bec753b4a..9217783659 100644 --- a/tests/qtest/migration/cpr-tests.c +++ b/tests/qtest/migration/cpr-tests.c @@ -169,6 +169,7 @@ static void set_cpr_exec_args(QTestState *who, MigrateCommon *args) g_autofree char *to_args = NULL; g_autofree char *exec_args = NULL; g_auto(GStrv) argv = NULL; + MigrateStart start = args->start; char *from_str, *src, *dst; int ret; @@ -179,7 +180,11 @@ static void set_cpr_exec_args(QTestState *who, MigrateCommon *args) */ g_assert(args->start.hide_stderr == false); - ret = migrate_args(&from_args, &to_args, &args->start); + /* opts_target, if set, replaces opts_source for the exec'd QEMU */ + if (start.opts_target) { + start.opts_source = start.opts_target; + } + ret = migrate_args(&from_args, &to_args, &start); g_assert(!ret); qtest_from_args = qtest_qemu_args(from_args); @@ -276,7 +281,8 @@ static void *test_mode_exec_start(QTestState *from, QTestState *to) return NULL; } -static void test_mode_exec(char *name, MigrateCommon *args) +static void test_mode_exec_common(MigrateCommon *args, const char *opts_source, + const char *opts_target) { g_autofree char *uri = g_strdup_printf("file:%s/%s", tmpfs, FILE_TEST_FILENAME); @@ -284,12 +290,35 @@ static void test_mode_exec(char *name, MigrateCommon *args) args->start_hook = test_mode_exec_start; args->start.only_source = true; - args->start.opts_source = "-machine aux-ram-share=on -nodefaults"; + args->start.opts_source = opts_source; + args->start.opts_target = opts_target; args->start.mem_type = MEM_TYPE_MEMFD; test_cpr_exec(args); } +static void test_mode_exec(char *name, MigrateCommon *args) +{ + test_mode_exec_common(args, "-machine aux-ram-share=on -nodefaults", NULL); +} + +#ifdef CONFIG_NUMA +/* + * mbind() rejects host node 127 as it would a node the cpuset dropped + * while the VM ran. + */ +static void test_mode_exec_numa(char *name, MigrateCommon *args) +{ + test_mode_exec_common(args, + "-machine aux-ram-share=on -nodefaults " + "-object memory-backend-memfd,id=numa0,size=2M," + "policy=bind,host-nodes=0", + "-machine aux-ram-share=on -nodefaults " + "-object memory-backend-memfd,id=numa0,size=2M," + "policy=bind,host-nodes=127"); +} +#endif + void migration_test_add_cpr(MigrationTestEnv *env) { tmpfs = env->tmpfs; @@ -313,5 +342,8 @@ void migration_test_add_cpr(MigrationTestEnv *env) migration_test_add("/migration/mode/transfer/defer", test_mode_transfer_defer); migration_test_add("/migration/mode/exec", test_mode_exec); +#ifdef CONFIG_NUMA + migration_test_add("/migration/mode/exec/numa", test_mode_exec_numa); +#endif } } -- 2.53.0
