提交 0943603d 编写于 作者: J Ján Tomko 提交者: Cole Robinson

qemu: allow restore with non-migratable XML input

Convert input XML to migratable before using it in
qemuDomainSaveImageOpen.

XML in the save image is migratable, i.e. doesn't contain implicit
controllers. If these controllers were in a non-default order in the
input XML, the ABI check would fail. Removing and re-adding these
controllers fixes it.

https://bugzilla.redhat.com/show_bug.cgi?id=834196
(cherry picked from commit 07966f6a)
上级 ca305a75
......@@ -1267,6 +1267,35 @@ void qemuDomainObjExitRemote(virDomainObjPtr obj)
}
virDomainDefPtr
qemuDomainDefCopy(virQEMUDriverPtr driver,
virDomainDefPtr src,
unsigned int flags)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
virDomainDefPtr ret = NULL;
virCapsPtr caps = NULL;
const char *xml = NULL;
if (qemuDomainDefFormatBuf(driver, src, flags, &buf) < 0)
goto cleanup;
xml = virBufferContentAndReset(&buf);
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup;
if (!(ret = virDomainDefParseString(xml, caps, driver->xmlopt,
QEMU_EXPECTED_VIRT_TYPES,
VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;
cleanup:
VIR_FREE(xml);
virObjectUnref(caps);
return ret;
}
int
qemuDomainDefFormatBuf(virQEMUDriverPtr driver,
virDomainDefPtr def,
......
......@@ -241,6 +241,10 @@ void qemuDomainObjEnterRemote(virDomainObjPtr obj)
void qemuDomainObjExitRemote(virDomainObjPtr obj)
ATTRIBUTE_NONNULL(1);
virDomainDefPtr qemuDomainDefCopy(virQEMUDriverPtr driver,
virDomainDefPtr src,
unsigned int flags);
int qemuDomainDefFormatBuf(virQEMUDriverPtr driver,
virDomainDefPtr vm,
unsigned int flags,
......
......@@ -4688,17 +4688,24 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
goto error;
if (xmlin) {
virDomainDefPtr def2 = NULL;
virDomainDefPtr newdef = NULL;
if (!(def2 = virDomainDefParseString(xmlin, caps, driver->xmlopt,
QEMU_EXPECTED_VIRT_TYPES,
VIR_DOMAIN_XML_INACTIVE)))
goto error;
if (!virDomainDefCheckABIStability(def, def2)) {
virDomainDefFree(def2);
newdef = qemuDomainDefCopy(driver, def2, VIR_DOMAIN_XML_MIGRATABLE);
virDomainDefFree(def2);
if (!newdef)
goto error;
if (!virDomainDefCheckABIStability(def, newdef)) {
virDomainDefFree(newdef);
goto error;
}
virDomainDefFree(def);
def = def2;
def = newdef;
}
VIR_FREE(xml);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册