[libvirt] [PATCH v2] qemu: Unlink temporary file on failure

Eric Blake eblake at redhat.com
Tue Aug 2 15:59:12 UTC 2011


On 08/02/2011 09:50 AM, Michal Privoznik wrote:
> Although virFDStreamOpenFile will unlink it once opened, when we hit
> error path, we must unlink it by hand.
> ---
>   src/qemu/qemu_driver.c |    5 ++++-
>   1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 09b2791..c78cdb7 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -2931,7 +2931,10 @@ qemuDomainScreenshot(virDomainPtr dom,
>
>   endjob:
>       VIR_FORCE_CLOSE(tmp_fd);
> -    VIR_FREE(tmp);
> +     if (tmp) {
> +        unlink(tmp);
> +        VIR_FREE(tmp);
> +     }

ACK.

The VIR_FREE(tmp) could be unconditional, but it doesn't hurt to leave 
it conditional - at any rate, it won't trip the syntax-check for 
useless-if-before-free because we are doing more than just freeing tmp 
in the conditional.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org




More information about the libvir-list mailing list