[libvirt] [PATCH 6/8] Fix printing of pathnames on error in qemuDomainSnapshotLoad.

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

 



While doing some testing of the snapshot code I noticed that
if qemuDomainSnapshotLoad failed, it would print a NULL as
part of the error.  That's not desirable, so leave the
full_path variable around until after we are done printing
errors.

Signed-off-by: Chris Lalancette <clalance@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2f889d9..7314328 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1388,9 +1388,9 @@ static void qemuDomainSnapshotLoad(void *payload,
         }
 
         ret = virFileReadAll(fullpath, 1024*1024*1, &xmlStr);
-        VIR_FREE(fullpath);
         if (ret < 0) {
             /* Nothing we can do here, skip this one */
+            VIR_FREE(fullpath);
             VIR_ERROR("Failed to read snapshot file %s: %s", fullpath,
                       virStrerror(errno, ebuf, sizeof(ebuf)));
             continue;
@@ -1400,12 +1400,14 @@ static void qemuDomainSnapshotLoad(void *payload,
         if (def == NULL) {
             /* Nothing we can do here, skip this one */
             VIR_ERROR("Failed to parse snapshot XML from file '%s'", fullpath);
+            VIR_FREE(fullpath);
             VIR_FREE(xmlStr);
             continue;
         }
 
         virDomainSnapshotAssignDef(&vm->snapshots, def);
 
+        VIR_FREE(fullpath);
         VIR_FREE(xmlStr);
     }
 
-- 
1.6.6.1

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