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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]