[PATCH 3/5] qemu: save image: Split out new definition check/update

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

 



Split out the call to the update method only to places where it is
actually used rather than having a mega-method that does all the stuff.
---
 src/qemu/qemu_driver.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index a276ea5..0151fd2 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5495,16 +5495,6 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
                                         VIR_DOMAIN_XML_INACTIVE)))
         goto error;

-    if (xmlin) {
-        virDomainDefPtr tmp;
-
-        if (!(tmp = qemuDomainSaveImageUpdateDef(driver, def, xmlin)))
-            goto error;
-
-        virDomainDefFree(def);
-        def = tmp;
-    }
-
     if (xmlout)
         *xmlout = xml;
     else
@@ -5647,6 +5637,7 @@ qemuDomainRestoreFlags(virConnectPtr conn,
 {
     virQEMUDriverPtr driver = conn->privateData;
     virDomainDefPtr def = NULL;
+    virDomainDefPtr newdef = NULL;
     virDomainObjPtr vm = NULL;
     int fd = -1;
     int ret = -1;
@@ -5673,6 +5664,14 @@ qemuDomainRestoreFlags(virConnectPtr conn,
     if (virDomainRestoreFlagsEnsureACL(conn, def) < 0)
         goto cleanup;

+    if (dxml) {
+        if (!(newdef = qemuDomainSaveImageUpdateDef(driver, def, dxml)))
+            goto cleanup;
+
+        virDomainDefFree(def);
+        def = newdef;
+    }
+
     if (!(vm = virDomainObjListAdd(driver->domains, def,
                                    driver->xmlopt,
                                    VIR_DOMAIN_OBJ_LIST_ADD_LIVE |
@@ -5749,6 +5748,7 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path,
     virQEMUDriverPtr driver = conn->privateData;
     int ret = -1;
     virDomainDefPtr def = NULL;
+    virDomainDefPtr newdef = NULL;
     int fd = -1;
     virQEMUSaveHeader header;
     char *xml = NULL;
@@ -5776,7 +5776,10 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path,
     if (virDomainSaveImageDefineXMLEnsureACL(conn, def) < 0)
         goto cleanup;

-    xml = qemuDomainDefFormatXML(driver, def,
+    if (!(newdef = qemuDomainSaveImageUpdateDef(driver, def, dxml)))
+        goto cleanup;
+
+    xml = qemuDomainDefFormatXML(driver, newdef,
                                  VIR_DOMAIN_XML_INACTIVE |
                                  VIR_DOMAIN_XML_SECURE |
                                  VIR_DOMAIN_XML_MIGRATABLE);
@@ -5807,6 +5810,7 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, const char *path,

  cleanup:
     virDomainDefFree(def);
+    virDomainDefFree(newdef);
     VIR_FORCE_CLOSE(fd);
     VIR_FREE(xml);
     return ret;
-- 
2.1.0

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