提交 0810d4f5 编写于 作者: J Jiri Denemark

qemu: Introduce qemuDomainDefFromXML helper

The main goal of this function is to enable reusing the parsing code
from qemuDomainDefCopy.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
Reviewed-by: NPavel Hrdina <phrdina@redhat.com>
上级 1e8d6c6e
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册