mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-27 23:15:18 +00:00
qemu: Introduce qemuDomainDefFromXML helper
The main goal of this function is to enable reusing the parsing code from qemuDomainDefCopy. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
1e8d6c6ef0
commit
0810d4f5e0
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user