[PATCH 2/2] qemu: avoid fd leak on core dump failure

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

 



* src/qemu/qemu_driver.c (doCoreDump): Guarantee fd is closed.
---

Spotted by hand, while working on virDomainSaveFlags.

 src/qemu/qemu_driver.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1356c54..f9d2de4 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2525,10 +2525,11 @@ cleanup:
     return ret;
 }

-static int doCoreDump(struct qemud_driver *driver,
-                      virDomainObjPtr vm,
-                      const char *path,
-                      enum qemud_save_formats compress)
+static int
+doCoreDump(struct qemud_driver *driver,
+           virDomainObjPtr vm,
+           const char *path,
+           enum qemud_save_formats compress)
 {
     int fd = -1;
     int ret = -1;
@@ -2554,6 +2555,7 @@ static int doCoreDump(struct qemud_driver *driver,
     ret = 0;

 cleanup:
+    VIR_FORCE_CLOSE(fd);
     if (ret != 0)
         unlink(path);
     return ret;
-- 
1.7.4.4

--
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]