From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44019) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSCyn-00028r-A3 for qemu-devel@nongnu.org; Tue, 26 Jul 2016 20:45:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bSCyj-0001hG-1c for qemu-devel@nongnu.org; Tue, 26 Jul 2016 20:45:44 -0400 Received: from ozlabs.org ([103.22.144.67]:57970) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSCyi-0001gq-0p for qemu-devel@nongnu.org; Tue, 26 Jul 2016 20:45:40 -0400 Date: Wed, 27 Jul 2016 10:43:07 +1000 From: David Gibson Message-ID: <20160727004307.GO17429@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="lLR1BQqf7txDtYcF" 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 --lLR1BQqf7txDtYcF 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 So, the warning message is a bit unfortunate, but the following discussion seems to show that removing it isn't trivial. If we can do so in a follow up patch, that would be nice, but for the time being, I've merged this patch to ppc-for-2.7 anyway. > --- > 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(-) >=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 --lLR1BQqf7txDtYcF Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXmAOaAAoJEGw4ysog2bOSwJwP/2KRfHRCIRCwtG2XwSeAQRkM vQpD7Ld6XotTvmIPXeK7udAanClicOVZ4igBB75O7vcWWaMrriwN5BBOX0lmLc2q aip9IV9R1rDur/Gv6TtHhWCj2QbJAd5EDZ8e7NiDmRwrQyjVOpEhaS3v6oXgsHnY /8AsRuPrbObgVu897S4eUBXZPyk3mc1DM/HVnAOyjaHJsKvcExd7jY4e3WvddPrE TTt4+iyNB9w7aSNusuIe5+w0hmVRUKZmnnnl3iJN7/5Hxp6Z5LewY43viRQ1IfzS cP9pM+h9pXlbzPwwyZWeQXjWjsETbuImFsXxqAmWoVe43TDzfU/i4ZlBabYT0kmp uO//EMfmwJo6cFKxLEqAFInIQ9Dl3yYVV5KAcnHeM6HnjaeU0Dbi6ic53rQTWGYm NA/u1WbNo3jdmgm0VigSiDdPb46RJL5iaB11SVXwKCBih/bpvlRth42yNnam57me HUOPMTiTUODmuZgTerUKf0PRu1wao7POX03r3v/B5vH144FmFzv1i6oZtIASJXjq S2dVKH+bCBBH7wbnFofdHglnUuQYknxzdVkGC1zLh9NKWawvotnjN3sf0kR1eqkl ls0O+ZfA+5Dal6nX8YcGRhBvnLcAfDXHf/Cc10G/vNGvGs5W/g5dEoMDl5eKDiE1 iPOaX3kyvRgSqT7roPIt =gwCV -----END PGP SIGNATURE----- --lLR1BQqf7txDtYcF--