migrate: v2: use VIR_DOMAIN_XML_MIGRATABLE when available

In v2 migration protocol, XML is obtained by calling domainGetXMLDesc.
This includes the default USB controller in XML, which breaks migration
to older libvirt (before 0.9.2).

Commit 409b5f5495
    qemu: Emit compatible XML when migrating a domain
only fixed this for v3 migration.

This patch uses the new VIR_DOMAIN_XML_MIGRATABLE flag (detected by
VIR_DRV_FEATURE_XML_MIGRATABLE) to obtain XML without the default controller,
enabling backward v2 migration.
This commit is contained in:
Ján Tomko 2012-10-19 16:58:05 +02:00 committed by Michal Privoznik
parent 508451e4ad
commit b6ab7a067f
3 changed files with 16 additions and 3 deletions

View File

@ -4620,6 +4620,7 @@ virDomainMigrateVersion2 (virDomainPtr domain,
int cookielen = 0, ret;
virDomainInfo info;
virErrorPtr orig_err = NULL;
unsigned int getxml_flags = 0;
int cancelled;
VIR_DOMAIN_DEBUG(domain,
"dconn=%p, flags=%lx, dname=%s, uri=%s, bandwidth=%lu",
@ -4646,9 +4647,15 @@ virDomainMigrateVersion2 (virDomainPtr domain,
virDispatchError(domain->conn);
return NULL;
}
dom_xml = domain->conn->driver->domainGetXMLDesc(domain,
VIR_DOMAIN_XML_SECURE |
VIR_DOMAIN_XML_UPDATE_CPU);
if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
VIR_DRV_FEATURE_XML_MIGRATABLE)) {
getxml_flags |= VIR_DOMAIN_XML_MIGRATABLE;
} else {
getxml_flags |= VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_UPDATE_CPU;
}
dom_xml = domain->conn->driver->domainGetXMLDesc(domain, getxml_flags);
if (!dom_xml)
return NULL;

View File

@ -95,6 +95,11 @@ enum {
* messages).
*/
VIR_DRV_FEATURE_PROGRAM_KEEPALIVE = 10,
/*
* Support for VIR_DOMAIN_XML_MIGRATABLE flag in domainGetXMLDesc
*/
VIR_DRV_FEATURE_XML_MIGRATABLE = 11,
};

View File

@ -1130,6 +1130,7 @@ qemudSupportsFeature (virConnectPtr conn ATTRIBUTE_UNUSED, int feature)
case VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION:
case VIR_DRV_FEATURE_FD_PASSING:
case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
case VIR_DRV_FEATURE_XML_MIGRATABLE:
return 1;
default:
return 0;