On Thu, Jul 24, 2014 at 08:30:59PM +0200, Marc Marí wrote: > +static QPCIBus *test_start(void) > +{ > + char cmdline[100]; > + char tmp_path[] = "/tmp/qtest.XXXXXX"; > + int fd, ret; > + > + /* Create a temporary raw image */ > + fd = mkstemp(tmp_path); > + g_assert_cmpint(fd, >=, 0); > + ret = ftruncate(fd, TEST_IMAGE_SIZE); > + g_assert_cmpint(ret, ==, 0); > + close(fd); > + > + last_tmp_path = g_malloc0(strlen(tmp_path)); > + strcpy(last_tmp_path, tmp_path); > + > + snprintf(cmdline, 100, "-drive if=none,id=drive0,file=%s " > + "-device virtio-blk-pci,drive=drive0,addr=%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.
pgpjYo2EWJU2Q.pgp
Description: PGP signature