Received: from eggs.gnu.org ([2001:4830:134:3::10]:53646) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCo4l-0001xU-Tf for qemu-devel@nongnu.org; Thu, 31 Jul 2014 06:59:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XCo4c-0006Ml-Sp for qemu-devel@nongnu.org; Thu, 31 Jul 2014 06:59:11 -0400 Received: from mail-wi0-x22d.google.com ([2a00:1450:400c:c05::22d]:34026) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCo4c-0006Mf-Le for qemu-devel@nongnu.org; Thu, 31 Jul 2014 06:59:02 -0400 Received: by mail-wi0-f173.google.com with SMTP id f8so9199819wiw.0 for ; Thu, 31 Jul 2014 03:59:00 -0700 (PDT) Date: Thu, 31 Jul 2014 11:58:56 +0100 From: Stefan Hajnoczi Message-ID: <20140731105856.GF25929@stefanha-thinkpad.redhat.com> References: <1404757089-4836-1-git-send-email-jsnow@redhat.com> <1404757089-4836-4-git-send-email-jsnow@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="aZoGpuMECXJckB41" Content-Disposition: inline In-Reply-To: <1404757089-4836-4-git-send-email-jsnow@redhat.com> Subject: Re: [Qemu-devel] [PATCH 03/28] ide-test: add test for werror=stop List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: John Snow Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, mst@redhat.com --aZoGpuMECXJckB41 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jul 07, 2014 at 02:17:44PM -0400, John Snow wrote: > @@ -489,6 +490,72 @@ static void test_flush(void) > ide_test_quit(); > } > =20 > +static void prepare_blkdebug_script(const char *debug_path, const char *= event) > +{ > + FILE *debug_file =3D fopen(debug_path, "w"); Please avoid shadowing the global debug_path variable. Perhaps simply call the argument 'filename'. > +static void test_retry_flush(void) > +{ > + uint8_t data; > + const char *s; > + > + prepare_blkdebug_script(debug_path, "flush_to_disk"); > + > + ide_test_start( > + "-vnc none " > + "-drive file=3Dblkdebug:%s:%s,if=3Dide,cache=3Dwriteback,rerror= =3Dstop,werror=3Dstop", > + debug_path, tmp_path); > + > + /* FLUSH CACHE command on device 0*/ > + outb(IDE_BASE + reg_device, 0); > + outb(IDE_BASE + reg_command, CMD_FLUSH_CACHE); > + > + /* Check status while request is in flight*/ > + data =3D inb(IDE_BASE + reg_status); > + assert_bit_set(data, BSY | DRDY); > + assert_bit_clear(data, DF | ERR | DRQ); > + > + sleep(1); /* HACK: wait for event */ > + > + /* Complete the command */ > + s =3D "{'execute':'cont' }"; > + while (!qmp(s)) { > + s =3D ""; > + sleep(1); > + } I guess we're supposed to wait for the block I/O error event when the machine stops. Please implement that and replace this polling loop. See the STOP event in docs/qmp/qmp-events.txt. > @@ -501,6 +568,11 @@ int main(int argc, char **argv) > return 0; > } > =20 > + /* Create temporary blkdebug instructions */ > + fd =3D mkstemp(debug_path); > + g_assert(fd >=3D 0); > + close(fd); > + debug_path must be unlinked at the end of main(). Tests should not clutter up the /tmp directory, all resources must be freed. --aZoGpuMECXJckB41 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJT2iFwAAoJEJykq7OBq3PIwBMH/0piui+QtxXByZGXOP4gtNNU 81rfhIz6qqGBi9ICV/JHIrXf/o4+S+MYe2mMoBM/vRWjEzS/1lSppiMWev9E0ry0 8o235CcX/PLVZF4yEAuUOcull1TCMChUXMykLswccB2qOTLS6HgrtrAeagHdRx5r lPkPiEDwl7byDtpgqmTFf/T73qIQzzuFtKhfEPCJjaGvwzet1ZCN5+uwIX2JSP0o nI3vk6wCOE7faep44WAGGgc8Fzyw5RW0Ii+heZx1LDwOMT7rovN0NGcO5qzB2tqk A/0x2LvpFEEMd4FB8y//C6DPf0E8vL06ve2u5We/oLEsCM8yS7ynFcyub32nWI8= =Q0hU -----END PGP SIGNATURE----- --aZoGpuMECXJckB41--