Re: [Qemu-devel] [PATCH V4 3/3] tests: Add migration test for aarch64

2018-02-26 Thread Wei Huang


On 02/26/2018 03:03 AM, Andrew Jones wrote:
> On Fri, Feb 23, 2018 at 04:13:08PM -0600, Wei Huang wrote:
>>
>>
>> On 02/22/2018 03:00 AM, Andrew Jones wrote:
>>> On Wed, Feb 21, 2018 at 10:44:17PM -0600, 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/. So users can change the
 source and/or re-compile the binary as they wish.

 Signed-off-by: Wei Huang 
 ---
  tests/Makefile.include   |  1 +
  tests/migration-test.c   | 47 +---
  tests/migration/Makefile | 12 +-
  tests/migration/aarch64-a-b-kernel.S | 71 
 
  tests/migration/aarch64-a-b-kernel.h | 19 ++
  tests/migration/migration-test.h |  5 +++
  6 files changed, 147 insertions(+), 8 deletions(-)
  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 a1bcbffe12..df9f64438f 100644
 --- a/tests/Makefile.include
 +++ b/tests/Makefile.include
 @@ -372,6 +372,7 @@ check-qtest-arm-y += tests/sdhci-test$(EXESUF)
  check-qtest-aarch64-y = tests/numa-test$(EXESUF)
  check-qtest-aarch64-y += 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 e2e06ed337..a4f6732a59 100644
 --- a/tests/migration-test.c
 +++ b/tests/migration-test.c
 @@ -11,6 +11,7 @@
   */
  
  #include "qemu/osdep.h"
 +#include 
  
  #include "libqtest.h"
  #include "qapi/qmp/qdict.h"
 @@ -23,8 +24,8 @@
  
  #include "migration/migration-test.h"
  
 -const unsigned start_address = TEST_MEM_START;
 -const unsigned end_address = TEST_MEM_END;
 +unsigned start_address = TEST_MEM_START;
 +unsigned end_address = TEST_MEM_END;
  bool got_stop;
  
  #if defined(__linux__)
 @@ -81,12 +82,13 @@ static const char *tmpfs;
   * outputting 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);
  }
  
 @@ -393,7 +395,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"
 @@ -422,6 +424,39 @@ 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) {
 +const char *cpu;
 +const char *gic_ver;
 +struct utsname utsname;
 +
 +/* kvm and tcg need different cpu and gic-version configs */
 +if (access("/dev/kvm", F_OK) == 0 && uname(&utsname) == 0 &&
 +strcmp(utsname.machine, "aarch64") == 0) {
 +accel = "kvm";
 +cpu = "host";
 +gic_ver = "host";
 +} else {
 +accel = "tcg";
 +cpu = "cortex-a57";
 +gic_ver = "2";
 +}
 +
 +init_bootfile(bootpath, aarch64_kernel);
 +cmd_src = g_strd

Re: [Qemu-devel] [PATCH V4 3/3] tests: Add migration test for aarch64

2018-02-26 Thread Andrew Jones
On Fri, Feb 23, 2018 at 04:13:08PM -0600, Wei Huang wrote:
> 
> 
> On 02/22/2018 03:00 AM, Andrew Jones wrote:
> > On Wed, Feb 21, 2018 at 10:44:17PM -0600, 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/. So users can change the
> >> source and/or re-compile the binary as they wish.
> >>
> >> Signed-off-by: Wei Huang 
> >> ---
> >>  tests/Makefile.include   |  1 +
> >>  tests/migration-test.c   | 47 +---
> >>  tests/migration/Makefile | 12 +-
> >>  tests/migration/aarch64-a-b-kernel.S | 71 
> >> 
> >>  tests/migration/aarch64-a-b-kernel.h | 19 ++
> >>  tests/migration/migration-test.h |  5 +++
> >>  6 files changed, 147 insertions(+), 8 deletions(-)
> >>  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 a1bcbffe12..df9f64438f 100644
> >> --- a/tests/Makefile.include
> >> +++ b/tests/Makefile.include
> >> @@ -372,6 +372,7 @@ check-qtest-arm-y += tests/sdhci-test$(EXESUF)
> >>  check-qtest-aarch64-y = tests/numa-test$(EXESUF)
> >>  check-qtest-aarch64-y += 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 e2e06ed337..a4f6732a59 100644
> >> --- a/tests/migration-test.c
> >> +++ b/tests/migration-test.c
> >> @@ -11,6 +11,7 @@
> >>   */
> >>  
> >>  #include "qemu/osdep.h"
> >> +#include 
> >>  
> >>  #include "libqtest.h"
> >>  #include "qapi/qmp/qdict.h"
> >> @@ -23,8 +24,8 @@
> >>  
> >>  #include "migration/migration-test.h"
> >>  
> >> -const unsigned start_address = TEST_MEM_START;
> >> -const unsigned end_address = TEST_MEM_END;
> >> +unsigned start_address = TEST_MEM_START;
> >> +unsigned end_address = TEST_MEM_END;
> >>  bool got_stop;
> >>  
> >>  #if defined(__linux__)
> >> @@ -81,12 +82,13 @@ static const char *tmpfs;
> >>   * outputting 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);
> >>  }
> >>  
> >> @@ -393,7 +395,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"
> >> @@ -422,6 +424,39 @@ 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) {
> >> +const char *cpu;
> >> +const char *gic_ver;
> >> +struct utsname utsname;
> >> +
> >> +/* kvm and tcg need different cpu and gic-version configs */
> >> +if (access("/dev/kvm", F_OK) == 0 && uname(&utsname) == 0 &&
> >> +strcmp(utsname.machine, "aarch64") == 0) {
> >> +accel = "kvm";
> >> +cpu = "host";
> >> +gic_ver = "host";
> >> +} else {
> >> +accel = "tcg";
> >> +cpu = "cortex-a57";
> >> +gic_ver = "2";
> >> +}
> >> +
> >> +init_bootfile(bootpath, aarch64_kernel);
> >> +cmd_src = g_strdup_printf("-machine virt,accel=%s,gic-version=%s 

Re: [Qemu-devel] [PATCH V4 3/3] tests: Add migration test for aarch64

2018-02-23 Thread Wei Huang


On 02/22/2018 03:00 AM, Andrew Jones wrote:
> On Wed, Feb 21, 2018 at 10:44:17PM -0600, 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/. So users can change the
>> source and/or re-compile the binary as they wish.
>>
>> Signed-off-by: Wei Huang 
>> ---
>>  tests/Makefile.include   |  1 +
>>  tests/migration-test.c   | 47 +---
>>  tests/migration/Makefile | 12 +-
>>  tests/migration/aarch64-a-b-kernel.S | 71 
>> 
>>  tests/migration/aarch64-a-b-kernel.h | 19 ++
>>  tests/migration/migration-test.h |  5 +++
>>  6 files changed, 147 insertions(+), 8 deletions(-)
>>  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 a1bcbffe12..df9f64438f 100644
>> --- a/tests/Makefile.include
>> +++ b/tests/Makefile.include
>> @@ -372,6 +372,7 @@ check-qtest-arm-y += tests/sdhci-test$(EXESUF)
>>  check-qtest-aarch64-y = tests/numa-test$(EXESUF)
>>  check-qtest-aarch64-y += 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 e2e06ed337..a4f6732a59 100644
>> --- a/tests/migration-test.c
>> +++ b/tests/migration-test.c
>> @@ -11,6 +11,7 @@
>>   */
>>  
>>  #include "qemu/osdep.h"
>> +#include 
>>  
>>  #include "libqtest.h"
>>  #include "qapi/qmp/qdict.h"
>> @@ -23,8 +24,8 @@
>>  
>>  #include "migration/migration-test.h"
>>  
>> -const unsigned start_address = TEST_MEM_START;
>> -const unsigned end_address = TEST_MEM_END;
>> +unsigned start_address = TEST_MEM_START;
>> +unsigned end_address = TEST_MEM_END;
>>  bool got_stop;
>>  
>>  #if defined(__linux__)
>> @@ -81,12 +82,13 @@ static const char *tmpfs;
>>   * outputting 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);
>>  }
>>  
>> @@ -393,7 +395,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"
>> @@ -422,6 +424,39 @@ 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) {
>> +const char *cpu;
>> +const char *gic_ver;
>> +struct utsname utsname;
>> +
>> +/* kvm and tcg need different cpu and gic-version configs */
>> +if (access("/dev/kvm", F_OK) == 0 && uname(&utsname) == 0 &&
>> +strcmp(utsname.machine, "aarch64") == 0) {
>> +accel = "kvm";
>> +cpu = "host";
>> +gic_ver = "host";
>> +} else {
>> +accel = "tcg";
>> +cpu = "cortex-a57";
>> +gic_ver = "2";
>> +}
>> +
>> +init_bootfile(bootpath, aarch64_kernel);
>> +cmd_src = g_strdup_printf("-machine virt,accel=%s,gic-version=%s "
>> +  "-name vmsource,debug-threads=on -cpu %s "
>> +  "-m 150M -serial file:%s/src_serial "
>> +  "-kernel %s ",
>> +  accel, gic_ver, cpu, tmpfs, bootpath);
>> +

Re: [Qemu-devel] [PATCH V4 3/3] tests: Add migration test for aarch64

2018-02-22 Thread Andrew Jones
On Wed, Feb 21, 2018 at 10:44:17PM -0600, 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/. So users can change the
> source and/or re-compile the binary as they wish.
> 
> Signed-off-by: Wei Huang 
> ---
>  tests/Makefile.include   |  1 +
>  tests/migration-test.c   | 47 +---
>  tests/migration/Makefile | 12 +-
>  tests/migration/aarch64-a-b-kernel.S | 71 
> 
>  tests/migration/aarch64-a-b-kernel.h | 19 ++
>  tests/migration/migration-test.h |  5 +++
>  6 files changed, 147 insertions(+), 8 deletions(-)
>  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 a1bcbffe12..df9f64438f 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -372,6 +372,7 @@ check-qtest-arm-y += tests/sdhci-test$(EXESUF)
>  check-qtest-aarch64-y = tests/numa-test$(EXESUF)
>  check-qtest-aarch64-y += 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 e2e06ed337..a4f6732a59 100644
> --- a/tests/migration-test.c
> +++ b/tests/migration-test.c
> @@ -11,6 +11,7 @@
>   */
>  
>  #include "qemu/osdep.h"
> +#include 
>  
>  #include "libqtest.h"
>  #include "qapi/qmp/qdict.h"
> @@ -23,8 +24,8 @@
>  
>  #include "migration/migration-test.h"
>  
> -const unsigned start_address = TEST_MEM_START;
> -const unsigned end_address = TEST_MEM_END;
> +unsigned start_address = TEST_MEM_START;
> +unsigned end_address = TEST_MEM_END;
>  bool got_stop;
>  
>  #if defined(__linux__)
> @@ -81,12 +82,13 @@ static const char *tmpfs;
>   * outputting 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);
>  }
>  
> @@ -393,7 +395,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"
> @@ -422,6 +424,39 @@ 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) {
> +const char *cpu;
> +const char *gic_ver;
> +struct utsname utsname;
> +
> +/* kvm and tcg need different cpu and gic-version configs */
> +if (access("/dev/kvm", F_OK) == 0 && uname(&utsname) == 0 &&
> +strcmp(utsname.machine, "aarch64") == 0) {
> +accel = "kvm";
> +cpu = "host";
> +gic_ver = "host";
> +} else {
> +accel = "tcg";
> +cpu = "cortex-a57";
> +gic_ver = "2";
> +}
> +
> +init_bootfile(bootpath, aarch64_kernel);
> +cmd_src = g_strdup_printf("-machine virt,accel=%s,gic-version=%s "
> +  "-name vmsource,debug-threads=on -cpu %s "
> +  "-m 150M -serial file:%s/src_serial "
> +  "-kernel %s ",
> +  accel, gic_ver, cpu, tmpfs, bootpath);
> +cmd_dst = g_strdup_printf("-machine virt,accel=%s,gic-version=%s "
> +  "-name vmdest,debug-threads=on -cpu %s "
> +  

[Qemu-devel] [PATCH V4 3/3] tests: Add migration test for aarch64

2018-02-21 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/. So users can change the
source and/or re-compile the binary as they wish.

Signed-off-by: Wei Huang 
---
 tests/Makefile.include   |  1 +
 tests/migration-test.c   | 47 +---
 tests/migration/Makefile | 12 +-
 tests/migration/aarch64-a-b-kernel.S | 71 
 tests/migration/aarch64-a-b-kernel.h | 19 ++
 tests/migration/migration-test.h |  5 +++
 6 files changed, 147 insertions(+), 8 deletions(-)
 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 a1bcbffe12..df9f64438f 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -372,6 +372,7 @@ check-qtest-arm-y += tests/sdhci-test$(EXESUF)
 check-qtest-aarch64-y = tests/numa-test$(EXESUF)
 check-qtest-aarch64-y += 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 e2e06ed337..a4f6732a59 100644
--- a/tests/migration-test.c
+++ b/tests/migration-test.c
@@ -11,6 +11,7 @@
  */
 
 #include "qemu/osdep.h"
+#include 
 
 #include "libqtest.h"
 #include "qapi/qmp/qdict.h"
@@ -23,8 +24,8 @@
 
 #include "migration/migration-test.h"
 
-const unsigned start_address = TEST_MEM_START;
-const unsigned end_address = TEST_MEM_END;
+unsigned start_address = TEST_MEM_START;
+unsigned end_address = TEST_MEM_END;
 bool got_stop;
 
 #if defined(__linux__)
@@ -81,12 +82,13 @@ static const char *tmpfs;
  * outputting 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);
 }
 
@@ -393,7 +395,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"
@@ -422,6 +424,39 @@ 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) {
+const char *cpu;
+const char *gic_ver;
+struct utsname utsname;
+
+/* kvm and tcg need different cpu and gic-version configs */
+if (access("/dev/kvm", F_OK) == 0 && uname(&utsname) == 0 &&
+strcmp(utsname.machine, "aarch64") == 0) {
+accel = "kvm";
+cpu = "host";
+gic_ver = "host";
+} else {
+accel = "tcg";
+cpu = "cortex-a57";
+gic_ver = "2";
+}
+
+init_bootfile(bootpath, aarch64_kernel);
+cmd_src = g_strdup_printf("-machine virt,accel=%s,gic-version=%s "
+  "-name vmsource,debug-threads=on -cpu %s "
+  "-m 150M -serial file:%s/src_serial "
+  "-kernel %s ",
+  accel, gic_ver, cpu, tmpfs, bootpath);
+cmd_dst = g_strdup_printf("-machine virt,accel=%s,gic-version=%s "
+  "-name vmdest,debug-threads=on -cpu %s "
+  "-m 150M -serial file:%s/dest_serial "
+  "-kernel %s "
+  "-incoming %s ",
+  accel, gic_ver, cpu, tmpfs, bootpath, uri);
+
+/* aarch64 virt machine physical memory st