Re: [Qemu-devel] [PATCH V2 1/1] tests: Add migration test for aarch64

2018-10-11 Thread Dr. David Alan Gilbert
* Wei Huang (w...@redhat.com) wrote:
> This patch adds migration test support for aarch64. The test code, which
> implements the same functionality as x86, is booted as a kernel in qemu.
> Here are the design choices we make for aarch64:
> 
>  * We choose this -kernel approach because aarch64 QEMU doesn't provide a
>built-in fw like x86 does. So instead of relying on a boot loader, we
>use -kernel approach for aarch64.
>  * The serial output is sent to PL011 directly.
>  * The physical memory base for mach-virt machine is 0x4000. We change
>the start_address and end_address for aarch64.
> 
> In addition to providing the binary, this patch also includes the source
> code and the build script in tests/migration/aarch64. So users can change
> the source and/or re-compile the binary as they wish.
> 
> Reviewed-by: Juan Quintela 
> Reviewed-by: Andrew Jones 
> Signed-off-by: Wei Huang 

Queued.
I've removed the blank lines at the end of 
  tests/migration/aarch64/Makefile
  tests/migration/aarch64/a-b-kernel.h

Dave

> ---
>  tests/Makefile.include   |  1 +
>  tests/migration-test.c   | 27 +++--
>  tests/migration/Makefile |  2 +-
>  tests/migration/aarch64/Makefile | 19 +
>  tests/migration/aarch64/a-b-kernel.S | 75 
> 
>  tests/migration/aarch64/a-b-kernel.h | 19 +
>  tests/migration/migration-test.h |  9 +
>  7 files changed, 147 insertions(+), 5 deletions(-)
>  create mode 100644 tests/migration/aarch64/Makefile
>  create mode 100644 tests/migration/aarch64/a-b-kernel.S
>  create mode 100644 tests/migration/aarch64/a-b-kernel.h
> 
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index 175d013..857e7cc 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -402,6 +402,7 @@ check-qtest-arm-y += tests/hexloader-test$(EXESUF)
>  check-qtest-aarch64-y = tests/numa-test$(EXESUF)
>  check-qtest-aarch64-$(CONFIG_SDHCI) += tests/sdhci-test$(EXESUF)
>  check-qtest-aarch64-y += tests/boot-serial-test$(EXESUF)
> +check-qtest-aarch64-y += tests/migration-test$(EXESUF)
>  
>  check-qtest-microblazeel-y = $(check-qtest-microblaze-y)
>  
> diff --git a/tests/migration-test.c b/tests/migration-test.c
> index 20f38f1..5bdc0bd 100644
> --- a/tests/migration-test.c
> +++ b/tests/migration-test.c
> @@ -86,12 +86,13 @@ static const char *tmpfs;
>   * repeatedly. It outputs a 'B' at a fixed rate while it's still running.
>   */
>  #include "tests/migration/i386/a-b-bootblock.h"
> +#include "tests/migration/aarch64/a-b-kernel.h"
>  
> -static void init_bootfile_x86(const char *bootpath)
> +static void init_bootfile(const char *bootpath, void *content)
>  {
>  FILE *bootfile = fopen(bootpath, "wb");
>  
> -g_assert_cmpint(fwrite(x86_bootsect, 512, 1, bootfile), ==, 1);
> +g_assert_cmpint(fwrite(content, 512, 1, bootfile), ==, 1);
>  fclose(bootfile);
>  }
>  
> @@ -428,7 +429,7 @@ static int test_migrate_start(QTestState **from, 
> QTestState **to,
>  got_stop = false;
>  
>  if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
> -init_bootfile_x86(bootpath);
> +init_bootfile(bootpath, x86_bootsect);
>  cmd_src = g_strdup_printf("-machine accel=%s -m 150M"
>" -name source,debug-threads=on"
>" -serial file:%s/src_serial"
> @@ -459,6 +460,24 @@ static int test_migrate_start(QTestState **from, 
> QTestState **to,
>  
>  start_address = PPC_TEST_MEM_START;
>  end_address = PPC_TEST_MEM_END;
> +} else if (strcmp(arch, "aarch64") == 0) {
> +init_bootfile(bootpath, aarch64_kernel);
> +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 ",
> +  accel, tmpfs, bootpath);
> +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 ",
> +  accel, tmpfs, bootpath, uri);
> +
> +start_address = ARM_TEST_MEM_START;
> +end_address = ARM_TEST_MEM_END;
> +
> +g_assert(sizeof(aarch64_kernel) <= ARM_TEST_MAX_KERNEL_SIZE);
>  } else {
>  g_assert_not_reached();
>  }
> @@ -545,7 +564,7 @@ static void test_deprecated(void)
>  {
>  QTestState *from;
>  
> -from = qtest_start("");
> +from = qtest_start("-machine none");
>  
>  deprecated_set_downtime(from, 0.12345);
>  deprecated_set_speed(from, 12345);
> diff --git 

Re: [Qemu-devel] [PATCH V2 1/1] tests: Add migration test for aarch64

2018-10-08 Thread Philippe Mathieu-Daudé



On 04/10/2018 18:08, Wei Huang wrote:
> This patch adds migration test support for aarch64. The test code, which
> implements the same functionality as x86, is booted as a kernel in qemu.
> Here are the design choices we make for aarch64:
> 
>  * We choose this -kernel approach because aarch64 QEMU doesn't provide a
>built-in fw like x86 does. So instead of relying on a boot loader, we
>use -kernel approach for aarch64.
>  * The serial output is sent to PL011 directly.
>  * The physical memory base for mach-virt machine is 0x4000. We change
>the start_address and end_address for aarch64.
> 
> In addition to providing the binary, this patch also includes the source
> code and the build script in tests/migration/aarch64. So users can change
> the source and/or re-compile the binary as they wish.
> 
> Reviewed-by: Juan Quintela 
> Reviewed-by: Andrew Jones 
> Signed-off-by: Wei Huang 

Reviewed-by: Philippe Mathieu-Daudé 
Tested-by: Philippe Mathieu-Daudé 

> ---
>  tests/Makefile.include   |  1 +
>  tests/migration-test.c   | 27 +++--
>  tests/migration/Makefile |  2 +-
>  tests/migration/aarch64/Makefile | 19 +
>  tests/migration/aarch64/a-b-kernel.S | 75 
> 
>  tests/migration/aarch64/a-b-kernel.h | 19 +
>  tests/migration/migration-test.h |  9 +
>  7 files changed, 147 insertions(+), 5 deletions(-)
>  create mode 100644 tests/migration/aarch64/Makefile
>  create mode 100644 tests/migration/aarch64/a-b-kernel.S
>  create mode 100644 tests/migration/aarch64/a-b-kernel.h
> 
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index 175d013..857e7cc 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -402,6 +402,7 @@ check-qtest-arm-y += tests/hexloader-test$(EXESUF)
>  check-qtest-aarch64-y = tests/numa-test$(EXESUF)
>  check-qtest-aarch64-$(CONFIG_SDHCI) += tests/sdhci-test$(EXESUF)
>  check-qtest-aarch64-y += tests/boot-serial-test$(EXESUF)
> +check-qtest-aarch64-y += tests/migration-test$(EXESUF)
>  
>  check-qtest-microblazeel-y = $(check-qtest-microblaze-y)
>  
> diff --git a/tests/migration-test.c b/tests/migration-test.c
> index 20f38f1..5bdc0bd 100644
> --- a/tests/migration-test.c
> +++ b/tests/migration-test.c
> @@ -86,12 +86,13 @@ static const char *tmpfs;
>   * repeatedly. It outputs a 'B' at a fixed rate while it's still running.
>   */
>  #include "tests/migration/i386/a-b-bootblock.h"
> +#include "tests/migration/aarch64/a-b-kernel.h"
>  
> -static void init_bootfile_x86(const char *bootpath)
> +static void init_bootfile(const char *bootpath, void *content)
>  {
>  FILE *bootfile = fopen(bootpath, "wb");
>  
> -g_assert_cmpint(fwrite(x86_bootsect, 512, 1, bootfile), ==, 1);
> +g_assert_cmpint(fwrite(content, 512, 1, bootfile), ==, 1);
>  fclose(bootfile);
>  }
>  
> @@ -428,7 +429,7 @@ static int test_migrate_start(QTestState **from, 
> QTestState **to,
>  got_stop = false;
>  
>  if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
> -init_bootfile_x86(bootpath);
> +init_bootfile(bootpath, x86_bootsect);
>  cmd_src = g_strdup_printf("-machine accel=%s -m 150M"
>" -name source,debug-threads=on"
>" -serial file:%s/src_serial"
> @@ -459,6 +460,24 @@ static int test_migrate_start(QTestState **from, 
> QTestState **to,
>  
>  start_address = PPC_TEST_MEM_START;
>  end_address = PPC_TEST_MEM_END;
> +} else if (strcmp(arch, "aarch64") == 0) {
> +init_bootfile(bootpath, aarch64_kernel);
> +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 ",
> +  accel, tmpfs, bootpath);
> +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 ",
> +  accel, tmpfs, bootpath, uri);
> +
> +start_address = ARM_TEST_MEM_START;
> +end_address = ARM_TEST_MEM_END;
> +
> +g_assert(sizeof(aarch64_kernel) <= ARM_TEST_MAX_KERNEL_SIZE);
>  } else {
>  g_assert_not_reached();
>  }
> @@ -545,7 +564,7 @@ static void test_deprecated(void)
>  {
>  QTestState *from;
>  
> -from = qtest_start("");
> +from = qtest_start("-machine none");
>  
>  deprecated_set_downtime(from, 0.12345);
>  deprecated_set_speed(from, 12345);
> diff --git a/tests/migration/Makefile b/tests/migration/Makefile
> index 

[Qemu-devel] [PATCH V2 1/1] tests: Add migration test for aarch64

2018-10-04 Thread Wei Huang
This patch adds migration test support for aarch64. The test code, which
implements the same functionality as x86, is booted as a kernel in qemu.
Here are the design choices we make for aarch64:

 * We choose this -kernel approach because aarch64 QEMU doesn't provide a
   built-in fw like x86 does. So instead of relying on a boot loader, we
   use -kernel approach for aarch64.
 * The serial output is sent to PL011 directly.
 * The physical memory base for mach-virt machine is 0x4000. We change
   the start_address and end_address for aarch64.

In addition to providing the binary, this patch also includes the source
code and the build script in tests/migration/aarch64. So users can change
the source and/or re-compile the binary as they wish.

Reviewed-by: Juan Quintela 
Reviewed-by: Andrew Jones 
Signed-off-by: Wei Huang 
---
 tests/Makefile.include   |  1 +
 tests/migration-test.c   | 27 +++--
 tests/migration/Makefile |  2 +-
 tests/migration/aarch64/Makefile | 19 +
 tests/migration/aarch64/a-b-kernel.S | 75 
 tests/migration/aarch64/a-b-kernel.h | 19 +
 tests/migration/migration-test.h |  9 +
 7 files changed, 147 insertions(+), 5 deletions(-)
 create mode 100644 tests/migration/aarch64/Makefile
 create mode 100644 tests/migration/aarch64/a-b-kernel.S
 create mode 100644 tests/migration/aarch64/a-b-kernel.h

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 175d013..857e7cc 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -402,6 +402,7 @@ check-qtest-arm-y += tests/hexloader-test$(EXESUF)
 check-qtest-aarch64-y = tests/numa-test$(EXESUF)
 check-qtest-aarch64-$(CONFIG_SDHCI) += tests/sdhci-test$(EXESUF)
 check-qtest-aarch64-y += tests/boot-serial-test$(EXESUF)
+check-qtest-aarch64-y += tests/migration-test$(EXESUF)
 
 check-qtest-microblazeel-y = $(check-qtest-microblaze-y)
 
diff --git a/tests/migration-test.c b/tests/migration-test.c
index 20f38f1..5bdc0bd 100644
--- a/tests/migration-test.c
+++ b/tests/migration-test.c
@@ -86,12 +86,13 @@ static const char *tmpfs;
  * repeatedly. It outputs a 'B' at a fixed rate while it's still running.
  */
 #include "tests/migration/i386/a-b-bootblock.h"
+#include "tests/migration/aarch64/a-b-kernel.h"
 
-static void init_bootfile_x86(const char *bootpath)
+static void init_bootfile(const char *bootpath, void *content)
 {
 FILE *bootfile = fopen(bootpath, "wb");
 
-g_assert_cmpint(fwrite(x86_bootsect, 512, 1, bootfile), ==, 1);
+g_assert_cmpint(fwrite(content, 512, 1, bootfile), ==, 1);
 fclose(bootfile);
 }
 
@@ -428,7 +429,7 @@ static int test_migrate_start(QTestState **from, QTestState 
**to,
 got_stop = false;
 
 if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
-init_bootfile_x86(bootpath);
+init_bootfile(bootpath, x86_bootsect);
 cmd_src = g_strdup_printf("-machine accel=%s -m 150M"
   " -name source,debug-threads=on"
   " -serial file:%s/src_serial"
@@ -459,6 +460,24 @@ static int test_migrate_start(QTestState **from, 
QTestState **to,
 
 start_address = PPC_TEST_MEM_START;
 end_address = PPC_TEST_MEM_END;
+} else if (strcmp(arch, "aarch64") == 0) {
+init_bootfile(bootpath, aarch64_kernel);
+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 ",
+  accel, tmpfs, bootpath);
+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 ",
+  accel, tmpfs, bootpath, uri);
+
+start_address = ARM_TEST_MEM_START;
+end_address = ARM_TEST_MEM_END;
+
+g_assert(sizeof(aarch64_kernel) <= ARM_TEST_MAX_KERNEL_SIZE);
 } else {
 g_assert_not_reached();
 }
@@ -545,7 +564,7 @@ static void test_deprecated(void)
 {
 QTestState *from;
 
-from = qtest_start("");
+from = qtest_start("-machine none");
 
 deprecated_set_downtime(from, 0.12345);
 deprecated_set_speed(from, 12345);
diff --git a/tests/migration/Makefile b/tests/migration/Makefile
index dc3b551..91237a8 100644
--- a/tests/migration/Makefile
+++ b/tests/migration/Makefile
@@ -5,7 +5,7 @@
 # See the COPYING file in the top-level directory.
 #
 
-TARGET_LIST = i386
+TARGET_LIST = i386 aarch64
 
 SRC_PATH = ../..
 
diff --git a/tests/migration/aarch64/Makefile b/tests/migration/aarch64/Makefile
new file mode 100644
index 

Re: [Qemu-devel] [PATCH V2 1/1] tests: Add migration test for aarch64

2018-02-15 Thread Andrew Jones
On Wed, Feb 14, 2018 at 02:17:34PM -0600, Wei Huang wrote:
> 
> 
> On 02/12/2018 11:31 AM, Andrew Jones wrote:
> > On Fri, Feb 09, 2018 at 04:42:42PM -0500, Wei Huang wrote:
> >> This patch adds migration test support for aarch64. The test code, which
> >> implements the same functionality as x86, is booted as a kernel in qemu.
> >> Here are the design choices we make for aarch64:
> >>
> >>  * We choose this -kernel approach because aarch64 QEMU doesn't provide a
> >>built-in fw like x86 does. So instead of relying on a boot loader, we
> >>use -kernel approach for aarch64.
> >>  * The serial output is sent to PL011 directly.
> >>  * The physical memory base for mach-virt machine is 0x4000. We change
> >>the start_address and end_address for aarch64.
> >>
> >> In addition to providing the binary, this patch also includes the test 
> >> source
> >> and the build script in tests/migration. So users can change/re-compile
> >> the binary as they wish.
> >>
> >> Signed-off-by: Wei Huang 
> >> ---
> >>  tests/Makefile.include|  1 +
> >>  tests/migration-test.c| 29 ++---
> >>  tests/migration/aarch64-a-b-kernel.h  | 19 +
> >>  tests/migration/aarch64-a-b-kernel.s  | 67 
> >> +++
> >>  tests/migration/rebuild-aarch64-kernel.sh | 67 
> >> +++
> >>  5 files changed, 177 insertions(+), 6 deletions(-)
> >>  create mode 100644 tests/migration/aarch64-a-b-kernel.h
> >>  create mode 100644 tests/migration/aarch64-a-b-kernel.s
> >>  create mode 100755 tests/migration/rebuild-aarch64-kernel.sh
> >>
> >> diff --git a/tests/Makefile.include b/tests/Makefile.include
> >> index f41da23..0fd18fd 100644
> >> --- a/tests/Makefile.include
> >> +++ b/tests/Makefile.include
> >> @@ -369,6 +369,7 @@ gcov-files-arm-y += hw/timer/arm_mptimer.c
> >>  check-qtest-arm-y += tests/boot-serial-test$(EXESUF)
> >>  
> >>  check-qtest-aarch64-y = tests/numa-test$(EXESUF)
> >> +check-qtest-aarch64-y += tests/migration-test$(EXESUF)
> >>  
> >>  check-qtest-microblazeel-y = $(check-qtest-microblaze-y)
> >>  
> >> diff --git a/tests/migration-test.c b/tests/migration-test.c
> >> index 85d4014..b16944c 100644
> >> --- a/tests/migration-test.c
> >> +++ b/tests/migration-test.c
> >> @@ -22,8 +22,8 @@
> >>  
> >>  #define MIN_NVRAM_SIZE 8192 /* from spapr_nvram.c */
> >>  
> >> -const unsigned start_address = 1024 * 1024;
> >> -const unsigned end_address = 100 * 1024 * 1024;
> >> +unsigned start_address = 1024 * 1024;
> >> +unsigned end_address = 100 * 1024 * 1024;
> >>  bool got_stop;
> >>  
> >>  #if defined(__linux__)
> >> @@ -80,12 +80,13 @@ static const char *tmpfs;
> >>   * outputing a 'B' every so often if it's still running.
> >>   */
> >>  #include "tests/migration/x86-a-b-bootblock.h"
> >> +#include "tests/migration/aarch64-a-b-kernel.h"
> >>  
> >> -static void init_bootfile_x86(const char *bootpath)
> >> +static void init_bootfile(const char *bootpath, void *content)
> >>  {
> >>  FILE *bootfile = fopen(bootpath, "wb");
> >>  
> >> -g_assert_cmpint(fwrite(x86_bootsect, 512, 1, bootfile), ==, 1);
> >> +g_assert_cmpint(fwrite(content, 512, 1, bootfile), ==, 1);
> >>  fclose(bootfile);
> >>  }
> >>  
> >> @@ -391,7 +392,7 @@ static void test_migrate_start(QTestState **from, 
> >> QTestState **to,
> >>  got_stop = false;
> >>  
> >>  if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
> >> -init_bootfile_x86(bootpath);
> >> +init_bootfile(bootpath, x86_bootsect);
> >>  cmd_src = g_strdup_printf("-machine accel=%s -m 150M"
> >>" -name source,debug-threads=on"
> >>" -serial file:%s/src_serial"
> >> @@ -420,6 +421,22 @@ static void test_migrate_start(QTestState **from, 
> >> QTestState **to,
> >>" -serial file:%s/dest_serial"
> >>" -incoming %s",
> >>accel, tmpfs, uri);
> >> +} else if (strcmp(arch, "aarch64") == 0) {
> >> +init_bootfile(bootpath, aarch64_kernel);
> >> +cmd_src = g_strdup_printf("-machine virt,accel=kvm:tcg -m 150M "
> >> +  "-name vmsource,debug-threads=on -cpu 
> >> host "
> > 
> > We can't use '-cpu host' with tcg, so the accel fallback won't work.
> 
> Will fix
> 
> > 
> >> +  "-serial file:%s/src_serial "
> >> +  "-kernel %s ",
> >> +  tmpfs, bootpath);
> >> +cmd_dst = g_strdup_printf("-machine virt,accel=kvm:tcg -m 150M "
> >> +  "-name vmdest,debug-threads=on -cpu 
> >> host "
> >> +  "-serial file:%s/dest_serial "
> >> +  "-kernel %s "
> >> +  "-incoming %s 

Re: [Qemu-devel] [PATCH V2 1/1] tests: Add migration test for aarch64

2018-02-14 Thread Wei Huang


On 02/12/2018 11:31 AM, Andrew Jones wrote:
> On Fri, Feb 09, 2018 at 04:42:42PM -0500, Wei Huang wrote:
>> This patch adds migration test support for aarch64. The test code, which
>> implements the same functionality as x86, is booted as a kernel in qemu.
>> Here are the design choices we make for aarch64:
>>
>>  * We choose this -kernel approach because aarch64 QEMU doesn't provide a
>>built-in fw like x86 does. So instead of relying on a boot loader, we
>>use -kernel approach for aarch64.
>>  * The serial output is sent to PL011 directly.
>>  * The physical memory base for mach-virt machine is 0x4000. We change
>>the start_address and end_address for aarch64.
>>
>> In addition to providing the binary, this patch also includes the test source
>> and the build script in tests/migration. So users can change/re-compile
>> the binary as they wish.
>>
>> Signed-off-by: Wei Huang 
>> ---
>>  tests/Makefile.include|  1 +
>>  tests/migration-test.c| 29 ++---
>>  tests/migration/aarch64-a-b-kernel.h  | 19 +
>>  tests/migration/aarch64-a-b-kernel.s  | 67 
>> +++
>>  tests/migration/rebuild-aarch64-kernel.sh | 67 
>> +++
>>  5 files changed, 177 insertions(+), 6 deletions(-)
>>  create mode 100644 tests/migration/aarch64-a-b-kernel.h
>>  create mode 100644 tests/migration/aarch64-a-b-kernel.s
>>  create mode 100755 tests/migration/rebuild-aarch64-kernel.sh
>>
>> diff --git a/tests/Makefile.include b/tests/Makefile.include
>> index f41da23..0fd18fd 100644
>> --- a/tests/Makefile.include
>> +++ b/tests/Makefile.include
>> @@ -369,6 +369,7 @@ gcov-files-arm-y += hw/timer/arm_mptimer.c
>>  check-qtest-arm-y += tests/boot-serial-test$(EXESUF)
>>  
>>  check-qtest-aarch64-y = tests/numa-test$(EXESUF)
>> +check-qtest-aarch64-y += tests/migration-test$(EXESUF)
>>  
>>  check-qtest-microblazeel-y = $(check-qtest-microblaze-y)
>>  
>> diff --git a/tests/migration-test.c b/tests/migration-test.c
>> index 85d4014..b16944c 100644
>> --- a/tests/migration-test.c
>> +++ b/tests/migration-test.c
>> @@ -22,8 +22,8 @@
>>  
>>  #define MIN_NVRAM_SIZE 8192 /* from spapr_nvram.c */
>>  
>> -const unsigned start_address = 1024 * 1024;
>> -const unsigned end_address = 100 * 1024 * 1024;
>> +unsigned start_address = 1024 * 1024;
>> +unsigned end_address = 100 * 1024 * 1024;
>>  bool got_stop;
>>  
>>  #if defined(__linux__)
>> @@ -80,12 +80,13 @@ static const char *tmpfs;
>>   * outputing a 'B' every so often if it's still running.
>>   */
>>  #include "tests/migration/x86-a-b-bootblock.h"
>> +#include "tests/migration/aarch64-a-b-kernel.h"
>>  
>> -static void init_bootfile_x86(const char *bootpath)
>> +static void init_bootfile(const char *bootpath, void *content)
>>  {
>>  FILE *bootfile = fopen(bootpath, "wb");
>>  
>> -g_assert_cmpint(fwrite(x86_bootsect, 512, 1, bootfile), ==, 1);
>> +g_assert_cmpint(fwrite(content, 512, 1, bootfile), ==, 1);
>>  fclose(bootfile);
>>  }
>>  
>> @@ -391,7 +392,7 @@ static void test_migrate_start(QTestState **from, 
>> QTestState **to,
>>  got_stop = false;
>>  
>>  if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
>> -init_bootfile_x86(bootpath);
>> +init_bootfile(bootpath, x86_bootsect);
>>  cmd_src = g_strdup_printf("-machine accel=%s -m 150M"
>>" -name source,debug-threads=on"
>>" -serial file:%s/src_serial"
>> @@ -420,6 +421,22 @@ static void test_migrate_start(QTestState **from, 
>> QTestState **to,
>>" -serial file:%s/dest_serial"
>>" -incoming %s",
>>accel, tmpfs, uri);
>> +} else if (strcmp(arch, "aarch64") == 0) {
>> +init_bootfile(bootpath, aarch64_kernel);
>> +cmd_src = g_strdup_printf("-machine virt,accel=kvm:tcg -m 150M "
>> +  "-name vmsource,debug-threads=on -cpu 
>> host "
> 
> We can't use '-cpu host' with tcg, so the accel fallback won't work.

Will fix

> 
>> +  "-serial file:%s/src_serial "
>> +  "-kernel %s ",
>> +  tmpfs, bootpath);
>> +cmd_dst = g_strdup_printf("-machine virt,accel=kvm:tcg -m 150M "
>> +  "-name vmdest,debug-threads=on -cpu host "
>> +  "-serial file:%s/dest_serial "
>> +  "-kernel %s "
>> +  "-incoming %s ",
>> +  tmpfs, bootpath, uri);
>> +/* aarch64 virt machine physical mem started from 0x4000 */
> 
> s/mem started from/memory starts at/

will fix

> 
>> +start_address += 0x4000;
>> +end_address += 0x4000;
> 
> Why is 

Re: [Qemu-devel] [PATCH V2 1/1] tests: Add migration test for aarch64

2018-02-12 Thread Andrew Jones
On Fri, Feb 09, 2018 at 04:42:42PM -0500, Wei Huang wrote:
> This patch adds migration test support for aarch64. The test code, which
> implements the same functionality as x86, is booted as a kernel in qemu.
> Here are the design choices we make for aarch64:
> 
>  * We choose this -kernel approach because aarch64 QEMU doesn't provide a
>built-in fw like x86 does. So instead of relying on a boot loader, we
>use -kernel approach for aarch64.
>  * The serial output is sent to PL011 directly.
>  * The physical memory base for mach-virt machine is 0x4000. We change
>the start_address and end_address for aarch64.
> 
> In addition to providing the binary, this patch also includes the test source
> and the build script in tests/migration. So users can change/re-compile
> the binary as they wish.
> 
> Signed-off-by: Wei Huang 
> ---
>  tests/Makefile.include|  1 +
>  tests/migration-test.c| 29 ++---
>  tests/migration/aarch64-a-b-kernel.h  | 19 +
>  tests/migration/aarch64-a-b-kernel.s  | 67 
> +++
>  tests/migration/rebuild-aarch64-kernel.sh | 67 
> +++
>  5 files changed, 177 insertions(+), 6 deletions(-)
>  create mode 100644 tests/migration/aarch64-a-b-kernel.h
>  create mode 100644 tests/migration/aarch64-a-b-kernel.s
>  create mode 100755 tests/migration/rebuild-aarch64-kernel.sh
> 
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index f41da23..0fd18fd 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -369,6 +369,7 @@ gcov-files-arm-y += hw/timer/arm_mptimer.c
>  check-qtest-arm-y += tests/boot-serial-test$(EXESUF)
>  
>  check-qtest-aarch64-y = tests/numa-test$(EXESUF)
> +check-qtest-aarch64-y += tests/migration-test$(EXESUF)
>  
>  check-qtest-microblazeel-y = $(check-qtest-microblaze-y)
>  
> diff --git a/tests/migration-test.c b/tests/migration-test.c
> index 85d4014..b16944c 100644
> --- a/tests/migration-test.c
> +++ b/tests/migration-test.c
> @@ -22,8 +22,8 @@
>  
>  #define MIN_NVRAM_SIZE 8192 /* from spapr_nvram.c */
>  
> -const unsigned start_address = 1024 * 1024;
> -const unsigned end_address = 100 * 1024 * 1024;
> +unsigned start_address = 1024 * 1024;
> +unsigned end_address = 100 * 1024 * 1024;
>  bool got_stop;
>  
>  #if defined(__linux__)
> @@ -80,12 +80,13 @@ static const char *tmpfs;
>   * outputing a 'B' every so often if it's still running.
>   */
>  #include "tests/migration/x86-a-b-bootblock.h"
> +#include "tests/migration/aarch64-a-b-kernel.h"
>  
> -static void init_bootfile_x86(const char *bootpath)
> +static void init_bootfile(const char *bootpath, void *content)
>  {
>  FILE *bootfile = fopen(bootpath, "wb");
>  
> -g_assert_cmpint(fwrite(x86_bootsect, 512, 1, bootfile), ==, 1);
> +g_assert_cmpint(fwrite(content, 512, 1, bootfile), ==, 1);
>  fclose(bootfile);
>  }
>  
> @@ -391,7 +392,7 @@ static void test_migrate_start(QTestState **from, 
> QTestState **to,
>  got_stop = false;
>  
>  if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
> -init_bootfile_x86(bootpath);
> +init_bootfile(bootpath, x86_bootsect);
>  cmd_src = g_strdup_printf("-machine accel=%s -m 150M"
>" -name source,debug-threads=on"
>" -serial file:%s/src_serial"
> @@ -420,6 +421,22 @@ static void test_migrate_start(QTestState **from, 
> QTestState **to,
>" -serial file:%s/dest_serial"
>" -incoming %s",
>accel, tmpfs, uri);
> +} else if (strcmp(arch, "aarch64") == 0) {
> +init_bootfile(bootpath, aarch64_kernel);
> +cmd_src = g_strdup_printf("-machine virt,accel=kvm:tcg -m 150M "
> +  "-name vmsource,debug-threads=on -cpu host 
> "

We can't use '-cpu host' with tcg, so the accel fallback won't work.

> +  "-serial file:%s/src_serial "
> +  "-kernel %s ",
> +  tmpfs, bootpath);
> +cmd_dst = g_strdup_printf("-machine virt,accel=kvm:tcg -m 150M "
> +  "-name vmdest,debug-threads=on -cpu host "
> +  "-serial file:%s/dest_serial "
> +  "-kernel %s "
> +  "-incoming %s ",
> +  tmpfs, bootpath, uri);
> +/* aarch64 virt machine physical mem started from 0x4000 */

s/mem started from/memory starts at/

> +start_address += 0x4000;
> +end_address += 0x4000;

Why is end_address == start_address?

>  } else {
>  g_assert_not_reached();
>  }
> @@ -501,7 +518,7 @@ static void test_deprecated(void)
>  {
>  QTestState *from;
>  
> -

[Qemu-devel] [PATCH V2 1/1] tests: Add migration test for aarch64

2018-02-09 Thread Wei Huang
This patch adds migration test support for aarch64. The test code, which
implements the same functionality as x86, is booted as a kernel in qemu.
Here are the design choices we make for aarch64:

 * We choose this -kernel approach because aarch64 QEMU doesn't provide a
   built-in fw like x86 does. So instead of relying on a boot loader, we
   use -kernel approach for aarch64.
 * The serial output is sent to PL011 directly.
 * The physical memory base for mach-virt machine is 0x4000. We change
   the start_address and end_address for aarch64.

In addition to providing the binary, this patch also includes the test source
and the build script in tests/migration. So users can change/re-compile
the binary as they wish.

Signed-off-by: Wei Huang 
---
 tests/Makefile.include|  1 +
 tests/migration-test.c| 29 ++---
 tests/migration/aarch64-a-b-kernel.h  | 19 +
 tests/migration/aarch64-a-b-kernel.s  | 67 +++
 tests/migration/rebuild-aarch64-kernel.sh | 67 +++
 5 files changed, 177 insertions(+), 6 deletions(-)
 create mode 100644 tests/migration/aarch64-a-b-kernel.h
 create mode 100644 tests/migration/aarch64-a-b-kernel.s
 create mode 100755 tests/migration/rebuild-aarch64-kernel.sh

diff --git a/tests/Makefile.include b/tests/Makefile.include
index f41da23..0fd18fd 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -369,6 +369,7 @@ gcov-files-arm-y += hw/timer/arm_mptimer.c
 check-qtest-arm-y += tests/boot-serial-test$(EXESUF)
 
 check-qtest-aarch64-y = tests/numa-test$(EXESUF)
+check-qtest-aarch64-y += tests/migration-test$(EXESUF)
 
 check-qtest-microblazeel-y = $(check-qtest-microblaze-y)
 
diff --git a/tests/migration-test.c b/tests/migration-test.c
index 85d4014..b16944c 100644
--- a/tests/migration-test.c
+++ b/tests/migration-test.c
@@ -22,8 +22,8 @@
 
 #define MIN_NVRAM_SIZE 8192 /* from spapr_nvram.c */
 
-const unsigned start_address = 1024 * 1024;
-const unsigned end_address = 100 * 1024 * 1024;
+unsigned start_address = 1024 * 1024;
+unsigned end_address = 100 * 1024 * 1024;
 bool got_stop;
 
 #if defined(__linux__)
@@ -80,12 +80,13 @@ static const char *tmpfs;
  * outputing a 'B' every so often if it's still running.
  */
 #include "tests/migration/x86-a-b-bootblock.h"
+#include "tests/migration/aarch64-a-b-kernel.h"
 
-static void init_bootfile_x86(const char *bootpath)
+static void init_bootfile(const char *bootpath, void *content)
 {
 FILE *bootfile = fopen(bootpath, "wb");
 
-g_assert_cmpint(fwrite(x86_bootsect, 512, 1, bootfile), ==, 1);
+g_assert_cmpint(fwrite(content, 512, 1, bootfile), ==, 1);
 fclose(bootfile);
 }
 
@@ -391,7 +392,7 @@ static void test_migrate_start(QTestState **from, 
QTestState **to,
 got_stop = false;
 
 if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
-init_bootfile_x86(bootpath);
+init_bootfile(bootpath, x86_bootsect);
 cmd_src = g_strdup_printf("-machine accel=%s -m 150M"
   " -name source,debug-threads=on"
   " -serial file:%s/src_serial"
@@ -420,6 +421,22 @@ static void test_migrate_start(QTestState **from, 
QTestState **to,
   " -serial file:%s/dest_serial"
   " -incoming %s",
   accel, tmpfs, uri);
+} else if (strcmp(arch, "aarch64") == 0) {
+init_bootfile(bootpath, aarch64_kernel);
+cmd_src = g_strdup_printf("-machine virt,accel=kvm:tcg -m 150M "
+  "-name vmsource,debug-threads=on -cpu host "
+  "-serial file:%s/src_serial "
+  "-kernel %s ",
+  tmpfs, bootpath);
+cmd_dst = g_strdup_printf("-machine virt,accel=kvm:tcg -m 150M "
+  "-name vmdest,debug-threads=on -cpu host "
+  "-serial file:%s/dest_serial "
+  "-kernel %s "
+  "-incoming %s ",
+  tmpfs, bootpath, uri);
+/* aarch64 virt machine physical mem started from 0x4000 */
+start_address += 0x4000;
+end_address += 0x4000;
 } else {
 g_assert_not_reached();
 }
@@ -501,7 +518,7 @@ static void test_deprecated(void)
 {
 QTestState *from;
 
-from = qtest_start("");
+from = qtest_start("-machine none");
 
 deprecated_set_downtime(from, 0.12345);
 deprecated_set_speed(from, "12345");
diff --git a/tests/migration/aarch64-a-b-kernel.h 
b/tests/migration/aarch64-a-b-kernel.h
new file mode 100644
index 000..5bdc74b
--- /dev/null
+++ b/tests/migration/aarch64-a-b-kernel.h
@@ -0,0 +1,19 @@
+/* This file is automatically generated from
+ *