[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] 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 409b5f549530e7b3a33f4505f2cad2e26896107c
    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.
---
 src/libvirt.c          |   13 ++++++++++---
 src/libvirt_internal.h |    5 +++++
 src/qemu/qemu_driver.c |    1 +
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index e3ddf27..f6f5b91 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -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;
 
diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h
index 23e7153..71483e4 100644
--- a/src/libvirt_internal.h
+++ b/src/libvirt_internal.h
@@ -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,
 };
 
 
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 76730c6..0c35dad 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -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;
-- 
1.7.8.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]