[PATCH 2/6] virQEMUSaveData: Register autoclear function and use it in qemuDomainSaveImageOpen

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

 



In an attempt to simplify qemuDomainSaveImageOpen we need to add
automatic pointer clearing for virQEMUSaveData.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 9a9361949d..5b87aaf9c2 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2856,6 +2856,7 @@ virQEMUSaveDataFree(virQEMUSaveDataPtr data)
     VIR_FREE(data);
 }

+G_DEFINE_AUTOPTR_CLEANUP_FUNC(virQEMUSaveData, virQEMUSaveDataFree);

 /**
  * This function steals @domXML on success.
@@ -6692,7 +6693,7 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
 {
     int fd = -1;
     int ret = -1;
-    virQEMUSaveDataPtr data = NULL;
+    g_autoptr(virQEMUSaveData) data = NULL;
     virQEMUSaveHeaderPtr header;
     virDomainDefPtr def = NULL;
     int oflags = open_write ? O_RDWR : O_RDONLY;
@@ -6809,13 +6810,12 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
         goto error;

     *ret_def = def;
-    *ret_data = data;
+    *ret_data = g_steal_pointer(&data);

     return fd;

  error:
     virDomainDefFree(def);
-    virQEMUSaveDataFree(data);
     VIR_FORCE_CLOSE(fd);
     return ret;
 }
-- 
2.26.0





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

  Powered by Linux