qemu: Add qemuDomainCheckABIStability

When making ABI stability checks for an active domain, we need to make
sure we use the same migratable definition which virDomainGetXMLDesc
with the MIGRATABLE flag provides, otherwise the ABI check will fail.
This is implemented in the new qemuDomainCheckABIStability which takes a
domain object and generates the right migratable definition from it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Jiri Denemark 2017-06-14 13:43:37 +02:00
parent a0912df3fa
commit 063b2b8788
2 changed files with 40 additions and 5 deletions

View File

@ -5919,6 +5919,10 @@ qemuDomainMigratableDefCheckABIStability(virQEMUDriverPtr driver,
} }
#define COPY_FLAGS (VIR_DOMAIN_XML_SECURE | \
VIR_DOMAIN_XML_UPDATE_CPU | \
VIR_DOMAIN_XML_MIGRATABLE)
bool bool
qemuDomainDefCheckABIStability(virQEMUDriverPtr driver, qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
virDomainDefPtr src, virDomainDefPtr src,
@ -5926,13 +5930,10 @@ qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
{ {
virDomainDefPtr migratableDefSrc = NULL; virDomainDefPtr migratableDefSrc = NULL;
virDomainDefPtr migratableDefDst = NULL; virDomainDefPtr migratableDefDst = NULL;
const unsigned int flags = VIR_DOMAIN_XML_SECURE |
VIR_DOMAIN_XML_UPDATE_CPU |
VIR_DOMAIN_XML_MIGRATABLE;
bool ret = false; bool ret = false;
if (!(migratableDefSrc = qemuDomainDefCopy(driver, src, flags)) || if (!(migratableDefSrc = qemuDomainDefCopy(driver, src, COPY_FLAGS)) ||
!(migratableDefDst = qemuDomainDefCopy(driver, dst, flags))) !(migratableDefDst = qemuDomainDefCopy(driver, dst, COPY_FLAGS)))
goto cleanup; goto cleanup;
ret = qemuDomainMigratableDefCheckABIStability(driver, ret = qemuDomainMigratableDefCheckABIStability(driver,
@ -5945,6 +5946,36 @@ qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
return ret; return ret;
} }
bool
qemuDomainCheckABIStability(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virDomainDefPtr dst)
{
virDomainDefPtr migratableSrc = NULL;
virDomainDefPtr migratableDst = NULL;
char *xml = NULL;
bool ret = false;
if (!(xml = qemuDomainFormatXML(driver, vm, COPY_FLAGS)) ||
!(migratableSrc = qemuDomainDefFromXML(driver, xml)) ||
!(migratableDst = qemuDomainDefCopy(driver, dst, COPY_FLAGS)))
goto cleanup;
ret = qemuDomainMigratableDefCheckABIStability(driver,
vm->def, migratableSrc,
dst, migratableDst);
cleanup:
VIR_FREE(xml);
virDomainDefFree(migratableSrc);
virDomainDefFree(migratableDst);
return ret;
}
#undef COPY_FLAGS
bool bool
qemuDomainAgentAvailable(virDomainObjPtr vm, qemuDomainAgentAvailable(virDomainObjPtr vm,
bool reportError) bool reportError)

View File

@ -666,6 +666,10 @@ bool qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
virDomainDefPtr src, virDomainDefPtr src,
virDomainDefPtr dst); virDomainDefPtr dst);
bool qemuDomainCheckABIStability(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virDomainDefPtr dst);
bool qemuDomainAgentAvailable(virDomainObjPtr vm, bool qemuDomainAgentAvailable(virDomainObjPtr vm,
bool reportError); bool reportError);