[PATCH 6/7] qemu: domain: Move qemuDomainObjPrivateAlloc after qemuDomainObjPrivateFree

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

 



The freeing function will be needed to undo failures in allocation.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c | 61 +++++++++++++++++++++---------------------
 1 file changed, 31 insertions(+), 30 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index b919da6eab..8d1ecc0140 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1772,36 +1772,6 @@ qemuDomainObjStopWorker(virDomainObj *dom)
 }


-static void *
-qemuDomainObjPrivateAlloc(void *opaque)
-{
-    qemuDomainObjPrivate *priv;
-
-    priv = g_new0(qemuDomainObjPrivate, 1);
-
-    if (qemuDomainObjInitJob(&priv->job, &qemuPrivateJobCallbacks) < 0) {
-        virReportSystemError(errno, "%s",
-                             _("Unable to init qemu driver mutexes"));
-        goto error;
-    }
-
-    if (!(priv->devs = virChrdevAlloc()))
-        goto error;
-
-    priv->blockjobs = virHashNew(virObjectFreeHashData);
-
-    /* agent commands block by default, user can choose different behavior */
-    priv->agentTimeout = VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK;
-    priv->migMaxBandwidth = QEMU_DOMAIN_MIG_BANDWIDTH_MAX;
-    priv->driver = opaque;
-
-    return priv;
-
- error:
-    VIR_FREE(priv);
-    return NULL;
-}
-
 /**
  * qemuDomainObjPrivateDataClear:
  * @priv: domain private data
@@ -1922,6 +1892,37 @@ qemuDomainObjPrivateFree(void *data)
 }


+static void *
+qemuDomainObjPrivateAlloc(void *opaque)
+{
+    qemuDomainObjPrivate *priv;
+
+    priv = g_new0(qemuDomainObjPrivate, 1);
+
+    if (qemuDomainObjInitJob(&priv->job, &qemuPrivateJobCallbacks) < 0) {
+        virReportSystemError(errno, "%s",
+                             _("Unable to init qemu driver mutexes"));
+        goto error;
+    }
+
+    if (!(priv->devs = virChrdevAlloc()))
+        goto error;
+
+    priv->blockjobs = virHashNew(virObjectFreeHashData);
+
+    /* agent commands block by default, user can choose different behavior */
+    priv->agentTimeout = VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK;
+    priv->migMaxBandwidth = QEMU_DOMAIN_MIG_BANDWIDTH_MAX;
+    priv->driver = opaque;
+
+    return priv;
+
+ error:
+    VIR_FREE(priv);
+    return NULL;
+}
+
+
 static int
 qemuStorageSourcePrivateDataAssignSecinfo(qemuDomainSecretInfo **secinfo,
                                           char **alias)
-- 
2.31.1




[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