[PATCH 05/25] conf: domain: Introduce an internal variant of virDomainDiskDefNew

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

 



The <disk> XML element parser is going to be modified so that the
virStorageSource bits are pre-parsed. Add virDomainDiskDefNewSource,
which uses an existing 'src' pointer.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 57cad6ffde..f59d17930b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2230,25 +2230,32 @@ virDomainDefGetVcpusTopology(const virDomainDef *def,
 }


-virDomainDiskDef *
-virDomainDiskDefNew(virDomainXMLOption *xmlopt)
+static virDomainDiskDef *
+virDomainDiskDefNewSource(virDomainXMLOption *xmlopt,
+                          virStorageSource **src)
 {
+    void *privateData = NULL;
     virDomainDiskDef *ret;

-    ret = g_new0(virDomainDiskDef, 1);
-
-    ret->src = virStorageSourceNew();
-
     if (xmlopt &&
         xmlopt->privateData.diskNew &&
-        !(ret->privateData = xmlopt->privateData.diskNew()))
-        goto error;
+        !(privateData = xmlopt->privateData.diskNew()))
+        return NULL;
+
+    ret = g_new0(virDomainDiskDef, 1);
+    ret->src = g_steal_pointer(src);
+    ret->privateData = privateData;

     return ret;
+}

- error:
-    virDomainDiskDefFree(ret);
-    return NULL;
+
+virDomainDiskDef *
+virDomainDiskDefNew(virDomainXMLOption *xmlopt)
+{
+    g_autoptr(virStorageSource) src = virStorageSourceNew();
+
+    return virDomainDiskDefNewSource(xmlopt, &src);
 }


-- 
2.30.2




[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