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