From 8443415f9a09b6d95d99f02733eb71ac4f2d574d Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Thu, 12 Dec 2019 23:20:24 +0100 Subject: migration-test: Create cmd_soure and cmd_target We are repeating almost everything for each machine while creating the command line for migration. And once for source and another for destination. We start putting there opts_src and opts_dst. Signed-off-by: Juan Quintela Tested-by: Cornelia Huck #s390x Tested-by: Laurent Vivier --- tests/migration-test.c | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) (limited to 'tests') diff --git a/tests/migration-test.c b/tests/migration-test.c index a5343fd..fbddcf2 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -557,6 +557,7 @@ static int test_migrate_start(QTestState **from, QTestState **to, const char *opts_dst) { gchar *cmd_src, *cmd_dst; + gchar *cmd_source, *cmd_target; char *bootpath = NULL; char *extra_opts = NULL; char *shmem_path = NULL; @@ -584,16 +585,16 @@ static int test_migrate_start(QTestState **from, QTestState **to, cmd_src = g_strdup_printf("-machine accel=%s -m 150M" " -name source,debug-threads=on" " -serial file:%s/src_serial" - " -drive file=%s,format=raw %s %s", + " -drive file=%s,format=raw %s", accel, tmpfs, bootpath, - extra_opts ? extra_opts : "", opts_src); + extra_opts ? extra_opts : ""); cmd_dst = g_strdup_printf("-machine accel=%s -m 150M" " -name target,debug-threads=on" " -serial file:%s/dest_serial" " -drive file=%s,format=raw" - " -incoming %s %s %s", + " -incoming %s %s", accel, tmpfs, bootpath, uri, - extra_opts ? extra_opts : "", opts_dst); + extra_opts ? extra_opts : ""); start_address = X86_TEST_MEM_START; end_address = X86_TEST_MEM_END; } else if (g_str_equal(arch, "s390x")) { @@ -601,15 +602,15 @@ static int test_migrate_start(QTestState **from, QTestState **to, extra_opts = use_shmem ? get_shmem_opts("128M", shmem_path) : NULL; cmd_src = g_strdup_printf("-machine accel=%s -m 128M" " -name source,debug-threads=on" - " -serial file:%s/src_serial -bios %s %s %s", + " -serial file:%s/src_serial -bios %s %s", accel, tmpfs, bootpath, - extra_opts ? extra_opts : "", opts_src); + extra_opts ? extra_opts : ""); cmd_dst = g_strdup_printf("-machine accel=%s -m 128M" " -name target,debug-threads=on" " -serial file:%s/dest_serial -bios %s" - " -incoming %s %s %s", + " -incoming %s %s", accel, tmpfs, bootpath, uri, - extra_opts ? extra_opts : "", opts_dst); + extra_opts ? extra_opts : ""); start_address = S390_TEST_MEM_START; end_address = S390_TEST_MEM_END; } else if (strcmp(arch, "ppc64") == 0) { @@ -620,15 +621,14 @@ static int test_migrate_start(QTestState **from, QTestState **to, " -prom-env 'use-nvramrc?=true' -prom-env " "'nvramrc=hex .\" _\" begin %x %x " "do i c@ 1 + i c! 1000 +loop .\" B\" 0 " - "until' %s %s", accel, tmpfs, end_address, - start_address, extra_opts ? extra_opts : "", - opts_src); + "until' %s", accel, tmpfs, end_address, + start_address, extra_opts ? extra_opts : ""); cmd_dst = g_strdup_printf("-machine accel=%s,vsmt=8 -m 256M" " -name target,debug-threads=on" " -serial file:%s/dest_serial" - " -incoming %s %s %s", + " -incoming %s %s", accel, tmpfs, uri, - extra_opts ? extra_opts : "", opts_dst); + extra_opts ? extra_opts : ""); start_address = PPC_TEST_MEM_START; end_address = PPC_TEST_MEM_END; @@ -638,16 +638,16 @@ static int test_migrate_start(QTestState **from, QTestState **to, cmd_src = g_strdup_printf("-machine virt,accel=%s,gic-version=max " "-name vmsource,debug-threads=on -cpu max " "-m 150M -serial file:%s/src_serial " - "-kernel %s %s %s", + "-kernel %s %s", accel, tmpfs, bootpath, - extra_opts ? extra_opts : "", opts_src); + extra_opts ? extra_opts : ""); cmd_dst = g_strdup_printf("-machine virt,accel=%s,gic-version=max " "-name vmdest,debug-threads=on -cpu max " "-m 150M -serial file:%s/dest_serial " "-kernel %s " - "-incoming %s %s %s", + "-incoming %s %s", accel, tmpfs, bootpath, uri, - extra_opts ? extra_opts : "", opts_dst); + extra_opts ? extra_opts : ""); start_address = ARM_TEST_MEM_START; end_address = ARM_TEST_MEM_END; @@ -671,11 +671,17 @@ static int test_migrate_start(QTestState **from, QTestState **to, cmd_dst = tmp; } - *from = qtest_init(cmd_src); + cmd_source = g_strdup_printf("%s %s", + cmd_src, opts_src); g_free(cmd_src); + *from = qtest_init(cmd_source); + g_free(cmd_source); - *to = qtest_init(cmd_dst); + cmd_target = g_strdup_printf("%s %s", + cmd_dst, opts_dst); g_free(cmd_dst); + *to = qtest_init(cmd_target); + g_free(cmd_target); /* * Remove shmem file immediately to avoid memory leak in test failed case. -- cgit v1.1 From 1b0237187182f32049831d39c775c93a27a0b3bf Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Thu, 12 Dec 2019 23:20:25 +0100 Subject: migration-test: Move hide_stderr to common commandline Signed-off-by: Juan Quintela Tested-by: Cornelia Huck #s390x Tested-by: Laurent Vivier --- tests/migration-test.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'tests') diff --git a/tests/migration-test.c b/tests/migration-test.c index fbddcf2..0c01ed3 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -558,6 +558,7 @@ static int test_migrate_start(QTestState **from, QTestState **to, { gchar *cmd_src, *cmd_dst; gchar *cmd_source, *cmd_target; + const gchar *ignore_stderr; char *bootpath = NULL; char *extra_opts = NULL; char *shmem_path = NULL; @@ -661,24 +662,19 @@ static int test_migrate_start(QTestState **from, QTestState **to, g_free(extra_opts); if (hide_stderr) { - gchar *tmp; - tmp = g_strdup_printf("%s 2>/dev/null", cmd_src); - g_free(cmd_src); - cmd_src = tmp; - - tmp = g_strdup_printf("%s 2>/dev/null", cmd_dst); - g_free(cmd_dst); - cmd_dst = tmp; + ignore_stderr = "2>/dev/null"; + } else { + ignore_stderr = ""; } - cmd_source = g_strdup_printf("%s %s", - cmd_src, opts_src); + cmd_source = g_strdup_printf("%s %s %s", + cmd_src, opts_src, ignore_stderr); g_free(cmd_src); *from = qtest_init(cmd_source); g_free(cmd_source); - cmd_target = g_strdup_printf("%s %s", - cmd_dst, opts_dst); + cmd_target = g_strdup_printf("%s %s %s", + cmd_dst, opts_dst, ignore_stderr); g_free(cmd_dst); *to = qtest_init(cmd_target); g_free(cmd_target); -- cgit v1.1 From e022c2772e8666d6df8ee4b0b7338e8fd0c3cc6a Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Thu, 12 Dec 2019 23:20:26 +0100 Subject: migration-test: Move -machine to common commandline Signed-off-by: Juan Quintela Tested-by: Cornelia Huck #s390x Tested-by: Laurent Vivier --- tests/migration-test.c | 51 +++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 21 deletions(-) (limited to 'tests') diff --git a/tests/migration-test.c b/tests/migration-test.c index 0c01ed3..5a63158 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -563,7 +563,8 @@ static int test_migrate_start(QTestState **from, QTestState **to, char *extra_opts = NULL; char *shmem_path = NULL; const char *arch = qtest_get_arch(); - const char *accel = "kvm:tcg"; + const char *machine_type; + const char *machine_args; opts_src = opts_src ? opts_src : ""; opts_dst = opts_dst ? opts_dst : ""; @@ -582,72 +583,78 @@ static int test_migrate_start(QTestState **from, QTestState **to, /* the assembled x86 boot sector should be exactly one sector large */ assert(sizeof(x86_bootsect) == 512); init_bootfile(bootpath, x86_bootsect, sizeof(x86_bootsect)); + machine_type = ""; + machine_args = ""; extra_opts = use_shmem ? get_shmem_opts("150M", shmem_path) : NULL; - cmd_src = g_strdup_printf("-machine accel=%s -m 150M" + cmd_src = g_strdup_printf("-m 150M" " -name source,debug-threads=on" " -serial file:%s/src_serial" " -drive file=%s,format=raw %s", - accel, tmpfs, bootpath, + tmpfs, bootpath, extra_opts ? extra_opts : ""); - cmd_dst = g_strdup_printf("-machine accel=%s -m 150M" + cmd_dst = g_strdup_printf("-m 150M" " -name target,debug-threads=on" " -serial file:%s/dest_serial" " -drive file=%s,format=raw" " -incoming %s %s", - accel, tmpfs, bootpath, uri, + tmpfs, bootpath, uri, extra_opts ? extra_opts : ""); start_address = X86_TEST_MEM_START; end_address = X86_TEST_MEM_END; } else if (g_str_equal(arch, "s390x")) { init_bootfile(bootpath, s390x_elf, sizeof(s390x_elf)); + machine_type = ""; + machine_args = ""; extra_opts = use_shmem ? get_shmem_opts("128M", shmem_path) : NULL; - cmd_src = g_strdup_printf("-machine accel=%s -m 128M" + cmd_src = g_strdup_printf("-m 128M" " -name source,debug-threads=on" " -serial file:%s/src_serial -bios %s %s", - accel, tmpfs, bootpath, + tmpfs, bootpath, extra_opts ? extra_opts : ""); - cmd_dst = g_strdup_printf("-machine accel=%s -m 128M" + cmd_dst = g_strdup_printf("-m 128M" " -name target,debug-threads=on" " -serial file:%s/dest_serial -bios %s" " -incoming %s %s", - accel, tmpfs, bootpath, uri, + tmpfs, bootpath, uri, extra_opts ? extra_opts : ""); start_address = S390_TEST_MEM_START; end_address = S390_TEST_MEM_END; } else if (strcmp(arch, "ppc64") == 0) { + machine_type = ""; + machine_args = ",vsmt=8"; extra_opts = use_shmem ? get_shmem_opts("256M", shmem_path) : NULL; - cmd_src = g_strdup_printf("-machine accel=%s,vsmt=8 -m 256M -nodefaults" + cmd_src = g_strdup_printf("-m 256M -nodefaults" " -name source,debug-threads=on" " -serial file:%s/src_serial" " -prom-env 'use-nvramrc?=true' -prom-env " "'nvramrc=hex .\" _\" begin %x %x " "do i c@ 1 + i c! 1000 +loop .\" B\" 0 " - "until' %s", accel, tmpfs, end_address, + "until' %s", tmpfs, end_address, start_address, extra_opts ? extra_opts : ""); - cmd_dst = g_strdup_printf("-machine accel=%s,vsmt=8 -m 256M" + cmd_dst = g_strdup_printf("-m 256M" " -name target,debug-threads=on" " -serial file:%s/dest_serial" " -incoming %s %s", - accel, tmpfs, uri, + tmpfs, uri, extra_opts ? extra_opts : ""); start_address = PPC_TEST_MEM_START; end_address = PPC_TEST_MEM_END; } else if (strcmp(arch, "aarch64") == 0) { init_bootfile(bootpath, aarch64_kernel, sizeof(aarch64_kernel)); + machine_type = "virt,"; + machine_args = "gic-version=max"; extra_opts = use_shmem ? get_shmem_opts("150M", shmem_path) : NULL; - cmd_src = g_strdup_printf("-machine virt,accel=%s,gic-version=max " - "-name vmsource,debug-threads=on -cpu max " + cmd_src = g_strdup_printf("-name vmsource,debug-threads=on -cpu max " "-m 150M -serial file:%s/src_serial " "-kernel %s %s", - accel, tmpfs, bootpath, + tmpfs, bootpath, extra_opts ? extra_opts : ""); - cmd_dst = g_strdup_printf("-machine virt,accel=%s,gic-version=max " - "-name vmdest,debug-threads=on -cpu max " + cmd_dst = g_strdup_printf("-name vmdest,debug-threads=on -cpu max " "-m 150M -serial file:%s/dest_serial " "-kernel %s " "-incoming %s %s", - accel, tmpfs, bootpath, uri, + tmpfs, bootpath, uri, extra_opts ? extra_opts : ""); start_address = ARM_TEST_MEM_START; @@ -667,13 +674,15 @@ static int test_migrate_start(QTestState **from, QTestState **to, ignore_stderr = ""; } - cmd_source = g_strdup_printf("%s %s %s", + cmd_source = g_strdup_printf("-machine %saccel=kvm:tcg%s %s %s %s", + machine_type, machine_args, cmd_src, opts_src, ignore_stderr); g_free(cmd_src); *from = qtest_init(cmd_source); g_free(cmd_source); - cmd_target = g_strdup_printf("%s %s %s", + cmd_target = g_strdup_printf("-machine %saccel=kvm:tcg%s %s %s %s", + machine_type, machine_args, cmd_dst, opts_dst, ignore_stderr); g_free(cmd_dst); *to = qtest_init(cmd_target); -- cgit v1.1 From 7b6d44cb811b987759889c7b2570dd9fe0079b4c Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Thu, 12 Dec 2019 23:20:27 +0100 Subject: migration-test: Move memory size to common commandline Signed-off-by: Juan Quintela Tested-by: Cornelia Huck #s390x Tested-by: Laurent Vivier --- tests/migration-test.c | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) (limited to 'tests') diff --git a/tests/migration-test.c b/tests/migration-test.c index 5a63158..9d40f2d 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -565,6 +565,7 @@ static int test_migrate_start(QTestState **from, QTestState **to, const char *arch = qtest_get_arch(); const char *machine_type; const char *machine_args; + const char *memory_size; opts_src = opts_src ? opts_src : ""; opts_dst = opts_dst ? opts_dst : ""; @@ -585,15 +586,14 @@ static int test_migrate_start(QTestState **from, QTestState **to, init_bootfile(bootpath, x86_bootsect, sizeof(x86_bootsect)); machine_type = ""; machine_args = ""; - extra_opts = use_shmem ? get_shmem_opts("150M", shmem_path) : NULL; - cmd_src = g_strdup_printf("-m 150M" - " -name source,debug-threads=on" + memory_size = "150M"; + extra_opts = use_shmem ? get_shmem_opts(memory_size, shmem_path) : NULL; + cmd_src = g_strdup_printf(" -name source,debug-threads=on" " -serial file:%s/src_serial" " -drive file=%s,format=raw %s", tmpfs, bootpath, extra_opts ? extra_opts : ""); - cmd_dst = g_strdup_printf("-m 150M" - " -name target,debug-threads=on" + cmd_dst = g_strdup_printf(" -name target,debug-threads=on" " -serial file:%s/dest_serial" " -drive file=%s,format=raw" " -incoming %s %s", @@ -605,14 +605,13 @@ static int test_migrate_start(QTestState **from, QTestState **to, init_bootfile(bootpath, s390x_elf, sizeof(s390x_elf)); machine_type = ""; machine_args = ""; - extra_opts = use_shmem ? get_shmem_opts("128M", shmem_path) : NULL; - cmd_src = g_strdup_printf("-m 128M" - " -name source,debug-threads=on" + memory_size = "128M"; + extra_opts = use_shmem ? get_shmem_opts(memory_size, shmem_path) : NULL; + cmd_src = g_strdup_printf(" -name source,debug-threads=on" " -serial file:%s/src_serial -bios %s %s", tmpfs, bootpath, extra_opts ? extra_opts : ""); - cmd_dst = g_strdup_printf("-m 128M" - " -name target,debug-threads=on" + cmd_dst = g_strdup_printf(" -name target,debug-threads=on" " -serial file:%s/dest_serial -bios %s" " -incoming %s %s", tmpfs, bootpath, uri, @@ -622,8 +621,9 @@ static int test_migrate_start(QTestState **from, QTestState **to, } else if (strcmp(arch, "ppc64") == 0) { machine_type = ""; machine_args = ",vsmt=8"; - extra_opts = use_shmem ? get_shmem_opts("256M", shmem_path) : NULL; - cmd_src = g_strdup_printf("-m 256M -nodefaults" + memory_size = "256M"; + extra_opts = use_shmem ? get_shmem_opts(memory_size, shmem_path) : NULL; + cmd_src = g_strdup_printf("-nodefaults" " -name source,debug-threads=on" " -serial file:%s/src_serial" " -prom-env 'use-nvramrc?=true' -prom-env " @@ -631,8 +631,7 @@ static int test_migrate_start(QTestState **from, QTestState **to, "do i c@ 1 + i c! 1000 +loop .\" B\" 0 " "until' %s", tmpfs, end_address, start_address, extra_opts ? extra_opts : ""); - cmd_dst = g_strdup_printf("-m 256M" - " -name target,debug-threads=on" + cmd_dst = g_strdup_printf(" -name target,debug-threads=on" " -serial file:%s/dest_serial" " -incoming %s %s", tmpfs, uri, @@ -644,14 +643,15 @@ static int test_migrate_start(QTestState **from, QTestState **to, init_bootfile(bootpath, aarch64_kernel, sizeof(aarch64_kernel)); machine_type = "virt,"; machine_args = "gic-version=max"; - extra_opts = use_shmem ? get_shmem_opts("150M", shmem_path) : NULL; + memory_size = "150M"; + extra_opts = use_shmem ? get_shmem_opts(memory_size, shmem_path) : NULL; cmd_src = g_strdup_printf("-name vmsource,debug-threads=on -cpu max " - "-m 150M -serial file:%s/src_serial " + "-serial file:%s/src_serial " "-kernel %s %s", tmpfs, bootpath, extra_opts ? extra_opts : ""); cmd_dst = g_strdup_printf("-name vmdest,debug-threads=on -cpu max " - "-m 150M -serial file:%s/dest_serial " + "-serial file:%s/dest_serial " "-kernel %s " "-incoming %s %s", tmpfs, bootpath, uri, @@ -674,15 +674,21 @@ static int test_migrate_start(QTestState **from, QTestState **to, ignore_stderr = ""; } - cmd_source = g_strdup_printf("-machine %saccel=kvm:tcg%s %s %s %s", + cmd_source = g_strdup_printf("-machine %saccel=kvm:tcg%s " + "-m %s " + "%s %s %s", machine_type, machine_args, + memory_size, cmd_src, opts_src, ignore_stderr); g_free(cmd_src); *from = qtest_init(cmd_source); g_free(cmd_source); - cmd_target = g_strdup_printf("-machine %saccel=kvm:tcg%s %s %s %s", + cmd_target = g_strdup_printf("-machine %saccel=kvm:tcg%s " + "-m %s " + "%s %s %s", machine_type, machine_args, + memory_size, cmd_dst, opts_dst, ignore_stderr); g_free(cmd_dst); *to = qtest_init(cmd_target); -- cgit v1.1 From 3ed375e7feff0587d9f370836069951b7df88848 Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Thu, 12 Dec 2019 23:20:28 +0100 Subject: migration-test: Move shmem handling to common commandline Signed-off-by: Juan Quintela Tested-by: Cornelia Huck #s390x Tested-by: Laurent Vivier --- tests/migration-test.c | 76 ++++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 42 deletions(-) (limited to 'tests') diff --git a/tests/migration-test.c b/tests/migration-test.c index 9d40f2d..e17d432 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -380,13 +380,6 @@ static void cleanup(const char *filename) g_free(path); } -static char *get_shmem_opts(const char *mem_size, const char *shmem_path) -{ - return g_strdup_printf("-object memory-backend-file,id=mem0,size=%s" - ",mem-path=%s,share=on -numa node,memdev=mem0", - mem_size, shmem_path); -} - static char *SocketAddress_to_str(SocketAddress *addr) { switch (addr->type) { @@ -560,8 +553,8 @@ static int test_migrate_start(QTestState **from, QTestState **to, gchar *cmd_source, *cmd_target; const gchar *ignore_stderr; char *bootpath = NULL; - char *extra_opts = NULL; - char *shmem_path = NULL; + char *shmem_opts; + char *shmem_path; const char *arch = qtest_get_arch(); const char *machine_type; const char *machine_args; @@ -575,7 +568,6 @@ static int test_migrate_start(QTestState **from, QTestState **to, g_test_skip("/dev/shm is not supported"); return -1; } - shmem_path = g_strdup_printf("/dev/shm/qemu-%d", getpid()); } got_stop = false; @@ -587,18 +579,15 @@ static int test_migrate_start(QTestState **from, QTestState **to, machine_type = ""; machine_args = ""; memory_size = "150M"; - extra_opts = use_shmem ? get_shmem_opts(memory_size, shmem_path) : NULL; cmd_src = g_strdup_printf(" -name source,debug-threads=on" " -serial file:%s/src_serial" - " -drive file=%s,format=raw %s", - tmpfs, bootpath, - extra_opts ? extra_opts : ""); + " -drive file=%s,format=raw", + tmpfs, bootpath); cmd_dst = g_strdup_printf(" -name target,debug-threads=on" " -serial file:%s/dest_serial" " -drive file=%s,format=raw" - " -incoming %s %s", - tmpfs, bootpath, uri, - extra_opts ? extra_opts : ""); + " -incoming %s", + tmpfs, bootpath, uri); start_address = X86_TEST_MEM_START; end_address = X86_TEST_MEM_END; } else if (g_str_equal(arch, "s390x")) { @@ -606,36 +595,31 @@ static int test_migrate_start(QTestState **from, QTestState **to, machine_type = ""; machine_args = ""; memory_size = "128M"; - extra_opts = use_shmem ? get_shmem_opts(memory_size, shmem_path) : NULL; cmd_src = g_strdup_printf(" -name source,debug-threads=on" - " -serial file:%s/src_serial -bios %s %s", - tmpfs, bootpath, - extra_opts ? extra_opts : ""); + " -serial file:%s/src_serial -bios %s", + tmpfs, bootpath); cmd_dst = g_strdup_printf(" -name target,debug-threads=on" " -serial file:%s/dest_serial -bios %s" - " -incoming %s %s", - tmpfs, bootpath, uri, - extra_opts ? extra_opts : ""); + " -incoming %s", + tmpfs, bootpath, uri); start_address = S390_TEST_MEM_START; end_address = S390_TEST_MEM_END; } else if (strcmp(arch, "ppc64") == 0) { machine_type = ""; machine_args = ",vsmt=8"; memory_size = "256M"; - extra_opts = use_shmem ? get_shmem_opts(memory_size, shmem_path) : NULL; cmd_src = g_strdup_printf("-nodefaults" " -name source,debug-threads=on" " -serial file:%s/src_serial" " -prom-env 'use-nvramrc?=true' -prom-env " "'nvramrc=hex .\" _\" begin %x %x " "do i c@ 1 + i c! 1000 +loop .\" B\" 0 " - "until' %s", tmpfs, end_address, - start_address, extra_opts ? extra_opts : ""); + "until'", tmpfs, end_address, + start_address); cmd_dst = g_strdup_printf(" -name target,debug-threads=on" " -serial file:%s/dest_serial" - " -incoming %s %s", - tmpfs, uri, - extra_opts ? extra_opts : ""); + " -incoming %s", + tmpfs, uri); start_address = PPC_TEST_MEM_START; end_address = PPC_TEST_MEM_END; @@ -644,18 +628,15 @@ static int test_migrate_start(QTestState **from, QTestState **to, machine_type = "virt,"; machine_args = "gic-version=max"; memory_size = "150M"; - extra_opts = use_shmem ? get_shmem_opts(memory_size, shmem_path) : NULL; cmd_src = g_strdup_printf("-name vmsource,debug-threads=on -cpu max " "-serial file:%s/src_serial " - "-kernel %s %s", - tmpfs, bootpath, - extra_opts ? extra_opts : ""); + "-kernel %s", + tmpfs, bootpath); cmd_dst = g_strdup_printf("-name vmdest,debug-threads=on -cpu max " "-serial file:%s/dest_serial " "-kernel %s " - "-incoming %s %s", - tmpfs, bootpath, uri, - extra_opts ? extra_opts : ""); + "-incoming %s", + tmpfs, bootpath, uri); start_address = ARM_TEST_MEM_START; end_address = ARM_TEST_MEM_END; @@ -666,7 +647,6 @@ static int test_migrate_start(QTestState **from, QTestState **to, } g_free(bootpath); - g_free(extra_opts); if (hide_stderr) { ignore_stderr = "2>/dev/null"; @@ -674,26 +654,38 @@ static int test_migrate_start(QTestState **from, QTestState **to, ignore_stderr = ""; } + if (use_shmem) { + shmem_path = g_strdup_printf("/dev/shm/qemu-%d", getpid()); + shmem_opts = g_strdup_printf( + "-object memory-backend-file,id=mem0,size=%s" + ",mem-path=%s,share=on -numa node,memdev=mem0", + memory_size, shmem_path); + } else { + shmem_path = NULL; + shmem_opts = g_strdup(""); + } + cmd_source = g_strdup_printf("-machine %saccel=kvm:tcg%s " "-m %s " - "%s %s %s", + "%s %s %s %s", machine_type, machine_args, memory_size, - cmd_src, opts_src, ignore_stderr); + cmd_src, shmem_opts, opts_src, ignore_stderr); g_free(cmd_src); *from = qtest_init(cmd_source); g_free(cmd_source); cmd_target = g_strdup_printf("-machine %saccel=kvm:tcg%s " "-m %s " - "%s %s %s", + "%s %s %s %s", machine_type, machine_args, memory_size, - cmd_dst, opts_dst, ignore_stderr); + cmd_dst, shmem_opts, opts_dst, ignore_stderr); g_free(cmd_dst); *to = qtest_init(cmd_target); g_free(cmd_target); + g_free(shmem_opts); /* * Remove shmem file immediately to avoid memory leak in test failed case. * It's valid becase QEMU has already opened this file -- cgit v1.1 From d6b4326714e852a1bca9cfc9902ab6fd7a1d2956 Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Thu, 12 Dec 2019 23:20:29 +0100 Subject: migration-test: Move -name handling to common commandline Signed-off-by: Juan Quintela Tested-by: Cornelia Huck #s390x Tested-by: Laurent Vivier --- tests/migration-test.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/migration-test.c b/tests/migration-test.c index e17d432..6e828fb 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -579,12 +579,10 @@ static int test_migrate_start(QTestState **from, QTestState **to, machine_type = ""; machine_args = ""; memory_size = "150M"; - cmd_src = g_strdup_printf(" -name source,debug-threads=on" - " -serial file:%s/src_serial" + cmd_src = g_strdup_printf(" -serial file:%s/src_serial" " -drive file=%s,format=raw", tmpfs, bootpath); - cmd_dst = g_strdup_printf(" -name target,debug-threads=on" - " -serial file:%s/dest_serial" + cmd_dst = g_strdup_printf(" -serial file:%s/dest_serial" " -drive file=%s,format=raw" " -incoming %s", tmpfs, bootpath, uri); @@ -595,11 +593,9 @@ static int test_migrate_start(QTestState **from, QTestState **to, machine_type = ""; machine_args = ""; memory_size = "128M"; - cmd_src = g_strdup_printf(" -name source,debug-threads=on" - " -serial file:%s/src_serial -bios %s", + cmd_src = g_strdup_printf(" -serial file:%s/src_serial -bios %s", tmpfs, bootpath); - cmd_dst = g_strdup_printf(" -name target,debug-threads=on" - " -serial file:%s/dest_serial -bios %s" + cmd_dst = g_strdup_printf(" -serial file:%s/dest_serial -bios %s" " -incoming %s", tmpfs, bootpath, uri); start_address = S390_TEST_MEM_START; @@ -609,15 +605,13 @@ static int test_migrate_start(QTestState **from, QTestState **to, machine_args = ",vsmt=8"; memory_size = "256M"; cmd_src = g_strdup_printf("-nodefaults" - " -name source,debug-threads=on" " -serial file:%s/src_serial" " -prom-env 'use-nvramrc?=true' -prom-env " "'nvramrc=hex .\" _\" begin %x %x " "do i c@ 1 + i c! 1000 +loop .\" B\" 0 " "until'", tmpfs, end_address, start_address); - cmd_dst = g_strdup_printf(" -name target,debug-threads=on" - " -serial file:%s/dest_serial" + cmd_dst = g_strdup_printf(" -serial file:%s/dest_serial" " -incoming %s", tmpfs, uri); @@ -628,11 +622,11 @@ static int test_migrate_start(QTestState **from, QTestState **to, machine_type = "virt,"; machine_args = "gic-version=max"; memory_size = "150M"; - cmd_src = g_strdup_printf("-name vmsource,debug-threads=on -cpu max " + cmd_src = g_strdup_printf("-cpu max " "-serial file:%s/src_serial " "-kernel %s", tmpfs, bootpath); - cmd_dst = g_strdup_printf("-name vmdest,debug-threads=on -cpu max " + cmd_dst = g_strdup_printf("-cpu max " "-serial file:%s/dest_serial " "-kernel %s " "-incoming %s", @@ -666,6 +660,7 @@ static int test_migrate_start(QTestState **from, QTestState **to, } cmd_source = g_strdup_printf("-machine %saccel=kvm:tcg%s " + "-name source,debug-threads=on " "-m %s " "%s %s %s %s", machine_type, machine_args, @@ -676,6 +671,7 @@ static int test_migrate_start(QTestState **from, QTestState **to, g_free(cmd_source); cmd_target = g_strdup_printf("-machine %saccel=kvm:tcg%s " + "-name target,debug-threads=on " "-m %s " "%s %s %s %s", machine_type, machine_args, -- cgit v1.1 From c5f40ff9f693e56ad7358a41b46dd01d27ad64e7 Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Thu, 12 Dec 2019 23:20:30 +0100 Subject: migration-test: Move -serial handling to common commandline Signed-off-by: Juan Quintela Tested-by: Cornelia Huck #s390x Tested-by: Laurent Vivier --- tests/migration-test.c | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-) (limited to 'tests') diff --git a/tests/migration-test.c b/tests/migration-test.c index 6e828fb..e1304d7 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -579,13 +579,10 @@ static int test_migrate_start(QTestState **from, QTestState **to, machine_type = ""; machine_args = ""; memory_size = "150M"; - cmd_src = g_strdup_printf(" -serial file:%s/src_serial" - " -drive file=%s,format=raw", - tmpfs, bootpath); - cmd_dst = g_strdup_printf(" -serial file:%s/dest_serial" - " -drive file=%s,format=raw" + cmd_src = g_strdup_printf("-drive file=%s,format=raw", bootpath); + cmd_dst = g_strdup_printf("-drive file=%s,format=raw" " -incoming %s", - tmpfs, bootpath, uri); + bootpath, uri); start_address = X86_TEST_MEM_START; end_address = X86_TEST_MEM_END; } else if (g_str_equal(arch, "s390x")) { @@ -593,28 +590,22 @@ static int test_migrate_start(QTestState **from, QTestState **to, machine_type = ""; machine_args = ""; memory_size = "128M"; - cmd_src = g_strdup_printf(" -serial file:%s/src_serial -bios %s", - tmpfs, bootpath); - cmd_dst = g_strdup_printf(" -serial file:%s/dest_serial -bios %s" + cmd_src = g_strdup_printf("-bios %s", bootpath); + cmd_dst = g_strdup_printf("-bios %s" " -incoming %s", - tmpfs, bootpath, uri); + bootpath, uri); start_address = S390_TEST_MEM_START; end_address = S390_TEST_MEM_END; } else if (strcmp(arch, "ppc64") == 0) { machine_type = ""; machine_args = ",vsmt=8"; memory_size = "256M"; - cmd_src = g_strdup_printf("-nodefaults" - " -serial file:%s/src_serial" - " -prom-env 'use-nvramrc?=true' -prom-env " + cmd_src = g_strdup_printf("-nodefaults " + "-prom-env 'use-nvramrc?=true' -prom-env " "'nvramrc=hex .\" _\" begin %x %x " "do i c@ 1 + i c! 1000 +loop .\" B\" 0 " - "until'", tmpfs, end_address, - start_address); - cmd_dst = g_strdup_printf(" -serial file:%s/dest_serial" - " -incoming %s", - tmpfs, uri); - + "until'", end_address, start_address); + cmd_dst = g_strdup_printf(" -incoming %s", uri); start_address = PPC_TEST_MEM_START; end_address = PPC_TEST_MEM_END; } else if (strcmp(arch, "aarch64") == 0) { @@ -623,14 +614,12 @@ static int test_migrate_start(QTestState **from, QTestState **to, machine_args = "gic-version=max"; memory_size = "150M"; cmd_src = g_strdup_printf("-cpu max " - "-serial file:%s/src_serial " "-kernel %s", - tmpfs, bootpath); + bootpath); cmd_dst = g_strdup_printf("-cpu max " - "-serial file:%s/dest_serial " "-kernel %s " "-incoming %s", - tmpfs, bootpath, uri); + bootpath, uri); start_address = ARM_TEST_MEM_START; end_address = ARM_TEST_MEM_END; @@ -661,10 +650,11 @@ static int test_migrate_start(QTestState **from, QTestState **to, cmd_source = g_strdup_printf("-machine %saccel=kvm:tcg%s " "-name source,debug-threads=on " + "-serial file:%s/src_serial " "-m %s " "%s %s %s %s", machine_type, machine_args, - memory_size, + tmpfs, memory_size, cmd_src, shmem_opts, opts_src, ignore_stderr); g_free(cmd_src); *from = qtest_init(cmd_source); @@ -673,9 +663,10 @@ static int test_migrate_start(QTestState **from, QTestState **to, cmd_target = g_strdup_printf("-machine %saccel=kvm:tcg%s " "-name target,debug-threads=on " "-m %s " + "-serial file:%s/dest_serial " "%s %s %s %s", machine_type, machine_args, - memory_size, + tmpfs, memory_size, cmd_dst, shmem_opts, opts_dst, ignore_stderr); g_free(cmd_dst); *to = qtest_init(cmd_target); -- cgit v1.1 From cd49673155a7cf4be879d1451c183a836347ee30 Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Thu, 12 Dec 2019 23:20:31 +0100 Subject: migration-test: Move -incomming handling to common commandline Signed-off-by: Juan Quintela Tested-by: Cornelia Huck #s390x Tested-by: Laurent Vivier --- tests/migration-test.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'tests') diff --git a/tests/migration-test.c b/tests/migration-test.c index e1304d7..14f2ce3 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -580,9 +580,7 @@ static int test_migrate_start(QTestState **from, QTestState **to, machine_args = ""; memory_size = "150M"; cmd_src = g_strdup_printf("-drive file=%s,format=raw", bootpath); - cmd_dst = g_strdup_printf("-drive file=%s,format=raw" - " -incoming %s", - bootpath, uri); + cmd_dst = g_strdup(cmd_src); start_address = X86_TEST_MEM_START; end_address = X86_TEST_MEM_END; } else if (g_str_equal(arch, "s390x")) { @@ -591,9 +589,7 @@ static int test_migrate_start(QTestState **from, QTestState **to, machine_args = ""; memory_size = "128M"; cmd_src = g_strdup_printf("-bios %s", bootpath); - cmd_dst = g_strdup_printf("-bios %s" - " -incoming %s", - bootpath, uri); + cmd_dst = g_strdup(cmd_src); start_address = S390_TEST_MEM_START; end_address = S390_TEST_MEM_END; } else if (strcmp(arch, "ppc64") == 0) { @@ -605,7 +601,7 @@ static int test_migrate_start(QTestState **from, QTestState **to, "'nvramrc=hex .\" _\" begin %x %x " "do i c@ 1 + i c! 1000 +loop .\" B\" 0 " "until'", end_address, start_address); - cmd_dst = g_strdup_printf(" -incoming %s", uri); + cmd_dst = g_strdup(""); start_address = PPC_TEST_MEM_START; end_address = PPC_TEST_MEM_END; } else if (strcmp(arch, "aarch64") == 0) { @@ -616,11 +612,7 @@ static int test_migrate_start(QTestState **from, QTestState **to, cmd_src = g_strdup_printf("-cpu max " "-kernel %s", bootpath); - cmd_dst = g_strdup_printf("-cpu max " - "-kernel %s " - "-incoming %s", - bootpath, uri); - + cmd_dst = g_strdup(cmd_src); start_address = ARM_TEST_MEM_START; end_address = ARM_TEST_MEM_END; @@ -650,11 +642,11 @@ static int test_migrate_start(QTestState **from, QTestState **to, cmd_source = g_strdup_printf("-machine %saccel=kvm:tcg%s " "-name source,debug-threads=on " - "-serial file:%s/src_serial " "-m %s " + "-serial file:%s/src_serial " "%s %s %s %s", machine_type, machine_args, - tmpfs, memory_size, + memory_size, tmpfs, cmd_src, shmem_opts, opts_src, ignore_stderr); g_free(cmd_src); *from = qtest_init(cmd_source); @@ -664,9 +656,10 @@ static int test_migrate_start(QTestState **from, QTestState **to, "-name target,debug-threads=on " "-m %s " "-serial file:%s/dest_serial " + "-incoming %s " "%s %s %s %s", machine_type, machine_args, - tmpfs, memory_size, + memory_size, tmpfs, uri, cmd_dst, shmem_opts, opts_dst, ignore_stderr); g_free(cmd_dst); *to = qtest_init(cmd_target); -- cgit v1.1 From 68d956092f156ad74e4f75437de626af6192fb71 Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Thu, 12 Dec 2019 23:20:32 +0100 Subject: migration-test: Rename cmd_src/dst to arch_source/arch_target This explains better what they do and avoid confussino with command_src/target. Signed-off-by: Juan Quintela Tested-by: Cornelia Huck #s390x Tested-by: Laurent Vivier --- tests/migration-test.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'tests') diff --git a/tests/migration-test.c b/tests/migration-test.c index 14f2ce3..37e9663 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -549,7 +549,7 @@ static int test_migrate_start(QTestState **from, QTestState **to, bool use_shmem, const char *opts_src, const char *opts_dst) { - gchar *cmd_src, *cmd_dst; + gchar *arch_source, *arch_target; gchar *cmd_source, *cmd_target; const gchar *ignore_stderr; char *bootpath = NULL; @@ -579,8 +579,8 @@ static int test_migrate_start(QTestState **from, QTestState **to, machine_type = ""; machine_args = ""; memory_size = "150M"; - cmd_src = g_strdup_printf("-drive file=%s,format=raw", bootpath); - cmd_dst = g_strdup(cmd_src); + arch_source = g_strdup_printf("-drive file=%s,format=raw", bootpath); + arch_target = g_strdup(arch_source); start_address = X86_TEST_MEM_START; end_address = X86_TEST_MEM_END; } else if (g_str_equal(arch, "s390x")) { @@ -588,20 +588,20 @@ static int test_migrate_start(QTestState **from, QTestState **to, machine_type = ""; machine_args = ""; memory_size = "128M"; - cmd_src = g_strdup_printf("-bios %s", bootpath); - cmd_dst = g_strdup(cmd_src); + arch_source = g_strdup_printf("-bios %s", bootpath); + arch_target = g_strdup(arch_source); start_address = S390_TEST_MEM_START; end_address = S390_TEST_MEM_END; } else if (strcmp(arch, "ppc64") == 0) { machine_type = ""; machine_args = ",vsmt=8"; memory_size = "256M"; - cmd_src = g_strdup_printf("-nodefaults " - "-prom-env 'use-nvramrc?=true' -prom-env " - "'nvramrc=hex .\" _\" begin %x %x " - "do i c@ 1 + i c! 1000 +loop .\" B\" 0 " - "until'", end_address, start_address); - cmd_dst = g_strdup(""); + arch_source = g_strdup_printf("-nodefaults " + "-prom-env 'use-nvramrc?=true' -prom-env " + "'nvramrc=hex .\" _\" begin %x %x " + "do i c@ 1 + i c! 1000 +loop .\" B\" 0 " + "until'", end_address, start_address); + arch_target = g_strdup(""); start_address = PPC_TEST_MEM_START; end_address = PPC_TEST_MEM_END; } else if (strcmp(arch, "aarch64") == 0) { @@ -609,10 +609,10 @@ static int test_migrate_start(QTestState **from, QTestState **to, machine_type = "virt,"; machine_args = "gic-version=max"; memory_size = "150M"; - cmd_src = g_strdup_printf("-cpu max " - "-kernel %s", - bootpath); - cmd_dst = g_strdup(cmd_src); + arch_source = g_strdup_printf("-cpu max " + "-kernel %s", + bootpath); + arch_target = g_strdup(arch_source); start_address = ARM_TEST_MEM_START; end_address = ARM_TEST_MEM_END; @@ -647,8 +647,9 @@ static int test_migrate_start(QTestState **from, QTestState **to, "%s %s %s %s", machine_type, machine_args, memory_size, tmpfs, - cmd_src, shmem_opts, opts_src, ignore_stderr); - g_free(cmd_src); + arch_source, shmem_opts, opts_src, + ignore_stderr); + g_free(arch_source); *from = qtest_init(cmd_source); g_free(cmd_source); @@ -660,8 +661,9 @@ static int test_migrate_start(QTestState **from, QTestState **to, "%s %s %s %s", machine_type, machine_args, memory_size, tmpfs, uri, - cmd_dst, shmem_opts, opts_dst, ignore_stderr); - g_free(cmd_dst); + arch_target, shmem_opts, opts_dst, + ignore_stderr); + g_free(arch_target); *to = qtest_init(cmd_target); g_free(cmd_target); -- cgit v1.1 From 5d3b575da64ed3f45952218ab5d3bd9985f35941 Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Thu, 12 Dec 2019 23:20:33 +0100 Subject: migration-test: Use a struct for test_migrate_start parameters It has two bools and two strings, it is very difficult to remember which does what. And it makes very difficult to add new parameters as we need to modify all the callers. Signed-off-by: Juan Quintela Tested-by: Cornelia Huck #s390x Tested-by: Laurent Vivier --- tests/migration-test.c | 118 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 78 insertions(+), 40 deletions(-) (limited to 'tests') diff --git a/tests/migration-test.c b/tests/migration-test.c index 37e9663..dbe25b8 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -544,10 +544,31 @@ static void migrate_postcopy_start(QTestState *from, QTestState *to) qtest_qmp_eventwait(to, "RESUME"); } +typedef struct { + bool hide_stderr; + bool use_shmem; + char *opts_source; + char *opts_target; +} MigrateStart; + +static MigrateStart *migrate_start_new(void) +{ + MigrateStart *args = g_new0(MigrateStart, 1); + + args->opts_source = g_strdup(""); + args->opts_target = g_strdup(""); + return args; +} + +static void migrate_start_destroy(MigrateStart *args) +{ + g_free(args->opts_source); + g_free(args->opts_target); + g_free(args); +} + static int test_migrate_start(QTestState **from, QTestState **to, - const char *uri, bool hide_stderr, - bool use_shmem, const char *opts_src, - const char *opts_dst) + const char *uri, MigrateStart *args) { gchar *arch_source, *arch_target; gchar *cmd_source, *cmd_target; @@ -560,10 +581,7 @@ static int test_migrate_start(QTestState **from, QTestState **to, const char *machine_args; const char *memory_size; - opts_src = opts_src ? opts_src : ""; - opts_dst = opts_dst ? opts_dst : ""; - - if (use_shmem) { + if (args->use_shmem) { if (!g_file_test("/dev/shm", G_FILE_TEST_IS_DIR)) { g_test_skip("/dev/shm is not supported"); return -1; @@ -623,13 +641,13 @@ static int test_migrate_start(QTestState **from, QTestState **to, g_free(bootpath); - if (hide_stderr) { + if (args->hide_stderr) { ignore_stderr = "2>/dev/null"; } else { ignore_stderr = ""; } - if (use_shmem) { + if (args->use_shmem) { shmem_path = g_strdup_printf("/dev/shm/qemu-%d", getpid()); shmem_opts = g_strdup_printf( "-object memory-backend-file,id=mem0,size=%s" @@ -647,7 +665,7 @@ static int test_migrate_start(QTestState **from, QTestState **to, "%s %s %s %s", machine_type, machine_args, memory_size, tmpfs, - arch_source, shmem_opts, opts_src, + arch_source, shmem_opts, args->opts_source, ignore_stderr); g_free(arch_source); *from = qtest_init(cmd_source); @@ -661,8 +679,8 @@ static int test_migrate_start(QTestState **from, QTestState **to, "%s %s %s %s", machine_type, machine_args, memory_size, tmpfs, uri, - arch_target, shmem_opts, opts_dst, - ignore_stderr); + arch_target, shmem_opts, + args->opts_target, ignore_stderr); g_free(arch_target); *to = qtest_init(cmd_target); g_free(cmd_target); @@ -672,11 +690,12 @@ static int test_migrate_start(QTestState **from, QTestState **to, * Remove shmem file immediately to avoid memory leak in test failed case. * It's valid becase QEMU has already opened this file */ - if (use_shmem) { + if (args->use_shmem) { unlink(shmem_path); g_free(shmem_path); } + migrate_start_destroy(args); return 0; } @@ -762,13 +781,13 @@ static void test_deprecated(void) } static int migrate_postcopy_prepare(QTestState **from_ptr, - QTestState **to_ptr, - bool hide_error) + QTestState **to_ptr, + MigrateStart *args) { char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs); QTestState *from, *to; - if (test_migrate_start(&from, &to, uri, hide_error, false, NULL, NULL)) { + if (test_migrate_start(&from, &to, uri, args)) { return -1; } @@ -813,9 +832,10 @@ static void migrate_postcopy_complete(QTestState *from, QTestState *to) static void test_postcopy(void) { + MigrateStart *args = migrate_start_new(); QTestState *from, *to; - if (migrate_postcopy_prepare(&from, &to, false)) { + if (migrate_postcopy_prepare(&from, &to, args)) { return; } migrate_postcopy_start(from, to); @@ -824,10 +844,13 @@ static void test_postcopy(void) static void test_postcopy_recovery(void) { + MigrateStart *args = migrate_start_new(); QTestState *from, *to; char *uri; - if (migrate_postcopy_prepare(&from, &to, true)) { + args->hide_stderr = true; + + if (migrate_postcopy_prepare(&from, &to, args)) { return; } @@ -910,9 +933,12 @@ static void wait_for_migration_fail(QTestState *from, bool allow_active) static void test_baddest(void) { + MigrateStart *args = migrate_start_new(); QTestState *from, *to; - if (test_migrate_start(&from, &to, "tcp:0:0", true, false, NULL, NULL)) { + args->hide_stderr = true; + + if (test_migrate_start(&from, &to, "tcp:0:0", args)) { return; } migrate(from, "tcp:0:0", "{}"); @@ -923,9 +949,10 @@ static void test_baddest(void) static void test_precopy_unix(void) { char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs); + MigrateStart *args = migrate_start_new(); QTestState *from, *to; - if (test_migrate_start(&from, &to, uri, false, false, NULL, NULL)) { + if (test_migrate_start(&from, &to, uri, args)) { return; } @@ -1001,9 +1028,10 @@ static void test_ignore_shared(void) static void test_xbzrle(const char *uri) { + MigrateStart *args = migrate_start_new(); QTestState *from, *to; - if (test_migrate_start(&from, &to, uri, false, false, NULL, NULL)) { + if (test_migrate_start(&from, &to, uri, args)) { return; } @@ -1052,11 +1080,11 @@ static void test_xbzrle_unix(void) static void test_precopy_tcp(void) { + MigrateStart *args = migrate_start_new(); char *uri; QTestState *from, *to; - if (test_migrate_start(&from, &to, "tcp:127.0.0.1:0", false, false, - NULL, NULL)) { + if (test_migrate_start(&from, &to, "tcp:127.0.0.1:0", args)) { return; } @@ -1096,13 +1124,14 @@ static void test_precopy_tcp(void) static void test_migrate_fd_proto(void) { + MigrateStart *args = migrate_start_new(); QTestState *from, *to; int ret; int pair[2]; QDict *rsp; const char *error_desc; - if (test_migrate_start(&from, &to, "defer", false, false, NULL, NULL)) { + if (test_migrate_start(&from, &to, "defer", args)) { return; } @@ -1178,15 +1207,12 @@ static void test_migrate_fd_proto(void) test_migrate_end(from, to, true); } -static void do_test_validate_uuid(const char *uuid_arg_src, - const char *uuid_arg_dst, - bool should_fail, bool hide_stderr) +static void do_test_validate_uuid(MigrateStart *args, bool should_fail) { char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs); QTestState *from, *to; - if (test_migrate_start(&from, &to, uri, hide_stderr, false, - uuid_arg_src, uuid_arg_dst)) { + if (test_migrate_start(&from, &to, uri, args)) { return; } @@ -1216,33 +1242,45 @@ static void do_test_validate_uuid(const char *uuid_arg_src, static void test_validate_uuid(void) { - do_test_validate_uuid("-uuid 11111111-1111-1111-1111-111111111111", - "-uuid 11111111-1111-1111-1111-111111111111", - false, false); + MigrateStart *args = migrate_start_new(); + + args->opts_source = g_strdup("-uuid 11111111-1111-1111-1111-111111111111"); + args->opts_target = g_strdup("-uuid 11111111-1111-1111-1111-111111111111"); + do_test_validate_uuid(args, false); } static void test_validate_uuid_error(void) { - do_test_validate_uuid("-uuid 11111111-1111-1111-1111-111111111111", - "-uuid 22222222-2222-2222-2222-222222222222", - true, true); + MigrateStart *args = migrate_start_new(); + + args->opts_source = g_strdup("-uuid 11111111-1111-1111-1111-111111111111"); + args->opts_target = g_strdup("-uuid 22222222-2222-2222-2222-222222222222"); + args->hide_stderr = true; + do_test_validate_uuid(args, true); } static void test_validate_uuid_src_not_set(void) { - do_test_validate_uuid(NULL, "-uuid 11111111-1111-1111-1111-111111111111", - false, true); + MigrateStart *args = migrate_start_new(); + + args->opts_target = g_strdup("-uuid 22222222-2222-2222-2222-222222222222"); + args->hide_stderr = true; + do_test_validate_uuid(args, false); } static void test_validate_uuid_dst_not_set(void) { - do_test_validate_uuid("-uuid 11111111-1111-1111-1111-111111111111", NULL, - false, true); + MigrateStart *args = migrate_start_new(); + + args->opts_source = g_strdup("-uuid 11111111-1111-1111-1111-111111111111"); + args->hide_stderr = true; + do_test_validate_uuid(args, false); } static void test_migrate_auto_converge(void) { char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs); + MigrateStart *args = migrate_start_new(); QTestState *from, *to; int64_t remaining, percentage; @@ -1261,7 +1299,7 @@ static void test_migrate_auto_converge(void) */ const int64_t expected_threshold = max_bandwidth * downtime_limit / 1000; - if (test_migrate_start(&from, &to, uri, false, false, NULL, NULL)) { + if (test_migrate_start(&from, &to, uri, args)) { return; } -- cgit v1.1 From 6f6e1698a68ceb49e57676528612f22eaf2c16c3 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 13 Nov 2019 10:10:47 +0100 Subject: vl: configure accelerators from -accel options Drop the "accel" property from MachineState, and instead desugar "-machine accel=" to a list of "-accel" options. This has a semantic change due to removing merge_lists from -accel. For example: - "-accel kvm -accel tcg" all but ignored "-accel kvm". This is a bugfix. - "-accel kvm -accel thread=single" ignored "thread=single", since it applied the option to KVM. Now it fails due to not specifying the accelerator on "-accel thread=single". - "-accel tcg -accel thread=single" chose single-threaded TCG, while now it will fail due to not specifying the accelerator on "-accel thread=single". Also, "-machine accel" and "-accel" become incompatible. Signed-off-by: Paolo Bonzini --- tests/arm-cpu-features.c | 4 ++-- tests/bios-tables-test.c | 16 ++++++++-------- tests/boot-serial-test.c | 4 ++-- tests/cdrom-test.c | 2 +- tests/libqtest.c | 4 ++-- tests/migration-test.c | 23 +++++++++-------------- tests/pflash-cfi02-test.c | 4 ++-- tests/pnv-xscom-test.c | 4 ++-- tests/prom-env-test.c | 2 +- tests/pxe-test.c | 2 +- tests/vmgenid-test.c | 2 +- 11 files changed, 31 insertions(+), 36 deletions(-) (limited to 'tests') diff --git a/tests/arm-cpu-features.c b/tests/arm-cpu-features.c index 6e99aa9..bef3ed2 100644 --- a/tests/arm-cpu-features.c +++ b/tests/arm-cpu-features.c @@ -20,8 +20,8 @@ */ #define SVE_MAX_VQ 16 -#define MACHINE "-machine virt,gic-version=max,accel=tcg " -#define MACHINE_KVM "-machine virt,gic-version=max,accel=kvm:tcg " +#define MACHINE "-machine virt,gic-version=max -accel tcg " +#define MACHINE_KVM "-machine virt,gic-version=max -accel kvm -accel tcg " #define QUERY_HEAD "{ 'execute': 'query-cpu-model-expansion', " \ " 'arguments': { 'type': 'full', " #define QUERY_TAIL "}}" diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c index 79f5da0..bc0ad59 100644 --- a/tests/bios-tables-test.c +++ b/tests/bios-tables-test.c @@ -51,7 +51,7 @@ #define ACPI_REBUILD_EXPECTED_AML "TEST_ACPI_REBUILD_AML" typedef struct { - const char *accel; + bool tcg_only; const char *machine; const char *variant; const char *uefi_fl1; @@ -607,19 +607,19 @@ static void test_acpi_one(const char *params, test_data *data) * TODO: convert '-drive if=pflash' to new syntax (see e33763be7cd3) * when arm/virt boad starts to support it. */ - args = g_strdup_printf("-machine %s,accel=%s -nodefaults -nographic " + args = g_strdup_printf("-machine %s %s -accel tcg -nodefaults -nographic " "-drive if=pflash,format=raw,file=%s,readonly " "-drive if=pflash,format=raw,file=%s,snapshot=on -cdrom %s %s", - data->machine, data->accel ? data->accel : "kvm:tcg", + data->machine, data->tcg_only ? "" : "-accel kvm", data->uefi_fl1, data->uefi_fl2, data->cd, params ? params : ""); } else { /* Disable kernel irqchip to be able to override apic irq0. */ - args = g_strdup_printf("-machine %s,accel=%s,kernel-irqchip=off " + args = g_strdup_printf("-machine %s,kernel-irqchip=off %s -accel tcg " "-net none -display none %s " "-drive id=hd0,if=none,file=%s,format=raw " "-device ide-hd,drive=hd0 ", - data->machine, data->accel ? data->accel : "kvm:tcg", + data->machine, data->tcg_only ? "" : "-accel kvm", params ? params : "", disk); } @@ -904,7 +904,7 @@ static void test_acpi_virt_tcg_memhp(void) { test_data data = { .machine = "virt", - .accel = "tcg", + .tcg_only = true, .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd", .uefi_fl2 = "pc-bios/edk2-arm-vars.fd", .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2", @@ -929,7 +929,7 @@ static void test_acpi_virt_tcg_numamem(void) { test_data data = { .machine = "virt", - .accel = "tcg", + .tcg_only = true, .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd", .uefi_fl2 = "pc-bios/edk2-arm-vars.fd", .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2", @@ -951,7 +951,7 @@ static void test_acpi_virt_tcg(void) { test_data data = { .machine = "virt", - .accel = "tcg", + .tcg_only = true, .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd", .uefi_fl2 = "pc-bios/edk2-arm-vars.fd", .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2", diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c index d3a54a0..05c7f44 100644 --- a/tests/boot-serial-test.c +++ b/tests/boot-serial-test.c @@ -215,9 +215,9 @@ static void test_machine(const void *data) * Make sure that this test uses tcg if available: It is used as a * fast-enough smoketest for that. */ - qts = qtest_initf("%s %s -M %s,accel=tcg:kvm -no-shutdown " + qts = qtest_initf("%s %s -M %s -no-shutdown " "-chardev file,id=serial0,path=%s " - "-serial chardev:serial0 %s", + "-serial chardev:serial0 -accel tcg -accel kvm %s", codeparam, code ? codetmp : "", test->machine, serialtmp, test->extra); if (code) { diff --git a/tests/cdrom-test.c b/tests/cdrom-test.c index 34e9974..67635e3 100644 --- a/tests/cdrom-test.c +++ b/tests/cdrom-test.c @@ -120,7 +120,7 @@ static void test_cdboot(gconstpointer data) { QTestState *qts; - qts = qtest_initf("-M accel=kvm:tcg -no-shutdown %s%s", (const char *)data, + qts = qtest_initf("-accel kvm -accel tcg -no-shutdown %s%s", (const char *)data, isoimage); boot_sector_test(qts); qtest_quit(qts); diff --git a/tests/libqtest.c b/tests/libqtest.c index f36e30a..76c9f8e 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -241,9 +241,9 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args) "-qtest-log %s " "-chardev socket,path=%s,id=char0 " "-mon chardev=char0,mode=control " - "-accel qtest " "-display none " - "%s", qemu_binary, socket_path, + "%s" + " -accel qtest", qemu_binary, socket_path, getenv("QTEST_LOG") ? "/dev/fd/2" : "/dev/null", qmp_socket_path, extra_args ?: ""); diff --git a/tests/migration-test.c b/tests/migration-test.c index dbe25b8..e56e6dc 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -577,8 +577,7 @@ static int test_migrate_start(QTestState **from, QTestState **to, char *shmem_opts; char *shmem_path; const char *arch = qtest_get_arch(); - const char *machine_type; - const char *machine_args; + const char *machine_opts = NULL; const char *memory_size; if (args->use_shmem) { @@ -594,8 +593,6 @@ static int test_migrate_start(QTestState **from, QTestState **to, /* the assembled x86 boot sector should be exactly one sector large */ assert(sizeof(x86_bootsect) == 512); init_bootfile(bootpath, x86_bootsect, sizeof(x86_bootsect)); - machine_type = ""; - machine_args = ""; memory_size = "150M"; arch_source = g_strdup_printf("-drive file=%s,format=raw", bootpath); arch_target = g_strdup(arch_source); @@ -603,16 +600,13 @@ static int test_migrate_start(QTestState **from, QTestState **to, end_address = X86_TEST_MEM_END; } else if (g_str_equal(arch, "s390x")) { init_bootfile(bootpath, s390x_elf, sizeof(s390x_elf)); - machine_type = ""; - machine_args = ""; memory_size = "128M"; arch_source = g_strdup_printf("-bios %s", bootpath); arch_target = g_strdup(arch_source); start_address = S390_TEST_MEM_START; end_address = S390_TEST_MEM_END; } else if (strcmp(arch, "ppc64") == 0) { - machine_type = ""; - machine_args = ",vsmt=8"; + machine_opts = "vsmt=8"; memory_size = "256M"; arch_source = g_strdup_printf("-nodefaults " "-prom-env 'use-nvramrc?=true' -prom-env " @@ -624,8 +618,7 @@ static int test_migrate_start(QTestState **from, QTestState **to, end_address = PPC_TEST_MEM_END; } else if (strcmp(arch, "aarch64") == 0) { init_bootfile(bootpath, aarch64_kernel, sizeof(aarch64_kernel)); - machine_type = "virt,"; - machine_args = "gic-version=max"; + machine_opts = "virt,gic-version=max"; memory_size = "150M"; arch_source = g_strdup_printf("-cpu max " "-kernel %s", @@ -658,12 +651,13 @@ static int test_migrate_start(QTestState **from, QTestState **to, shmem_opts = g_strdup(""); } - cmd_source = g_strdup_printf("-machine %saccel=kvm:tcg%s " + cmd_source = g_strdup_printf("-accel kvm -accel tcg%s%s " "-name source,debug-threads=on " "-m %s " "-serial file:%s/src_serial " "%s %s %s %s", - machine_type, machine_args, + machine_opts ? " -machine " : "", + machine_opts ? machine_opts : "", memory_size, tmpfs, arch_source, shmem_opts, args->opts_source, ignore_stderr); @@ -671,13 +665,14 @@ static int test_migrate_start(QTestState **from, QTestState **to, *from = qtest_init(cmd_source); g_free(cmd_source); - cmd_target = g_strdup_printf("-machine %saccel=kvm:tcg%s " + cmd_target = g_strdup_printf("-accel kvm -accel tcg%s%s " "-name target,debug-threads=on " "-m %s " "-serial file:%s/dest_serial " "-incoming %s " "%s %s %s %s", - machine_type, machine_args, + machine_opts ? " -machine " : "", + machine_opts ? machine_opts : "", memory_size, tmpfs, uri, arch_target, shmem_opts, args->opts_target, ignore_stderr); diff --git a/tests/pflash-cfi02-test.c b/tests/pflash-cfi02-test.c index d3b23f4..17aa669 100644 --- a/tests/pflash-cfi02-test.c +++ b/tests/pflash-cfi02-test.c @@ -260,7 +260,7 @@ static void test_geometry(const void *opaque) { const FlashConfig *config = opaque; QTestState *qtest; - qtest = qtest_initf("-M musicpal,accel=qtest" + qtest = qtest_initf("-M musicpal" " -drive if=pflash,file=%s,format=raw,copy-on-read" /* Device geometry properties. */ " -global driver=cfi.pflash02," @@ -580,7 +580,7 @@ static void test_cfi_in_autoselect(const void *opaque) { const FlashConfig *config = opaque; QTestState *qtest; - qtest = qtest_initf("-M musicpal,accel=qtest" + qtest = qtest_initf("-M musicpal" " -drive if=pflash,file=%s,format=raw,copy-on-read", image_path); FlashConfig explicit_config = expand_config_defaults(config); diff --git a/tests/pnv-xscom-test.c b/tests/pnv-xscom-test.c index 9fddc7d..2c46d5c 100644 --- a/tests/pnv-xscom-test.c +++ b/tests/pnv-xscom-test.c @@ -84,7 +84,7 @@ static void test_cfam_id(const void *data) machine = "powernv9"; } - qts = qtest_initf("-M %s,accel=tcg -cpu %s", + qts = qtest_initf("-M %s -accel tcg -cpu %s", machine, chip->cpu_model); test_xscom_cfam_id(qts, chip); qtest_quit(qts); @@ -125,7 +125,7 @@ static void test_core(const void *data) machine = "powernv9"; } - qts = qtest_initf("-M %s,accel=tcg -cpu %s", + qts = qtest_initf("-M %s -accel tcg -cpu %s", machine, chip->cpu_model); test_xscom_core(qts, chip); qtest_quit(qts); diff --git a/tests/prom-env-test.c b/tests/prom-env-test.c index 61bc1d1..9be52c7 100644 --- a/tests/prom-env-test.c +++ b/tests/prom-env-test.c @@ -57,7 +57,7 @@ static void test_machine(const void *machine) " -machine cap-cfpc=broken,cap-sbbc=broken,cap-ibs=broken"; } - qts = qtest_initf("-M %s,accel=tcg %s -prom-env 'use-nvramrc?=true' " + qts = qtest_initf("-M %s -accel tcg %s -prom-env 'use-nvramrc?=true' " "-prom-env 'nvramrc=%x %x l!' ", (const char *)machine, extra_args, MAGIC, ADDRESS); check_guest_memory(qts); diff --git a/tests/pxe-test.c b/tests/pxe-test.c index aaae54f..f68d0aa 100644 --- a/tests/pxe-test.c +++ b/tests/pxe-test.c @@ -74,7 +74,7 @@ static void test_pxe_one(const testdef_t *test, bool ipv6) } args = g_strdup_printf( - "-machine %s,accel=kvm:tcg -nodefaults -boot order=n " + "-accel kvm -accel tcg -machine %s -nodefaults -boot order=n " "-netdev user,id=" NETNAME ",tftp=./,bootfile=%s,ipv4=%s,ipv6=%s " "-device %s,bootindex=1,netdev=" NETNAME " %s", test->machine, disk, ipv6 ? "off" : "on", ipv6 ? "on" : "off", diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c index 85d8e64..efba76e 100644 --- a/tests/vmgenid-test.c +++ b/tests/vmgenid-test.c @@ -109,7 +109,7 @@ static void read_guid_from_monitor(QTestState *qts, QemuUUID *guid) static char disk[] = "tests/vmgenid-test-disk-XXXXXX"; #define GUID_CMD(guid) \ - "-machine accel=kvm:tcg " \ + "-accel kvm -accel tcg " \ "-device vmgenid,id=testvgid,guid=%s " \ "-drive id=hd0,if=none,file=%s,format=raw " \ "-device ide-hd,drive=hd0 ", guid, disk -- cgit v1.1 From ee6fe0532c0618e3e556ab1c1c5a24a8aa5f834b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 3 Sep 2019 12:30:48 +0400 Subject: tests: skip block layer tests if !CONFIG_TOOLS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The block tests, as well as ahci-test needs qemu-img. Do not run them if it wasn't built. Signed-off-by: Marc-André Lureau Signed-off-by: Paolo Bonzini --- tests/Makefile.include | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/Makefile.include b/tests/Makefile.include index b381387..31b8667 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -167,7 +167,7 @@ check-qtest-pci-$(CONFIG_IVSHMEM_DEVICE) += tests/ivshmem-test$(EXESUF) check-qtest-i386-$(CONFIG_ISA_TESTDEV) = tests/endianness-test$(EXESUF) check-qtest-i386-y += tests/fdc-test$(EXESUF) check-qtest-i386-y += tests/ide-test$(EXESUF) -check-qtest-i386-y += tests/ahci-test$(EXESUF) +check-qtest-i386-$(CONFIG_TOOLS) += tests/ahci-test$(EXESUF) check-qtest-i386-y += tests/hd-geo-test$(EXESUF) check-qtest-i386-y += tests/boot-order-test$(EXESUF) check-qtest-i386-y += tests/bios-tables-test$(EXESUF) @@ -1191,7 +1191,9 @@ check-acceptance: check-venv $(TESTS_RESULTS_DIR) .PHONY: check-block check-qapi-schema check-qtest check-unit check check-clean check-qapi-schema: check-tests/qapi-schema/frontend check-tests/qapi-schema/doc-good.texi check-qtest: $(patsubst %,check-qtest-%, $(QTEST_TARGETS)) +ifeq ($(CONFIG_TOOLS),y) check-block: $(patsubst %,check-%, $(check-block-y)) +endif check: check-block check-qapi-schema check-unit check-softfloat check-qtest check-decodetree check-clean: rm -rf $(check-unit-y) tests/*.o $(QEMU_IOTESTS_HELPERS-y) -- cgit v1.1 From 30d2a17b46e9b2979e91f6d85c8b0da98879a879 Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Mon, 9 Dec 2019 13:52:45 +0100 Subject: hw/i386: Remove the deprecated machines 0.12 up to 0.15 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These machines can't be used reliably for migration anymore, quoting https://lists.gnu.org/archive/html/qemu-devel/2018-12/msg04516.html : " due to the introduction of the memory API, the firmware is not migrated correctly from source to destination. On QEMU <1.3 the 0xf0000-0xfffff area is basically a copy of the higher 0xffff0000-0xffffffff area, while on more recent versions it is initialized with zeroes and the firmware copies from 0xffff0000 to 0xf0000. When you migrate from old to new QEMU, after reboot there's nothing at 0xf0000 and bugs ensue. " The pc-0.x machines have been marked as deprecated since QEMU v4.0, so it is time to remove them now. And while we're at it, mark the remaining pc-1.x machine types as deprecated now, too, so that we finally only have "pc-i440fx" and "pc-q35" machine types left (apart from the non-versioned "isapc" and "microvm") once we remove them in a couple of releases. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Thomas Huth Message-Id: <20191209125248.5849-2-thuth@redhat.com> Signed-off-by: Paolo Bonzini --- tests/cpu-plug-test.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/cpu-plug-test.c b/tests/cpu-plug-test.c index 30e514b..e8ffbbc 100644 --- a/tests/cpu-plug-test.c +++ b/tests/cpu-plug-test.c @@ -148,11 +148,7 @@ static void add_pc_test_case(const char *mname) (strcmp(mname, "pc-1.3") == 0) || (strcmp(mname, "pc-1.2") == 0) || (strcmp(mname, "pc-1.1") == 0) || - (strcmp(mname, "pc-1.0") == 0) || - (strcmp(mname, "pc-0.15") == 0) || - (strcmp(mname, "pc-0.14") == 0) || - (strcmp(mname, "pc-0.13") == 0) || - (strcmp(mname, "pc-0.12") == 0)) { + (strcmp(mname, "pc-1.0") == 0)) { path = g_strdup_printf("cpu-plug/%s/init/%ux%ux%u&maxcpus=%u", mname, data->sockets, data->cores, data->threads, data->maxcpus); -- cgit v1.1