The main goal of this function is to enable reusing the parsing code from qemuDomainDefCopy. Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> --- src/qemu/qemu_domain.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 9b13241f9..2f8afd1d9 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4179,6 +4179,25 @@ void qemuDomainObjExitRemote(virDomainObjPtr obj) } +static virDomainDefPtr +qemuDomainDefFromXML(virQEMUDriverPtr driver, + const char *xml) +{ + virCapsPtr caps; + virDomainDefPtr def; + + if (!(caps = virQEMUDriverGetCapabilities(driver, false))) + return NULL; + + def = virDomainDefParseString(xml, caps, driver->xmlopt, NULL, + VIR_DOMAIN_DEF_PARSE_INACTIVE | + VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE); + + virObjectUnref(caps); + return def; +} + + virDomainDefPtr qemuDomainDefCopy(virQEMUDriverPtr driver, virDomainDefPtr src, @@ -4186,25 +4205,15 @@ qemuDomainDefCopy(virQEMUDriverPtr driver, { virBuffer buf = VIR_BUFFER_INITIALIZER; virDomainDefPtr ret = NULL; - virCapsPtr caps = NULL; char *xml = NULL; if (qemuDomainDefFormatBuf(driver, src, flags, &buf) < 0) - goto cleanup; + return NULL; xml = virBufferContentAndReset(&buf); + ret = qemuDomainDefFromXML(driver, xml); - if (!(caps = virQEMUDriverGetCapabilities(driver, false))) - goto cleanup; - - if (!(ret = virDomainDefParseString(xml, caps, driver->xmlopt, NULL, - VIR_DOMAIN_DEF_PARSE_INACTIVE | - VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE))) - goto cleanup; - - cleanup: VIR_FREE(xml); - virObjectUnref(caps); return ret; } -- 2.13.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list