render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
3e5111
From 0085fabfc81c097d0307b307ac0441c2448fbb16 Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <0085fabfc81c097d0307b307ac0441c2448fbb16@dist-git>
3e5111
From: Jiri Denemark <jdenemar@redhat.com>
3e5111
Date: Wed, 14 Jun 2017 13:42:16 +0200
3e5111
Subject: [PATCH] qemu: Introduce qemuDomainDefFromXML helper
3e5111
3e5111
The main goal of this function is to enable reusing the parsing code
3e5111
from qemuDomainDefCopy.
3e5111
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3e5111
(cherry picked from commit 0810d4f5e0d77354cdf7ad56e1e8b7748bdb1501)
3e5111
3e5111
https://bugzilla.redhat.com/show_bug.cgi?id=1460952
3e5111
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
---
3e5111
 src/qemu/qemu_domain.c | 33 +++++++++++++++++++++------------
3e5111
 1 file changed, 21 insertions(+), 12 deletions(-)
3e5111
3e5111
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
3e5111
index 82dacb3c9c..ce75105afa 100644
3e5111
--- a/src/qemu/qemu_domain.c
3e5111
+++ b/src/qemu/qemu_domain.c
3e5111
@@ -4146,6 +4146,25 @@ void qemuDomainObjExitRemote(virDomainObjPtr obj)
3e5111
 }
3e5111
 
3e5111
 
3e5111
+static virDomainDefPtr
3e5111
+qemuDomainDefFromXML(virQEMUDriverPtr driver,
3e5111
+                     const char *xml)
3e5111
+{
3e5111
+    virCapsPtr caps;
3e5111
+    virDomainDefPtr def;
3e5111
+
3e5111
+    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
3e5111
+        return NULL;
3e5111
+
3e5111
+    def = virDomainDefParseString(xml, caps, driver->xmlopt, NULL,
3e5111
+                                  VIR_DOMAIN_DEF_PARSE_INACTIVE |
3e5111
+                                  VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE);
3e5111
+
3e5111
+    virObjectUnref(caps);
3e5111
+    return def;
3e5111
+}
3e5111
+
3e5111
+
3e5111
 virDomainDefPtr
3e5111
 qemuDomainDefCopy(virQEMUDriverPtr driver,
3e5111
                   virDomainDefPtr src,
3e5111
@@ -4153,25 +4172,15 @@ qemuDomainDefCopy(virQEMUDriverPtr driver,
3e5111
 {
3e5111
     virBuffer buf = VIR_BUFFER_INITIALIZER;
3e5111
     virDomainDefPtr ret = NULL;
3e5111
-    virCapsPtr caps = NULL;
3e5111
     char *xml = NULL;
3e5111
 
3e5111
     if (qemuDomainDefFormatBuf(driver, src, flags, &buf) < 0)
3e5111
-        goto cleanup;
3e5111
+        return NULL;
3e5111
 
3e5111
     xml = virBufferContentAndReset(&buf;;
3e5111
+    ret = qemuDomainDefFromXML(driver, xml);
3e5111
 
3e5111
-    if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
3e5111
-        goto cleanup;
3e5111
-
3e5111
-    if (!(ret = virDomainDefParseString(xml, caps, driver->xmlopt, NULL,
3e5111
-                                        VIR_DOMAIN_DEF_PARSE_INACTIVE |
3e5111
-                                        VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE)))
3e5111
-        goto cleanup;
3e5111
-
3e5111
- cleanup:
3e5111
     VIR_FREE(xml);
3e5111
-    virObjectUnref(caps);
3e5111
     return ret;
3e5111
 }
3e5111
 
3e5111
-- 
3e5111
2.13.1
3e5111