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

[libvirt] [PATCH 2/3] Add a second URI parameter to virDomainMigratePerform3 method



The virDomainMigratePerform3 currently has a single URI parameter
whose meaning varies. It is either

 - A QEMU migration URI (normal migration)
 - A libvirtd connection URI (peer2peer migration)

Unfortunately when using peer2peer migration, without also
using tunnelled migration, it is possible that both URIs are
required.

This adds a second URI parameter to the virDomainMigratePerform3
method, to cope with this scenario. Each parameter how has a fixed
meaning.

NB, there is no way to actually take advantage of this yet,
since virDomainMigrate/virDomainMigrateToURI do not have any
way to provide the 2 separate URIs

* daemon/remote.c, src/remote/remote_driver.c,
  src/remote/remote_protocol.x, src/remote_protocol-structs: Add
  the second URI parameter to perform3 message
* src/driver.h, src/libvirt.c, src/libvirt_internal.h: Add
  the second URI parameter to Perform3 method
* src/libvirt_internal.h, src/qemu/qemu_migration.c,
  src/qemu/qemu_migration.h: Update to handle URIs correctly
---
 daemon/remote.c              |    4 +++-
 src/driver.h                 |    1 +
 src/libvirt.c                |   26 +++++++++++++++++++-------
 src/libvirt_internal.h       |    3 ++-
 src/qemu/qemu_driver.c       |    5 +++--
 src/qemu/qemu_migration.c    |   15 +++++++++++----
 src/qemu/qemu_migration.h    |    1 +
 src/remote/remote_driver.c   |    2 ++
 src/remote/remote_protocol.x |    1 +
 src/remote_protocol-structs  |    1 +
 10 files changed, 44 insertions(+), 15 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 03f1a5e..270ca30 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -3329,6 +3329,7 @@ remoteDispatchDomainMigratePerform3(struct qemud_server *server ATTRIBUTE_UNUSED
     virDomainPtr dom = NULL;
     char *xmlin;
     char *dname;
+    char *dconnuri;
     char *cookieout = NULL;
     int cookieoutlen = 0;
     int rv = -1;
@@ -3343,12 +3344,13 @@ remoteDispatchDomainMigratePerform3(struct qemud_server *server ATTRIBUTE_UNUSED
 
     xmlin = args->xmlin == NULL ? NULL : *args->xmlin;
     dname = args->dname == NULL ? NULL : *args->dname;
+    dconnuri = args->dconnuri == NULL ? NULL : *args->dconnuri;
 
     if (virDomainMigratePerform3(dom, xmlin,
                                  args->cookie_in.cookie_in_val,
                                  args->cookie_in.cookie_in_len,
                                  &cookieout, &cookieoutlen,
-                                 args->uri,
+                                 dconnuri, args->uri,
                                  args->flags, dname, args->resource) < 0)
         goto cleanup;
 
diff --git a/src/driver.h b/src/driver.h
index a1468e8..035e42d 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -581,6 +581,7 @@ typedef int
                      int cookieinlen,
                      char **cookieout,
                      int *cookieoutlen,
+                     const char *dconnuri,
                      const char *uri,
                      unsigned long flags,
                      const char *dname,
diff --git a/src/libvirt.c b/src/libvirt.c
index 7b7323e..c85f7bf 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -3792,9 +3792,10 @@ virDomainMigrateVersion3(virDomainPtr domain,
     cookieinlen = cookieoutlen;
     cookieout = NULL;
     cookieoutlen = 0;
+    /* dconnuri not relevant in non-P2P modes, so left NULL here */
     ret = domain->conn->driver->domainMigratePerform3
         (domain, NULL, cookiein, cookieinlen,
-         &cookieout, &cookieoutlen,
+         &cookieout, &cookieoutlen, NULL,
          uri, flags, dname, bandwidth);
 
     /* Perform failed. Make sure Finish doesn't overwrite the error */
@@ -3877,6 +3878,7 @@ virDomainMigratePeer2Peer (virDomainPtr domain,
                            const char *xmlin,
                            unsigned long flags,
                            const char *dname,
+                           const char *dconnuri,
                            const char *uri,
                            unsigned long bandwidth)
 {
@@ -3915,6 +3917,7 @@ virDomainMigratePeer2Peer (virDomainPtr domain,
                                                            0,    /* cookieinlen */
                                                            NULL, /* cookieoutlen */
                                                            NULL, /* cookieoutlen */
+                                                           dconnuri,
                                                            uri,
                                                            flags,
                                                            dname,
@@ -3926,10 +3929,15 @@ virDomainMigratePeer2Peer (virDomainPtr domain,
                             _("Unable to change target guest XML during migration"));
             return -1;
         }
+        if (uri) {
+            virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
+                            _("Unable to override peer2peer migration URI"));
+            return -1;
+        }
         return domain->conn->driver->domainMigratePerform(domain,
                                                           NULL, /* cookie */
                                                           0,    /* cookielen */
-                                                          uri,
+                                                          dconnuri,
                                                           flags,
                                                           dname,
                                                           bandwidth);
@@ -3968,12 +3976,15 @@ virDomainMigrateDirect (virDomainPtr domain,
     if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
                                  VIR_DRV_FEATURE_MIGRATION_V3)) {
         VIR_DEBUG("Using migration protocol 3");
+        /* dconn URI not relevant in direct migration, since no
+         * target libvirtd is involved */
         return domain->conn->driver->domainMigratePerform3(domain,
                                                            xmlin,
                                                            NULL, /* cookiein */
                                                            0,    /* cookieinlen */
                                                            NULL, /* cookieoutlen */
                                                            NULL, /* cookieoutlen */
+                                                           NULL, /* dconnuri */
                                                            uri,
                                                            flags,
                                                            dname,
@@ -4110,7 +4121,7 @@ virDomainMigrate (virDomainPtr domain,
 
             VIR_DEBUG("Using peer2peer migration");
             if (virDomainMigratePeer2Peer(domain, NULL, flags, dname,
-                                          uri ? uri : dstURI, bandwidth) < 0) {
+                                          uri ? uri : dstURI, NULL, bandwidth) < 0) {
                 VIR_FREE(dstURI);
                 goto error;
             }
@@ -4256,7 +4267,7 @@ virDomainMigrateToURI (virDomainPtr domain,
                                       VIR_DRV_FEATURE_MIGRATION_P2P)) {
             VIR_DEBUG("Using peer2peer migration");
             if (virDomainMigratePeer2Peer(domain, NULL, flags,
-                                          dname, duri, bandwidth) < 0)
+                                          dname, duri, NULL, bandwidth) < 0)
                 goto error;
         } else {
             /* No peer to peer migration supported */
@@ -4758,6 +4769,7 @@ virDomainMigratePerform3(virDomainPtr domain,
                          int cookieinlen,
                          char **cookieout,
                          int *cookieoutlen,
+                         const char *dconnuri,
                          const char *uri,
                          unsigned long flags,
                          const char *dname,
@@ -4766,10 +4778,10 @@ virDomainMigratePerform3(virDomainPtr domain,
     virConnectPtr conn;
 
     VIR_DOMAIN_DEBUG(domain, "xmlin=%s cookiein=%p, cookieinlen=%d, "
-                     "cookieout=%p, cookieoutlen=%p, "
+                     "cookieout=%p, cookieoutlen=%p, dconnuri=%s, "
                      "uri=%s, flags=%lu, dname=%s, bandwidth=%lu",
                      NULLSTR(xmlin), cookiein, cookieinlen,
-                     cookieout, cookieoutlen,
+                     cookieout, cookieoutlen, NULLSTR(dconnuri),
                      uri, flags, NULLSTR(dname), bandwidth);
 
     virResetLastError();
@@ -4791,7 +4803,7 @@ virDomainMigratePerform3(virDomainPtr domain,
         ret = conn->driver->domainMigratePerform3(domain, xmlin,
                                                   cookiein, cookieinlen,
                                                   cookieout, cookieoutlen,
-                                                  uri,
+                                                  dconnuri, uri,
                                                   flags, dname, bandwidth);
         if (ret < 0)
             goto error;
diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h
index c7c1932..68c140b 100644
--- a/src/libvirt_internal.h
+++ b/src/libvirt_internal.h
@@ -161,7 +161,8 @@ int virDomainMigratePerform3(virDomainPtr dom,
                              int cookieinlen,
                              char **cookieout,
                              int *cookieoutlen,
-                             const char *uri,
+                             const char *dconnuri, /* libvirtd URI if Peer2Peer, NULL otherwise */
+                             const char *uri, /* VM Migration URI */
                              unsigned long flags,
                              const char *dname,
                              unsigned long resource);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2f454f7..f836d79 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5961,7 +5961,7 @@ qemudDomainMigratePerform (virDomainPtr dom,
      * Consume any cookie we were able to decode though
      */
     ret = qemuMigrationPerform(driver, dom->conn, vm,
-                               NULL, uri, cookie, cookielen,
+                               NULL, NULL, uri, cookie, cookielen,
                                NULL, NULL, /* No output cookies in v2 */
                                flags, dname, resource, true);
 
@@ -6182,6 +6182,7 @@ qemuDomainMigratePerform3(virDomainPtr dom,
                           int cookieinlen,
                           char **cookieout,
                           int *cookieoutlen,
+                          const char *dconnuri,
                           const char *uri,
                           unsigned long flags,
                           const char *dname,
@@ -6211,7 +6212,7 @@ qemuDomainMigratePerform3(virDomainPtr dom,
     }
 
     ret = qemuMigrationPerform(driver, dom->conn, vm, xmlin,
-                               uri, cookiein, cookieinlen,
+                               dconnuri, uri, cookiein, cookieinlen,
                                cookieout, cookieoutlen,
                                flags, dname, resource, false);
 
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 077a1b1..7817f37 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1778,7 +1778,7 @@ static int doPeer2PeerMigrate3(struct qemud_driver *driver,
         qemuDomainObjEnterRemoteWithDriver(driver, vm);
         ret = dconn->driver->domainMigratePrepare3
             (dconn, cookiein, cookieinlen, &cookieout, &cookieoutlen,
-             NULL, &uri_out, flags, dname, resource, dom_xml);
+             uri, &uri_out, flags, dname, resource, dom_xml);
         qemuDomainObjExitRemoteWithDriver(driver, vm);
     }
     VIR_FREE(dom_xml);
@@ -1798,7 +1798,7 @@ static int doPeer2PeerMigrate3(struct qemud_driver *driver,
      * running, but in paused state until the destination can
      * confirm migration completion.
      */
-    VIR_DEBUG("Perform3 %p uri=%s", sconn, uri_out);
+    VIR_DEBUG("Perform3 %p uri=%s uri_out=%s", sconn, uri, uri_out);
     VIR_FREE(cookiein);
     cookiein = cookieout;
     cookieinlen = cookieoutlen;
@@ -1898,6 +1898,7 @@ static int doPeer2PeerMigrate(struct qemud_driver *driver,
                               virConnectPtr sconn,
                               virDomainObjPtr vm,
                               const char *xmlin,
+                              const char *dconnuri,
                               const char *uri,
                               unsigned long flags,
                               const char *dname,
@@ -1913,7 +1914,7 @@ static int doPeer2PeerMigrate(struct qemud_driver *driver,
      */
 
     qemuDomainObjEnterRemoteWithDriver(driver, vm);
-    dconn = virConnectOpen(uri);
+    dconn = virConnectOpen(dconnuri);
     qemuDomainObjExitRemoteWithDriver(driver, vm);
     if (dconn == NULL) {
         qemuReportError(VIR_ERR_OPERATION_FAILED,
@@ -1962,6 +1963,7 @@ int qemuMigrationPerform(struct qemud_driver *driver,
                          virConnectPtr conn,
                          virDomainObjPtr vm,
                          const char *xmlin,
+                         const char *dconnuri,
                          const char *uri,
                          const char *cookiein,
                          int cookieinlen,
@@ -2005,10 +2007,15 @@ int qemuMigrationPerform(struct qemud_driver *driver,
         }
 
         if (doPeer2PeerMigrate(driver, conn, vm, xmlin,
-                               uri, flags, dname, resource) < 0)
+                               dconnuri, uri, flags, dname, resource) < 0)
             /* doPeer2PeerMigrate already set the error, so just get out */
             goto endjob;
     } else {
+        if (dconnuri) {
+            qemuReportError(VIR_ERR_INTERNAL_ERROR,
+                            "%s", _("Unexpected dconnuri parameter with non-peer2peer migration"));
+            goto endjob;
+        }
         if (doNativeMigrate(driver, vm, uri, cookiein, cookieinlen,
                             cookieout, cookieoutlen,
                             flags, dname, resource) < 0)
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
index a24b3a8..a350579 100644
--- a/src/qemu/qemu_migration.h
+++ b/src/qemu/qemu_migration.h
@@ -63,6 +63,7 @@ int qemuMigrationPerform(struct qemud_driver *driver,
                          virConnectPtr conn,
                          virDomainObjPtr vm,
                          const char *xmlin,
+                         const char *dconnuri,
                          const char *uri,
                          const char *cookiein,
                          int cookieinlen,
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 77bd474..668edfe 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -5174,6 +5174,7 @@ remoteDomainMigratePerform3(virDomainPtr dom,
                             int cookieinlen,
                             char **cookieout,
                             int *cookieoutlen,
+                            const char *dconnuri,
                             const char *uri,
                             unsigned long flags,
                             const char *dname,
@@ -5197,6 +5198,7 @@ remoteDomainMigratePerform3(virDomainPtr dom,
     args.uri = (char *) uri;
     args.flags = flags;
     args.dname = dname == NULL ? NULL : (char **) &dname;
+    args.dconnuri = dconnuri == NULL ? NULL : (char **) &dconnuri;
     args.resource = resource;
 
     if (call (dom->conn, priv, 0, REMOTE_PROC_DOMAIN_MIGRATE_PERFORM3,
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 37b5a3f..214a052 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -2014,6 +2014,7 @@ struct remote_domain_migrate_perform3_args {
     remote_nonnull_domain dom;
     remote_string xmlin;
     opaque cookie_in<REMOTE_MIGRATE_COOKIE_MAX>;
+    remote_string dconnuri;
     remote_nonnull_string uri;
     unsigned hyper flags;
     remote_string dname;
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 616a44b..7285006 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -1510,6 +1510,7 @@ struct remote_domain_migrate_perform3_args {
                 u_int              cookie_in_len;
                 char *             cookie_in_val;
         } cookie_in;
+        remote_string              dconnuri;
         remote_nonnull_string      uri;
         uint64_t                   flags;
         remote_string              dname;
-- 
1.7.4.4


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