From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43315) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQUXJ-0000DW-Qr for qemu-devel@nongnu.org; Fri, 22 Jul 2016 03:06:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQUXE-00048t-Gx for qemu-devel@nongnu.org; Fri, 22 Jul 2016 03:06:16 -0400 Received: from ozlabs.org ([103.22.144.67]:47971) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQUXD-00048L-Tz for qemu-devel@nongnu.org; Fri, 22 Jul 2016 03:06:12 -0400 Date: Fri, 22 Jul 2016 16:43:11 +1000 From: David Gibson Message-ID: <20160722064311.GU15941@voom.fritz.box> References: <1469119676-32373-1-git-send-email-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="s6WJ5R58009U+S7n" Content-Disposition: inline In-Reply-To: <1469119676-32373-1-git-send-email-lvivier@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2] test: port postcopy test to ppc64 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laurent Vivier Cc: qemu-devel@nongnu.org, dgilbert@redhat.com, thuth@redhat.com, dgibson@redhat.com --s6WJ5R58009U+S7n Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jul 21, 2016 at 06:47:56PM +0200, Laurent Vivier wrote: > As userfaultfd syscall is available on powerpc, migration > postcopy can be used. >=20 > This patch adds the support needed to test this on powerpc, > instead of using a bootsector to run code to modify memory, > we use a FORTH script in "boot-command" property. >=20 > As spapr machine doesn't support "-prom-env" argument > (the nvram is initialized by SLOF and not by QEMU), > "boot-command" is provided to SLOF via a file mapped nvram > (with "-drive file=3D...,if=3Dpflash") >=20 > Signed-off-by: Laurent Vivier > --- > v2: move FORTH script directly in sprintf() > use openbios_firmware_abi.h > remove useless "default" case >=20 > tests/Makefile.include | 1 + > tests/postcopy-test.c | 116 +++++++++++++++++++++++++++++++++++++++++--= ------ > 2 files changed, 98 insertions(+), 19 deletions(-) There's a mostly cosmetic problem with this. If you run make check for a ppc64 target on an x86 machine, you get: GTESTER check-qtest-ppc64 "kvm" accelerator not found. "kvm" accelerator not found. >=20 > diff --git a/tests/Makefile.include b/tests/Makefile.include > index e7e50d6..e2d1885 100644 > --- a/tests/Makefile.include > +++ b/tests/Makefile.include > @@ -268,6 +268,7 @@ check-qtest-sparc-y +=3D tests/prom-env-test$(EXESUF) > #check-qtest-sparc64-y +=3D tests/prom-env-test$(EXESUF) > check-qtest-microblazeel-y =3D $(check-qtest-microblaze-y) > check-qtest-xtensaeb-y =3D $(check-qtest-xtensa-y) > +check-qtest-ppc64-y +=3D tests/postcopy-test$(EXESUF) > =20 > check-qtest-generic-y +=3D tests/qom-test$(EXESUF) > =20 > diff --git a/tests/postcopy-test.c b/tests/postcopy-test.c > index 16465ab..229e9e9 100644 > --- a/tests/postcopy-test.c > +++ b/tests/postcopy-test.c > @@ -18,6 +18,9 @@ > #include "qemu/sockets.h" > #include "sysemu/char.h" > #include "sysemu/sysemu.h" > +#include "hw/nvram/openbios_firmware_abi.h" > + > +#define MIN_NVRAM_SIZE 8192 /* from spapr_nvram.c */ > =20 > const unsigned start_address =3D 1024 * 1024; > const unsigned end_address =3D 100 * 1024 * 1024; > @@ -122,6 +125,44 @@ unsigned char bootsect[] =3D { > 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa > }; > =20 > +static void init_bootfile_x86(const char *bootpath) > +{ > + FILE *bootfile =3D fopen(bootpath, "wb"); > + > + g_assert_cmpint(fwrite(bootsect, 512, 1, bootfile), =3D=3D, 1); > + fclose(bootfile); > +} > + > +static void init_bootfile_ppc(const char *bootpath) > +{ > + FILE *bootfile; > + char buf[MIN_NVRAM_SIZE]; > + struct OpenBIOS_nvpart_v1 *header =3D (struct OpenBIOS_nvpart_v1 *)b= uf; > + > + memset(buf, 0, MIN_NVRAM_SIZE); > + > + /* Create a "common" partition in nvram to store boot-command proper= ty */ > + > + header->signature =3D OPENBIOS_PART_SYSTEM; > + memcpy(header->name, "common", 6); > + OpenBIOS_finish_partition(header, MIN_NVRAM_SIZE); > + > + /* FW_MAX_SIZE is 4MB, but slof.bin is only 900KB, > + * so let's modify memory between 1MB and 100MB > + * to do like PC bootsector > + */ > + > + sprintf(buf + 16, > + "boot-command=3Dhex .\" _\" begin %x %x do i c@ 1 + i c! 100= 0 +loop " > + ".\" B\" 0 until", end_address, start_address); > + > + /* Write partition to the NVRAM file */ > + > + bootfile =3D fopen(bootpath, "wb"); > + g_assert_cmpint(fwrite(buf, MIN_NVRAM_SIZE, 1, bootfile), =3D=3D, 1); > + fclose(bootfile); > +} > + > /* > * Wait for some output in the serial output file, > * we get an 'A' followed by an endless string of 'B's > @@ -131,10 +172,29 @@ static void wait_for_serial(const char *side) > { > char *serialpath =3D g_strdup_printf("%s/%s", tmpfs, side); > FILE *serialfile =3D fopen(serialpath, "r"); > + const char *arch =3D qtest_get_arch(); > + int started =3D (strcmp(side, "src_serial") =3D=3D 0 && > + strcmp(arch, "ppc64") =3D=3D 0) ? 0 : 1; > =20 > do { > int readvalue =3D fgetc(serialfile); > =20 > + if (!started) { > + /* SLOF prints its banner before starting test, > + * to ignore it, mark the start of the test with '_', > + * ignore all characters until this marker > + */ > + switch (readvalue) { > + case '_': > + started =3D 1; > + break; > + case EOF: > + fseek(serialfile, 0, SEEK_SET); > + usleep(1000); > + break; > + } > + continue; > + } > switch (readvalue) { > case 'A': > /* Fine */ > @@ -147,6 +207,8 @@ static void wait_for_serial(const char *side) > return; > =20 > case EOF: > + started =3D (strcmp(side, "src_serial") =3D=3D 0 && > + strcmp(arch, "ppc64") =3D=3D 0) ? 0 : 1; > fseek(serialfile, 0, SEEK_SET); > usleep(1000); > break; > @@ -295,32 +357,48 @@ static void test_migrate(void) > char *uri =3D g_strdup_printf("unix:%s/migsocket", tmpfs); > QTestState *global =3D global_qtest, *from, *to; > unsigned char dest_byte_a, dest_byte_b, dest_byte_c, dest_byte_d; > - gchar *cmd; > + gchar *cmd, *cmd_src, *cmd_dst; > QDict *rsp; > =20 > char *bootpath =3D g_strdup_printf("%s/bootsect", tmpfs); > - FILE *bootfile =3D fopen(bootpath, "wb"); > + const char *arch =3D qtest_get_arch(); > =20 > got_stop =3D false; > - g_assert_cmpint(fwrite(bootsect, 512, 1, bootfile), =3D=3D, 1); > - fclose(bootfile); > =20 > - cmd =3D g_strdup_printf("-machine accel=3Dkvm:tcg -m 150M" > - " -name pcsource,debug-threads=3Don" > - " -serial file:%s/src_serial" > - " -drive file=3D%s,format=3Draw", > - tmpfs, bootpath); > - from =3D qtest_start(cmd); > - g_free(cmd); > + if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0= ) { > + init_bootfile_x86(bootpath); > + cmd_src =3D g_strdup_printf("-machine accel=3Dkvm:tcg -m 150M" > + " -name pcsource,debug-threads=3Don" > + " -serial file:%s/src_serial" > + " -drive file=3D%s,format=3Draw", > + tmpfs, bootpath); > + cmd_dst =3D g_strdup_printf("-machine accel=3Dkvm:tcg -m 150M" > + " -name pcdest,debug-threads=3Don" > + " -serial file:%s/dest_serial" > + " -drive file=3D%s,format=3Draw" > + " -incoming %s", > + tmpfs, bootpath, uri); > + } else if (strcmp(arch, "ppc64") =3D=3D 0) { > + init_bootfile_ppc(bootpath); > + cmd_src =3D g_strdup_printf("-machine accel=3Dkvm:tcg -m 256M" > + " -name pcsource,debug-threads=3Don" > + " -serial file:%s/src_serial" > + " -drive file=3D%s,if=3Dpflash,format= =3Draw", > + tmpfs, bootpath); > + cmd_dst =3D g_strdup_printf("-machine accel=3Dkvm:tcg -m 256M" > + " -name pcdest,debug-threads=3Don" > + " -serial file:%s/dest_serial" > + " -incoming %s", > + tmpfs, uri); > + } else { > + g_assert_not_reached(); > + } > =20 > - cmd =3D g_strdup_printf("-machine accel=3Dkvm:tcg -m 150M" > - " -name pcdest,debug-threads=3Don" > - " -serial file:%s/dest_serial" > - " -drive file=3D%s,format=3Draw" > - " -incoming %s", > - tmpfs, bootpath, uri); > - to =3D qtest_init(cmd); > - g_free(cmd); > + from =3D qtest_start(cmd_src); > + g_free(cmd_src); > + > + to =3D qtest_init(cmd_dst); > + g_free(cmd_dst); > =20 > global_qtest =3D from; > rsp =3D qmp("{ 'execute': 'migrate-set-capabilities'," --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --s6WJ5R58009U+S7n Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXkcB/AAoJEGw4ysog2bOSLNUP/jNo6PiNp/Ab7GRrLzGGAQxg Irc+4U2Ic4FOwYyE9wo4pJz/BUCaofVhM+N2eJ8zMd/SbIPGepkUX4GuFbHUbqU1 71BD0lDmagkPfsfc7hgIBnSxSYbCLVOntUCuuhrMVSZ3FVXA0e25ZfryCZl8GvSM HBAH+U0kFrDJ7Y4M03kNmsS8c/q2fsbSTNaYp8k2+fYVjzStr9TRAV5r9PHrQFb9 pd46YqXCY0ul7ez14Yppgemttb4CbLIrq7iYyu+UPVGxMHX1n4oaDdgpmPENAMQl 6kvnWKg2Fwk8R2Y0bwSw93L3os9KIW7dxiCuaaF2csEIrRXHGarbCikzLGLa97KH t8PJEnw9NqHjes0f83cF9Qa3ACBbqrEyC4l/767SR0xJsWw63XFnQ/+TKfiiQ0XW P2U14nE4TRV0M/C8e6frZT6H9XyCkjbk73rCfaJhdDNtm54PPLa5rZujXt0EQm0f k7v9HJiTUoRXaVD8bF6uRr60zk6z2E7EzmVvsM4cwsjIZmdTwMdcVG1OCNlYSce5 mkP6Tsy0b7caLyjCcEWKUK2HylKEAsTk0h+tyI8o+iRFCRZ25+UCFCLxksTQbWT4 pVS1r+wndqq8s5CrrQUrfgD/bjnOKCwhNqOfoKxaYvIc5QoWo+WsG9rQxtC3qAIi SMZajDoNK+DymuyIALvj =f/BU -----END PGP SIGNATURE----- --s6WJ5R58009U+S7n--