Migration Arguments cleanup
v2 cover Migration Arguments cleanup
[v2]
- fix use-after-free (thanks peter)
[v1]
This series simplify test_migrate_start() in two ways:
- simplify the command line creation, so everything that is common between architectures don't have to be repeated (DRY).
Note that this bit remove lines of code.
- test_migrate_start() has two bools and two strings as arguments, it is very difficult to remmeber which is which and meaning. And it is even worse to add new parameters. Just pass them through one struct.
Please, review.
Juan Quintela (10):
migration-test: Create cmd_soure and cmd_target
migration-test: Move hide_stderr to common commandline
migration-test: Move -machine to common commandline
migration-test: Move memory size to common commandline
migration-test: Move shmem handling to common commandline
migration-test: Move -name handling to common commandline
migration-test: Move -serial handling to common commandline
migration-test: Move -incomming handling to common commandline
migration-test: Rename cmd_src/dst to arch_source/arch_target
migration-test: Use a struct for test_migrate_start parameters
tests/migration-test.c | 269 +++++++++++++++++++++++------------------ 1 file changed, 149 insertions(+), 120 deletions(-)
Signature · 1 line
2.23.0
PATCH v2 1/10 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.
--- tests/migration-test.c | 44 ++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 19 deletions(-)
tests/migration-test.c +25 -19
@@ -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.
Signature · 1 line
2.23.0
Re: [PATCH v2 01/10] migration-test: Create cmd_soure and cmd_target
Quoted 14 lines · Juan Quintela
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_srcandopts_dst.Signed-off-by Juan Quintela <[email protected]>--- tests/migration-test.c | 44 ++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 19 deletions(-)tests/migration-test.c +0
-0
tests/migration-test.c static int test_migrate_start(QTestState **from, QTestState **to, · line 560
Quoted 4 lines
tests/migration-test.c +1
-0@@ -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;
The naming looks quite unfortunate to me ... "cmd_src" can easily be mixed up with "cmd_source" ... but maybe you could do it without these additional variables (see below) ...
[...]
Quoted 7 lines
tests/migration-test.c +2
-1@@ -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);
tests/migration-test.c static int test_migrate_start(QTestState **from, QTestState **to, · line 684
Quoted 10 lines
tests/migration-test.c +6
-1g_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);
May I suggest to qtest_initf() here instead:
*from = qtest_initf("%s %s", cmd_src, opts_src);
*to = qtest_initf("%s %s", cmd_dst, opts_dst);And maybe you could even move the extra_opts here, too? e.g.:
*from = qtest_initf("%s %s %s", cmd_src, extra_opts ?: "", opts_src);
*to = qtest_initf("%s %s %s", cmd_dst, extra_opts ?: "", opts_dst);Thomas
Re: [PATCH v2 01/10] migration-test: Create cmd_soure and cmd_target
Quoted 23 lines · Thomas Huth
Quoted 14 lines · Juan Quintela
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_srcandopts_dst.Signed-off-by Juan Quintela <[email protected]>--- tests/migration-test.c | 44 ++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 19 deletions(-)tests/migration-test.c +0
-0tests/migration-test.c static int test_migrate_start(QTestState **from, QTestState **to, · line 560
Quoted 4 lines
tests/migration-test.c +1
-0@@ -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;The naming looks quite unfortunate to me ... "
cmd_src" can easily be mixed up with "cmd_source" ... but maybe you could do it without these additional variables (see below) ...
[...]
Quoted 7 lines
May I suggest to
qtest_initf()here instead:*from = qtest_initf("%s %s", cmd_src, opts_src); *to = qtest_initf("%s %s", cmd_dst, opts_dst);
Quoted 7 lines
And maybe you could even move the
extra_optshere, too? e.g.:*from = qtest_initf("%s %s %s", cmd_src, extra_opts ?: "", opts_src); *to = qtest_initf("%s %s %s", cmd_dst, extra_opts ?: "", opts_dst);Thomas
I do that on later patches. But the _final_ better name that I could get with was "cmd_source". cmd_src ends being arch_source.
About using qtest_initf():
- I didn't knew it's existence (O:-)
- I was considering about merning the command parts of cmd_source/target But arrived to the conclusion that it was more complicated to have it share it, that to repeat it. But you need to look at the last patch to arrive to one conclusion.
Thanks, Juan.
PATCH v2 2/10 migration-test: Move hide_stderr to common commandline
In reply to Juan Quintela--- tests/migration-test.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)
tests/migration-test.c +8 -12
@@ -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);
Signature · 1 line
2.23.0
PATCH v2 3/10 migration-test: Move -machine to common commandline
In reply to Juan Quintela--- tests/migration-test.c | 51 +++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 21 deletions(-)
tests/migration-test.c +30 -21
@@ -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);
Signature · 1 line
2.23.0
PATCH v2 4/10 migration-test: Move memory size to common commandline
In reply to Juan Quintela--- tests/migration-test.c | 44 ++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 19 deletions(-)
tests/migration-test.c +25 -19
@@ -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);
Signature · 1 line
2.23.0
PATCH v2 5/10 migration-test: Move shmem handling to common commandline
In reply to Juan Quintela--- tests/migration-test.c | 76 +++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 42 deletions(-)
tests/migration-test.c +34 -42
@@ -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
Signature · 1 line
2.23.0
PATCH v2 6/10 migration-test: Move -name handling to common commandline
In reply to Juan Quintela--- tests/migration-test.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
tests/migration-test.c +9 -13
@@ -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,
Signature · 1 line
2.23.0
PATCH v2 7/10 migration-test: Move -serial handling to common commandline
In reply to Juan Quintela--- tests/migration-test.c | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-)
tests/migration-test.c +16 -25
@@ -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);
Signature · 1 line
2.23.0
PATCH v2 8/10 migration-test: Move -incomming handling to common commandline
In reply to Juan Quintela--- tests/migration-test.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-)
tests/migration-test.c +8 -15
@@ -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);
Signature · 1 line
2.23.0
Re: [PATCH v2 08/10] migration-test: Move -incomming handling to common commandline
You've got a typo in the subject: Please replace "incomming" with "incoming".
Thanks,
Thomas
PATCH v2 9/10 migration-test: Rename cmd_src/dst to arch_source/arch_target
In reply to Juan QuintelaThis explains better what they do and avoid confussino with command_src/target.
--- tests/migration-test.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-)
tests/migration-test.c +21 -19
@@ -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);
Signature · 1 line
2.23.0
Re: [PATCH v2 09/10] migration-test: Rename cmd_src/dst to arch_source/arch_target
Quoted 2 lines · Juan Quintela
This explains better what they do and avoid confussino with command_src/target.
s/confussino/confusion/
Cheers,
Thomas
PATCH v2 10/10 migration-test: Use a struct for test_migrate_start parameters
In reply to Juan QuintelaIt 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.
---
Move the free after last use.
--- tests/migration-test.c | 118 +++++++++++++++++++++++++++-------------- 1 file changed, 78 insertions(+), 40 deletions(-)
tests/migration-test.c +78 -40
@@ -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,10 +690,11 @@ 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 ; }
Signature · 1 line
2.23.0