From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49895) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAgvD-0002Cl-LH for qemu-devel@nongnu.org; Fri, 25 Jul 2014 10:56:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XAgv6-0004MK-5p for qemu-devel@nongnu.org; Fri, 25 Jul 2014 10:56:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3733) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAgv5-0004M0-Tr for qemu-devel@nongnu.org; Fri, 25 Jul 2014 10:56:28 -0400 Date: Fri, 25 Jul 2014 15:56:23 +0100 From: Stefan Hajnoczi Message-ID: <20140725145623.GB1855@stefanha-thinkpad.redhat.com> References: <1406226665-1710-1-git-send-email-marc.mari.barcelo@gmail.com> <1406226665-1710-2-git-send-email-marc.mari.barcelo@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="/NkBOFFp2J2Af1nK" Content-Disposition: inline In-Reply-To: <1406226665-1710-2-git-send-email-marc.mari.barcelo@gmail.com> Subject: Re: [Qemu-devel] [PATCH 1/7] tests: Functions bus_foreach and device_find from libqos virtio API List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Marc =?iso-8859-1?Q?Mar=ED?= Cc: Paolo Bonzini , qemu-devel@nongnu.org --/NkBOFFp2J2Af1nK Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jul 24, 2014 at 08:30:59PM +0200, Marc Mar=ED wrote: > +static QPCIBus *test_start(void) > +{ > + char cmdline[100]; > + char tmp_path[] =3D "/tmp/qtest.XXXXXX"; > + int fd, ret; > + > + /* Create a temporary raw image */ > + fd =3D mkstemp(tmp_path); > + g_assert_cmpint(fd, >=3D, 0); > + ret =3D ftruncate(fd, TEST_IMAGE_SIZE); > + g_assert_cmpint(ret, =3D=3D, 0); > + close(fd); > + > + last_tmp_path =3D g_malloc0(strlen(tmp_path)); > + strcpy(last_tmp_path, tmp_path); > + > + snprintf(cmdline, 100, "-drive if=3Dnone,id=3Ddrive0,file=3D%s " > + "-device virtio-blk-pci,drive=3Ddrive0,addr= =3D%x.%x", > + tmp_path, PCI_SLOT, PCI_FN); > + qtest_start(cmdline); Please unlink the temporary disk image file here. The QEMU process has a file descriptor open when we reach this point, so it's safe to delete it on disk (the file stays allocated until the last file descriptor is closed). This is important so that the temporary file is always deleted in failure cases. We do not reach test_end() when an assertion fails. --/NkBOFFp2J2Af1nK Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJT0nAXAAoJEJykq7OBq3PIvRQIAKOmuP95hizv3VpQElu02Kj4 qsdpvHdsARTMfpYGfL6m8oGXR3xBn7Fm4lPTm51rZg25fEleB2Lk8krqTGBDTCJy tNlKdcPzPkTb6uhol1reqJf6q+3ui6R1tXj6PR4btrXauUVYQ6ionvwNHP7KoU79 Wf5GjO/nSc4WdwFg88+NIzNALzC1Jz/Pj+DlL3+/TdkfZ/jpBw044c8NwRWg5rPe 9dVtM+zQWbLlE8tBqmWj4FZGGc5cDM+WvJpdE5MZOUco8LmLYcJHxd+CoAgSVjmD L0/N37sl+EGw+eCUF1l3JRqM78CZTWe15cH5KSaaKLvDtMKbKCFC2NK0BmEWggI= =wJai -----END PGP SIGNATURE----- --/NkBOFFp2J2Af1nK--