qemu-devel
[Top][All Lists]
Advanced

[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.

Attachment: pgpTC3ROpwB2c.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]