[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/7] tests: Functions bus_foreach and device_fin
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH 1/7] tests: Functions bus_foreach and device_find from libqos virtio API |
Date: |
Fri, 25 Jul 2014 15:56:23 +0100 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
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.
pgpTC3ROpwB2c.pgp
Description: PGP signature
- [Qemu-devel] [PATCH 2/7] tests: Add virtio device initialization, (continued)
- [Qemu-devel] [PATCH 3/7] libqtest: add QTEST_LOG for debugging qtest testcases, Marc Marí, 2014/07/24
- [Qemu-devel] [PATCH 5/7] libqos: Change free function called in malloc, Marc Marí, 2014/07/24
- [Qemu-devel] [PATCH 1/7] tests: Functions bus_foreach and device_find from libqos virtio API, Marc Marí, 2014/07/24
- Re: [Qemu-devel] [PATCH 1/7] tests: Functions bus_foreach and device_find from libqos virtio API,
Stefan Hajnoczi <=
- [Qemu-devel] [PATCH 4/7] libqos: Correct mask to align size to PAGE_SIZE in malloc-pc, Marc Marí, 2014/07/24
- [Qemu-devel] [PATCH 6/7] virtio-blk: Correct bug in support for flexible descriptor layout, Marc Marí, 2014/07/24
- [Qemu-devel] [PATCH 7/7] libqos: Added basic virtqueue support to virtio implementation, Marc Marí, 2014/07/24