]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
migration: merge all proto branches into single function
authorNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Fri, 2 Oct 2015 07:52:50 +0000 (10:52 +0300)
committerJiri Denemark <jdenemar@redhat.com>
Mon, 12 Oct 2015 11:31:28 +0000 (13:31 +0200)
Finally on this step we get what we were aimed for - toURI{1, 2} (and
migration{*} APIs too) now can work thru V3_PARAMS protocol. Execution path
goes thru unchanged virDomainMigrateUnmanaged adapter function which is called
by all target places.

Note that we keep the fact that direct migration never works
thru V3_PARAMS proto. We can't change this aspect without
further investigation.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
src/libvirt-domain.c

index 0fd07d0c8303e4178decdb45e1f5218c3b451089..f8958f67ece473c776071ad5ee424b508d4b1456 100644 (file)
@@ -3434,8 +3434,19 @@ virDomainMigrateUnmanagedParams(virDomainPtr domain,
         virDomainMigrateCheckNotLocal(dconnuri) < 0)
         return -1;
 
-    if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
-                                 VIR_DRV_FEATURE_MIGRATION_V3)) {
+    if ((flags & VIR_MIGRATE_PEER2PEER) &&
+        VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
+                                 VIR_DRV_FEATURE_MIGRATION_PARAMS)) {
+        VIR_DEBUG("Using migration protocol 3 with extensible parameters");
+        if (!domain->conn->driver->domainMigratePerform3Params) {
+            virReportUnsupportedError();
+            return -1;
+        }
+        return domain->conn->driver->domainMigratePerform3Params
+                (domain, dconnuri, params, nparams,
+                 NULL, 0, NULL, NULL, flags);
+    } else if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
+                                        VIR_DRV_FEATURE_MIGRATION_V3)) {
         VIR_DEBUG("Using migration protocol 3");
         if (!domain->conn->driver->domainMigratePerform3) {
             virReportUnsupportedError();
@@ -3455,32 +3466,6 @@ virDomainMigrateUnmanagedParams(virDomainPtr domain,
 }
 
 
-static int
-virDomainMigratePeer2PeerParams(virDomainPtr domain,
-                                const char *dconnuri,
-                                virTypedParameterPtr params,
-                                int nparams,
-                                unsigned int flags)
-{
-    VIR_DOMAIN_DEBUG(domain, "dconnuri=%s, params=%p, nparams=%d, flags=%x",
-                     dconnuri, params, nparams, flags);
-    VIR_TYPED_PARAMS_DEBUG(params, nparams);
-
-    if (!domain->conn->driver->domainMigratePerform3Params) {
-        virReportUnsupportedError();
-        return -1;
-    }
-
-    if (virDomainMigrateCheckNotLocal(dconnuri) < 0)
-        return -1;
-
-    VIR_DEBUG("Using migration protocol 3 with extensible parameters");
-    return domain->conn->driver->domainMigratePerform3Params
-            (domain, dconnuri, params, nparams,
-             NULL, 0, NULL, NULL, flags);
-}
-
-
 static int
 virDomainMigrateUnmanaged(virDomainPtr domain,
                           const char *xmlin,
@@ -4505,18 +4490,9 @@ virDomainMigrateToURI3(virDomainPtr domain,
             goto error;
         }
 
-        if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
-                                     VIR_DRV_FEATURE_MIGRATION_PARAMS)) {
-            VIR_DEBUG("Using peer2peer migration with extensible parameters");
-            if (virDomainMigratePeer2PeerParams(domain, dconnuri, params,
-                                                nparams, flags) < 0)
-                goto error;
-        } else {
-            VIR_DEBUG("Using peer2peer migration");
-            if (virDomainMigrateUnmanagedParams(domain, dconnuri, params,
-                                                nparams, flags) < 0)
-                goto error;
-        }
+        VIR_DEBUG("Using peer2peer migration");
+        if (virDomainMigrateUnmanagedParams(domain, dconnuri, params, nparams, flags) < 0)
+            goto error;
     } else {
         if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
                                       VIR_DRV_FEATURE_MIGRATION_DIRECT)) {