[PATCH 02/16] Remote driver implementation of new migration API

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

 



* src/remote/remote_protocol.x: Define wire protocol for migration
  protocol v3
* daemon/remote.c: Server side dispatch
* src/remote/remote_driver.c: Client side serialization
* src/remote/remote_protocol.c, src/remote/remote_protocol.h,
  daemon/remote_dispatch_args.h, daemon/remote_dispatch_prototypes.h,
  daemon/remote_dispatch_ret.h, daemon/remote_dispatch_table.h:
  Re-generate files
* src/remote_protocol-structs: Declare new ABIs
---
 daemon/remote.c              |  315 +++++++++++++++++++++++++++++++++++
 daemon/remote_generator.pl   |   12 ++
 src/remote/remote_driver.c   |  370 +++++++++++++++++++++++++++++++++++++++++-
 src/remote/remote_protocol.x |   79 +++++++++-
 src/remote_protocol-structs  |   90 ++++++++++
 5 files changed, 859 insertions(+), 7 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 2220655..f89d612 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -76,6 +76,7 @@ static virStorageVolPtr get_nonnull_storage_vol(virConnectPtr conn, remote_nonnu
 static virSecretPtr get_nonnull_secret(virConnectPtr conn, remote_nonnull_secret secret);
 static virNWFilterPtr get_nonnull_nwfilter(virConnectPtr conn, remote_nonnull_nwfilter nwfilter);
 static virDomainSnapshotPtr get_nonnull_domain_snapshot(virDomainPtr dom, remote_nonnull_domain_snapshot snapshot);
+static int make_domain(remote_domain *dom_dst, virDomainPtr dom_src);
 static void make_nonnull_domain(remote_nonnull_domain *dom_dst, virDomainPtr dom_src);
 static void make_nonnull_network(remote_nonnull_network *net_dst, virNetworkPtr net_src);
 static void make_nonnull_interface(remote_nonnull_interface *interface_dst, virInterfacePtr interface_src);
@@ -2989,6 +2990,305 @@ cleanup:
 #include "qemu_dispatch_bodies.h"
 
 
+static int
+remoteDispatchDomainMigrateBegin3(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                  struct qemud_client *client ATTRIBUTE_UNUSED,
+                                  virConnectPtr conn,
+                                  remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                  remote_error *rerr,
+                                  remote_domain_migrate_begin3_args *args,
+                                  remote_domain_migrate_begin3_ret *ret)
+{
+    char *xml = NULL;
+    virDomainPtr dom = NULL;
+    char *dname;
+    char *cookieout = NULL;
+    int cookieoutlen = 0;
+    int rv = -1;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
+        goto cleanup;
+
+    dname = args->dname == NULL ? NULL : *args->dname;
+
+    if (!(xml = virDomainMigrateBegin3(dom,
+                                       &cookieout, &cookieoutlen,
+                                       args->flags, dname, args->resource)))
+        goto cleanup;
+
+    /* remoteDispatchClientRequest will free cookie and
+     * the xml string if there is one.
+     */
+    ret->cookie_out.cookie_out_len = cookieoutlen;
+    ret->cookie_out.cookie_out_val = cookieout;
+    ret->xml = xml;
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (dom)
+        virDomainFree(dom);
+    return rv;
+}
+
+
+static int
+remoteDispatchDomainMigratePrepare3(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                    struct qemud_client *client ATTRIBUTE_UNUSED,
+                                    virConnectPtr conn,
+                                    remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                    remote_error *rerr,
+                                    remote_domain_migrate_prepare3_args *args,
+                                    remote_domain_migrate_prepare3_ret *ret)
+{
+    char *cookieout = NULL;
+    int cookieoutlen = 0;
+    char *uri_in;
+    char **uri_out;
+    char *dname;
+    int rv = -1;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    uri_in = args->uri_in == NULL ? NULL : *args->uri_in;
+    dname = args->dname == NULL ? NULL : *args->dname;
+
+    /* Wacky world of XDR ... */
+    if (VIR_ALLOC(uri_out) < 0) {
+        virReportOOMError();
+        goto cleanup;
+    }
+
+    if (virDomainMigratePrepare3(conn,
+                                 args->cookie_in.cookie_in_val,
+                                 args->cookie_in.cookie_in_len,
+                                 &cookieout, &cookieoutlen,
+                                 uri_in, uri_out,
+                                 args->flags, dname, args->resource,
+                                 args->dom_xml) < 0)
+        goto cleanup;
+
+    /* remoteDispatchClientRequest will free cookie, uri_out and
+     * the string if there is one.
+     */
+    ret->cookie_out.cookie_out_len = cookieoutlen;
+    ret->cookie_out.cookie_out_val = cookieout;
+    ret->uri_out = *uri_out == NULL ? NULL : uri_out;
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0) {
+        remoteDispatchError(rerr);
+        VIR_FREE(uri_out);
+    }
+    return rv;
+}
+
+static int
+remoteDispatchDomainMigratePrepareTunnel3(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                          struct qemud_client *client,
+                                          virConnectPtr conn,
+                                          remote_message_header *hdr,
+                                          remote_error *rerr,
+                                          remote_domain_migrate_prepare_tunnel3_args *args,
+                                          remote_domain_migrate_prepare_tunnel3_ret *ret)
+{
+    char *dname;
+    char *cookieout = NULL;
+    int cookieoutlen = 0;
+    struct qemud_client_stream *stream = NULL;
+    int rv = -1;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    dname = args->dname == NULL ? NULL : *args->dname;
+
+    if (!(stream = remoteCreateClientStream(conn, hdr))) {
+        virReportOOMError();
+        goto cleanup;
+    }
+
+    if (virDomainMigratePrepareTunnel3(conn, stream->st,
+                                       args->cookie_in.cookie_in_val,
+                                       args->cookie_in.cookie_in_len,
+                                       &cookieout, &cookieoutlen,
+                                       args->flags, dname, args->resource,
+                                       args->dom_xml) < 0)
+        goto cleanup;
+
+    if (remoteAddClientStream(client, stream, 0) < 0)
+        goto cleanup;
+
+    /* remoteDispatchClientRequest will free cookie
+     */
+    ret->cookie_out.cookie_out_len = cookieoutlen;
+    ret->cookie_out.cookie_out_val = cookieout;
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0) {
+        remoteDispatchError(rerr);
+        VIR_FREE(cookieout);
+    }
+    if (stream && rv < 0) {
+        virStreamAbort(stream->st);
+        remoteFreeClientStream(client, stream);
+    }
+    return rv;
+}
+
+static int
+remoteDispatchDomainMigratePerform3(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                    struct qemud_client *client ATTRIBUTE_UNUSED,
+                                    virConnectPtr conn,
+                                    remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                    remote_error *rerr,
+                                    remote_domain_migrate_perform3_args *args,
+                                    remote_domain_migrate_perform3_ret *ret)
+{
+    virDomainPtr dom = NULL;
+    char *dname;
+    char *cookieout = NULL;
+    int cookieoutlen = 0;
+    int rv = -1;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
+        goto cleanup;
+
+    dname = args->dname == NULL ? NULL : *args->dname;
+
+    if (virDomainMigratePerform3(dom,
+                                 args->cookie_in.cookie_in_val,
+                                 args->cookie_in.cookie_in_len,
+                                 &cookieout, &cookieoutlen,
+                                 args->uri,
+                                 args->flags, dname, args->resource) < 0)
+        goto cleanup;
+
+    /* remoteDispatchClientRequest will free cookie
+     */
+    ret->cookie_out.cookie_out_len = cookieoutlen;
+    ret->cookie_out.cookie_out_val = cookieout;
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (dom)
+        virDomainFree(dom);
+    return rv;
+}
+
+
+static int
+remoteDispatchDomainMigrateFinish3(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                   struct qemud_client *client ATTRIBUTE_UNUSED,
+                                   virConnectPtr conn,
+                                   remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                   remote_error *rerr,
+                                   remote_domain_migrate_finish3_args *args,
+                                   remote_domain_migrate_finish3_ret *ret)
+{
+    virDomainPtr dom = NULL;
+    char *cookieout = NULL;
+    int cookieoutlen = 0;
+    int rv = -1;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (virDomainMigrateFinish3(conn, args->dname,
+                                args->cookie_in.cookie_in_val,
+                                args->cookie_in.cookie_in_len,
+                                &cookieout, &cookieoutlen,
+                                args->uri,
+                                args->flags,
+                                args->cancelled,
+                                &dom) < 0)
+        goto cleanup;
+
+    if (dom &&
+        make_domain(&ret->ddom, dom) < 0)
+        goto cleanup;
+
+    /* remoteDispatchClientRequest will free cookie
+     */
+    ret->cookie_out.cookie_out_len = cookieoutlen;
+    ret->cookie_out.cookie_out_val = cookieout;
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0) {
+        remoteDispatchError(rerr);
+        VIR_FREE(cookieout);
+    }
+    if (dom)
+        virDomainFree(dom);
+    return rv;
+}
+
+
+static int
+remoteDispatchDomainMigrateConfirm3(struct qemud_server *server ATTRIBUTE_UNUSED,
+                                    struct qemud_client *client ATTRIBUTE_UNUSED,
+                                    virConnectPtr conn,
+                                    remote_message_header *hdr ATTRIBUTE_UNUSED,
+                                    remote_error *rerr,
+                                    remote_domain_migrate_confirm3_args *args,
+                                    void *ret ATTRIBUTE_UNUSED)
+{
+    virDomainPtr dom = NULL;
+    int rv = -1;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
+        goto cleanup;
+
+    if (virDomainMigrateConfirm3(dom,
+                                 args->cookie_in.cookie_in_val,
+                                 args->cookie_in.cookie_in_len,
+                                 args->flags, args->cancelled) < 0)
+        goto cleanup;
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (dom)
+        virDomainFree(dom);
+    return rv;
+}
+
+
 /*----- Helpers. -----*/
 
 /* get_nonnull_domain and get_nonnull_network turn an on-wire
@@ -3054,6 +3354,21 @@ get_nonnull_domain_snapshot(virDomainPtr dom, remote_nonnull_domain_snapshot sna
 }
 
 /* Make remote_nonnull_domain and remote_nonnull_network. */
+static int
+make_domain(remote_domain *dom_dst, virDomainPtr dom_src)
+{
+    remote_domain rdom;
+    if (VIR_ALLOC(rdom) < 0)
+        return -1;
+
+    rdom->id = dom_src->id;
+    rdom->name = strdup(dom_src->name);
+    memcpy(rdom->uuid, dom_src->uuid, VIR_UUID_BUFLEN);
+
+    *dom_dst = rdom;
+    return 0;
+}
+
 static void
 make_nonnull_domain(remote_nonnull_domain *dom_dst, virDomainPtr dom_src)
 {
diff --git a/daemon/remote_generator.pl b/daemon/remote_generator.pl
index 79d2021..d525983 100755
--- a/daemon/remote_generator.pl
+++ b/daemon/remote_generator.pl
@@ -273,8 +273,14 @@ elsif ($opt_b) {
                           "DomainGetVcpus",
                           "DomainMemoryPeek",
                           "DomainMemoryStats",
+                          "DomainMigrateBegin3",
+                          "DomainMigrateConfirm3",
+                          "DomainMigrateFinish3",
+                          "DomainMigratePerform3",
                           "DomainMigratePrepare",
                           "DomainMigratePrepare2",
+                          "DomainMigratePrepare3",
+                          "DomainMigratePrepareTunnel3",
                           "GetType",
                           "NodeDeviceGetParent",
                           "NodeGetSecurityModel",
@@ -802,8 +808,14 @@ elsif ($opt_k) {
                           "DomainGetVcpus",
                           "DomainMemoryPeek",
                           "DomainMemoryStats",
+                          "DomainMigrateBegin3",
+                          "DomainMigrateConfirm3",
+                          "DomainMigrateFinish3",
+                          "DomainMigratePerform3",
                           "DomainMigratePrepare",
                           "DomainMigratePrepare2",
+                          "DomainMigratePrepare3",
+                          "DomainMigratePrepareTunnel3",
                           "GetType",
                           "NodeDeviceGetParent",
                           "NodeGetSecurityModel",
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 694a7b2..e113e39 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -245,6 +245,7 @@ static int remoteAuthPolkit (virConnectPtr conn, struct private_data *priv, int
     virReportErrorHelper(VIR_FROM_REMOTE, code, __FILE__,         \
                          __FUNCTION__, __LINE__, __VA_ARGS__)
 
+static virDomainPtr get_domain (virConnectPtr conn, remote_domain domain);
 static virDomainPtr get_nonnull_domain (virConnectPtr conn, remote_nonnull_domain domain);
 static virNetworkPtr get_nonnull_network (virConnectPtr conn, remote_nonnull_network network);
 static virNWFilterPtr get_nonnull_nwfilter (virConnectPtr conn, remote_nonnull_nwfilter nwfilter);
@@ -4967,9 +4968,350 @@ done:
     return rv;
 }
 
+
+static char *
+remoteDomainMigrateBegin3(virDomainPtr domain,
+                          char **cookieout,
+                          int *cookieoutlen,
+                          unsigned long flags,
+                          const char *dname,
+                          unsigned long resource)
+{
+    char *rv = NULL;
+    remote_domain_migrate_begin3_args args;
+    remote_domain_migrate_begin3_ret ret;
+    struct private_data *priv = domain->conn->privateData;
+
+    remoteDriverLock(priv);
+
+    memset(&args, 0, sizeof(args));
+    memset(&ret, 0, sizeof(ret));
+
+    make_nonnull_domain (&args.dom, domain);
+    args.flags = flags;
+    args.dname = dname == NULL ? NULL : (char **) &dname;
+    args.resource = resource;
+
+    if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_MIGRATE_BEGIN3,
+              (xdrproc_t) xdr_remote_domain_migrate_begin3_args, (char *) &args,
+              (xdrproc_t) xdr_remote_domain_migrate_begin3_ret, (char *) &ret) == -1)
+        goto done;
+
+    if (ret.cookie_out.cookie_out_len > 0) {
+        if (!cookieout || !cookieoutlen) {
+            remoteError(VIR_ERR_INTERNAL_ERROR, "%s",
+                        _("caller ignores cookieout or cookieoutlen"));
+            goto error;
+        }
+        *cookieout = ret.cookie_out.cookie_out_val; /* Caller frees. */
+        *cookieoutlen = ret.cookie_out.cookie_out_len;
+    }
+
+    rv = ret.xml; /* caller frees */
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+
+error:
+    VIR_FREE(ret.cookie_out.cookie_out_val);
+    goto done;
+}
+
+
+static int
+remoteDomainMigratePrepare3(virConnectPtr dconn,
+                            const char *cookiein,
+                            int cookieinlen,
+                            char **cookieout,
+                            int *cookieoutlen,
+                            const char *uri_in,
+                            char **uri_out,
+                            unsigned long flags,
+                            const char *dname,
+                            unsigned long resource,
+                            const char *dom_xml)
+{
+    int rv = -1;
+    remote_domain_migrate_prepare3_args args;
+    remote_domain_migrate_prepare3_ret ret;
+    struct private_data *priv = dconn->privateData;
+
+    remoteDriverLock(priv);
+
+    memset(&args, 0, sizeof(args));
+    memset(&ret, 0, sizeof(ret));
+
+    args.cookie_in.cookie_in_val = (char *)cookiein;
+    args.cookie_in.cookie_in_len = cookieinlen;
+    args.uri_in = uri_in == NULL ? NULL : (char **) &uri_in;
+    args.flags = flags;
+    args.dname = dname == NULL ? NULL : (char **) &dname;
+    args.resource = resource;
+    args.dom_xml = (char *) dom_xml;
+
+    memset (&ret, 0, sizeof ret);
+    if (call (dconn, priv, 0, REMOTE_PROC_DOMAIN_MIGRATE_PREPARE3,
+              (xdrproc_t) xdr_remote_domain_migrate_prepare3_args, (char *) &args,
+              (xdrproc_t) xdr_remote_domain_migrate_prepare3_ret, (char *) &ret) == -1)
+        goto done;
+
+    if (ret.cookie_out.cookie_out_len > 0) {
+        if (!cookieout || !cookieoutlen) {
+            remoteError(VIR_ERR_INTERNAL_ERROR, "%s",
+                        _("caller ignores cookieout or cookieoutlen"));
+            goto error;
+        }
+        *cookieout = ret.cookie_out.cookie_out_val; /* Caller frees. */
+        *cookieoutlen = ret.cookie_out.cookie_out_len;
+    }
+    if (ret.uri_out) {
+        if (!uri_out) {
+            remoteError(VIR_ERR_INTERNAL_ERROR, "%s",
+                        _("caller ignores uri_out"));
+            goto error;
+        }
+        *uri_out = *ret.uri_out; /* Caller frees. */
+    }
+
+    rv = 0;
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+error:
+    VIR_FREE(ret.cookie_out.cookie_out_val);
+    if (ret.uri_out)
+        VIR_FREE(*ret.uri_out);
+    goto done;
+}
+
+
+static int
+remoteDomainMigratePrepareTunnel3(virConnectPtr dconn,
+                                  virStreamPtr st,
+                                  const char *cookiein,
+                                  int cookieinlen,
+                                  char **cookieout,
+                                  int *cookieoutlen,
+                                  unsigned long flags,
+                                  const char *dname,
+                                  unsigned long resource,
+                                  const char *dom_xml)
+{
+    struct private_data *priv = dconn->privateData;
+    struct private_stream_data *privst = NULL;
+    int rv = -1;
+    remote_domain_migrate_prepare_tunnel3_args args;
+    remote_domain_migrate_prepare_tunnel3_ret ret;
+
+    remoteDriverLock(priv);
+
+    memset(&args, 0, sizeof(args));
+    memset(&ret, 0, sizeof(ret));
+
+    if (!(privst = remoteStreamOpen(st,
+                                    REMOTE_PROC_DOMAIN_MIGRATE_PREPARE_TUNNEL3,
+                                    priv->counter)))
+        goto done;
+
+    st->driver = &remoteStreamDrv;
+    st->privateData = privst;
+
+    args.cookie_in.cookie_in_val = (char *)cookiein;
+    args.cookie_in.cookie_in_len = cookieinlen;
+    args.flags = flags;
+    args.dname = dname == NULL ? NULL : (char **) &dname;
+    args.resource = resource;
+    args.dom_xml = (char *) dom_xml;
+
+    if (call(dconn, priv, 0, REMOTE_PROC_DOMAIN_MIGRATE_PREPARE_TUNNEL3,
+             (xdrproc_t) xdr_remote_domain_migrate_prepare_tunnel3_args, (char *) &args,
+             (xdrproc_t) xdr_remote_domain_migrate_prepare_tunnel3_ret, (char *) &ret) == -1) {
+        remoteStreamRelease(st);
+        goto done;
+    }
+
+    if (ret.cookie_out.cookie_out_len > 0) {
+        if (!cookieout || !cookieoutlen) {
+            remoteError(VIR_ERR_INTERNAL_ERROR, "%s",
+                        _("caller ignores cookieout or cookieoutlen"));
+            goto error;
+        }
+        *cookieout = ret.cookie_out.cookie_out_val; /* Caller frees. */
+        *cookieoutlen = ret.cookie_out.cookie_out_len;
+    }
+
+    rv = 0;
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+
+error:
+    VIR_FREE(ret.cookie_out.cookie_out_val);
+    goto done;
+}
+
+
+static int
+remoteDomainMigratePerform3(virDomainPtr dom,
+                            const char *cookiein,
+                            int cookieinlen,
+                            char **cookieout,
+                            int *cookieoutlen,
+                            const char *uri,
+                            unsigned long flags,
+                            const char *dname,
+                            unsigned long resource)
+{
+    int rv = -1;
+    remote_domain_migrate_perform3_args args;
+    remote_domain_migrate_perform3_ret ret;
+    struct private_data *priv = dom->conn->privateData;
+
+    remoteDriverLock(priv);
+
+    memset(&args, 0, sizeof(args));
+    memset(&ret, 0, sizeof(ret));
+
+    make_nonnull_domain(&args.dom, dom);
+
+    args.cookie_in.cookie_in_val = (char *)cookiein;
+    args.cookie_in.cookie_in_len = cookieinlen;
+    args.uri = (char *) uri;
+    args.flags = flags;
+    args.dname = dname == NULL ? NULL : (char **) &dname;
+    args.resource = resource;
+
+    if (call (dom->conn, priv, 0, REMOTE_PROC_DOMAIN_MIGRATE_PERFORM3,
+              (xdrproc_t) xdr_remote_domain_migrate_perform3_args, (char *) &args,
+              (xdrproc_t) xdr_remote_domain_migrate_perform3_ret, (char *) &ret) == -1)
+        goto done;
+
+    if (ret.cookie_out.cookie_out_len > 0) {
+        if (!cookieout || !cookieoutlen) {
+            remoteError(VIR_ERR_INTERNAL_ERROR, "%s",
+                        _("caller ignores cookieout or cookieoutlen"));
+            goto error;
+        }
+        *cookieout = ret.cookie_out.cookie_out_val; /* Caller frees. */
+        *cookieoutlen = ret.cookie_out.cookie_out_len;
+    }
+
+    rv = 0;
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+
+error:
+    VIR_FREE(ret.cookie_out.cookie_out_val);
+    goto done;
+}
+
+
+static int
+remoteDomainMigrateFinish3(virConnectPtr dconn,
+                           const char *dname,
+                           const char *cookiein,
+                           int cookieinlen,
+                           char **cookieout,
+                           int *cookieoutlen,
+                           const char *uri,
+                           unsigned long flags,
+                           int cancelled,
+                           virDomainPtr *ddom)
+{
+    remote_domain_migrate_finish3_args args;
+    remote_domain_migrate_finish3_ret ret;
+    struct private_data *priv = dconn->privateData;
+    int rv = -1;
+
+    remoteDriverLock(priv);
+
+    *ddom = NULL;
+    memset(&args, 0, sizeof(args));
+    memset(&ret, 0, sizeof(ret));
+
+    args.cookie_in.cookie_in_val = (char *)cookiein;
+    args.cookie_in.cookie_in_len = cookieinlen;
+    args.dname = (char *) dname;
+    args.uri = (char *) uri;
+    args.flags = flags;
+    args.cancelled = cancelled;
+
+    if (call (dconn, priv, 0, REMOTE_PROC_DOMAIN_MIGRATE_FINISH3,
+              (xdrproc_t) xdr_remote_domain_migrate_finish3_args, (char *) &args,
+              (xdrproc_t) xdr_remote_domain_migrate_finish3_ret, (char *) &ret) == -1)
+        goto done;
+
+    *ddom = get_domain(dconn, ret.ddom);
+
+    if (ret.cookie_out.cookie_out_len > 0) {
+        if (!cookieout || !cookieoutlen) {
+            remoteError(VIR_ERR_INTERNAL_ERROR, "%s",
+                        _("caller ignores cookieout or cookieoutlen"));
+            goto error;
+        }
+        *cookieout = ret.cookie_out.cookie_out_val; /* Caller frees. */
+        *cookieoutlen = ret.cookie_out.cookie_out_len;
+        ret.cookie_out.cookie_out_val = NULL;
+        ret.cookie_out.cookie_out_len = 0;
+    }
+
+    xdr_free ((xdrproc_t) &xdr_remote_domain_migrate_finish3_ret, (char *) &ret);
+
+    rv = 0;
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+
+error:
+    VIR_FREE(ret.cookie_out.cookie_out_val);
+    goto done;
+}
+
+
+static int
+remoteDomainMigrateConfirm3(virDomainPtr domain,
+                            const char *cookiein,
+                            int cookieinlen,
+                            unsigned long flags,
+                            int cancelled)
+{
+    int rv = -1;
+    remote_domain_migrate_confirm3_args args;
+    struct private_data *priv = domain->conn->privateData;
+
+    remoteDriverLock(priv);
+
+    memset(&args, 0, sizeof(args));
+
+    make_nonnull_domain (&args.dom, domain);
+    args.cookie_in.cookie_in_len = cookieinlen;
+    args.cookie_in.cookie_in_val = (char *) cookiein;
+    args.flags = flags;
+    args.cancelled = cancelled;
+
+    if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_MIGRATE_CONFIRM3,
+              (xdrproc_t) xdr_remote_domain_migrate_confirm3_args, (char *) &args,
+              (xdrproc_t) xdr_void, (char *) NULL) == -1)
+        goto done;
+
+    rv = 0;
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+}
+
+
 #include "remote_client_bodies.h"
 #include "qemu_client_bodies.h"
 
+
 /*----------------------------------------------------------------------*/
 
 static struct remote_thread_call *
@@ -6262,6 +6604,22 @@ remoteDomainEventQueueFlush(int timer ATTRIBUTE_UNUSED, void *opaque)
  * but if they do then virterror_internal.has been set.
  */
 static virDomainPtr
+get_domain (virConnectPtr conn, remote_domain domain)
+{
+    virDomainPtr dom = NULL;
+    if (domain) {
+        dom = virGetDomain (conn, domain->name, BAD_CAST domain->uuid);
+        if (dom) dom->id = domain->id;
+    }
+    return dom;
+}
+
+/* get_nonnull_domain and get_nonnull_network turn an on-wire
+ * (name, uuid) pair into virDomainPtr or virNetworkPtr object.
+ * These can return NULL if underlying memory allocations fail,
+ * but if they do then virterror_internal.has been set.
+ */
+static virDomainPtr
 get_nonnull_domain (virConnectPtr conn, remote_nonnull_domain domain)
 {
     virDomainPtr dom;
@@ -6499,12 +6857,12 @@ static virDriver remote_driver = {
     remoteQemuDomainMonitorCommand, /* qemuDomainMonitorCommand */
     remoteDomainOpenConsole, /* domainOpenConsole */
     remoteDomainInjectNMI, /* domainInjectNMI */
-    NULL, /* domainMigrateBegin3 */
-    NULL, /* domainMigratePrepare3 */
-    NULL, /* domainMigratePrepareTunnel3 */
-    NULL, /* domainMigratePerform3 */
-    NULL, /* domainMigrateFinish3 */
-    NULL, /* domainMigrateConfirm3 */
+    remoteDomainMigrateBegin3, /* domainMigrateBegin3 */
+    remoteDomainMigratePrepare3, /* domainMigratePrepare3 */
+    remoteDomainMigratePrepareTunnel3, /* domainMigratePrepareTunnel3 */
+    remoteDomainMigratePerform3, /* domainMigratePerform3 */
+    remoteDomainMigrateFinish3, /* domainMigrateFinish3 */
+    remoteDomainMigrateConfirm3, /* domainMigrateConfirm3 */
 };
 
 static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 2cf6022..ec083a4 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -1945,6 +1945,76 @@ struct remote_storage_vol_download_args {
     unsigned int flags;
 };
 
+struct remote_domain_migrate_begin3_args {
+    remote_nonnull_domain dom;
+    unsigned hyper flags;
+    remote_string dname;
+    unsigned hyper resource;
+};
+
+struct remote_domain_migrate_begin3_ret {
+    opaque cookie_out<REMOTE_MIGRATE_COOKIE_MAX>;
+    remote_nonnull_string xml;
+};
+
+struct remote_domain_migrate_prepare3_args {
+    opaque cookie_in<REMOTE_MIGRATE_COOKIE_MAX>;
+    remote_string uri_in;
+    unsigned hyper flags;
+    remote_string dname;
+    unsigned hyper resource;
+    remote_nonnull_string dom_xml;
+};
+
+struct remote_domain_migrate_prepare3_ret {
+    opaque cookie_out<REMOTE_MIGRATE_COOKIE_MAX>;
+    remote_string uri_out;
+};
+
+struct remote_domain_migrate_prepare_tunnel3_args {
+    opaque cookie_in<REMOTE_MIGRATE_COOKIE_MAX>;
+    unsigned hyper flags;
+    remote_string dname;
+    unsigned hyper resource;
+    remote_nonnull_string dom_xml;
+};
+
+struct remote_domain_migrate_prepare_tunnel3_ret {
+    opaque cookie_out<REMOTE_MIGRATE_COOKIE_MAX>;
+};
+
+struct remote_domain_migrate_perform3_args {
+    remote_nonnull_domain dom;
+    opaque cookie_in<REMOTE_MIGRATE_COOKIE_MAX>;
+    remote_nonnull_string uri;
+    unsigned hyper flags;
+    remote_string dname;
+    unsigned hyper resource;
+};
+
+struct remote_domain_migrate_perform3_ret {
+    opaque cookie_out<REMOTE_MIGRATE_COOKIE_MAX>;
+};
+
+struct remote_domain_migrate_finish3_args {
+    remote_nonnull_string dname;
+    opaque cookie_in<REMOTE_MIGRATE_COOKIE_MAX>;
+    remote_nonnull_string uri;
+    unsigned hyper flags;
+    int cancelled;
+};
+
+struct remote_domain_migrate_finish3_ret {
+    remote_domain ddom;
+    opaque cookie_out<REMOTE_MIGRATE_COOKIE_MAX>;
+};
+
+struct remote_domain_migrate_confirm3_args {
+    remote_nonnull_domain dom;
+    opaque cookie_in<REMOTE_MIGRATE_COOKIE_MAX>;
+    unsigned hyper flags;
+    int cancelled;
+};
 
 /*----- Protocol. -----*/
 
@@ -2182,7 +2252,14 @@ enum remote_procedure {
     REMOTE_PROC_DOMAIN_MIGRATE_SET_MAX_SPEED = 207,
     REMOTE_PROC_STORAGE_VOL_UPLOAD = 208,
     REMOTE_PROC_STORAGE_VOL_DOWNLOAD = 209,
-    REMOTE_PROC_DOMAIN_INJECT_NMI = 210
+    REMOTE_PROC_DOMAIN_INJECT_NMI = 210,
+
+    REMOTE_PROC_DOMAIN_MIGRATE_BEGIN3 = 211,
+    REMOTE_PROC_DOMAIN_MIGRATE_PREPARE3 = 212,
+    REMOTE_PROC_DOMAIN_MIGRATE_PREPARE_TUNNEL3 = 213,
+    REMOTE_PROC_DOMAIN_MIGRATE_PERFORM3 = 214,
+    REMOTE_PROC_DOMAIN_MIGRATE_FINISH3 = 215,
+    REMOTE_PROC_DOMAIN_MIGRATE_CONFIRM3 = 216
 
     /*
      * Notice how the entries are grouped in sets of 10 ?
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 0507a91..27cd6a4 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -1431,6 +1431,96 @@ struct remote_storage_vol_download_args {
         uint64_t                   length;
         u_int                      flags;
 };
+struct remote_domain_migrate_begin3_args {
+        remote_nonnull_domain      dom;
+        uint64_t                   flags;
+        remote_string              dname;
+        uint64_t                   resource;
+};
+struct remote_domain_migrate_begin3_ret {
+        struct {
+                u_int              cookie_out_len;
+                char *             cookie_out_val;
+        } cookie_out;
+        remote_nonnull_string      xml;
+};
+struct remote_domain_migrate_prepare3_args {
+        struct {
+                u_int              cookie_in_len;
+                char *             cookie_in_val;
+        } cookie_in;
+        remote_string              uri_in;
+        uint64_t                   flags;
+        remote_string              dname;
+        uint64_t                   resource;
+        remote_nonnull_string      dom_xml;
+};
+struct remote_domain_migrate_prepare3_ret {
+        struct {
+                u_int              cookie_out_len;
+                char *             cookie_out_val;
+        } cookie_out;
+        remote_string              uri_out;
+};
+struct remote_domain_migrate_prepare_tunnel3_args {
+        struct {
+                u_int              cookie_in_len;
+                char *             cookie_in_val;
+        } cookie_in;
+        uint64_t                   flags;
+        remote_string              dname;
+        uint64_t                   resource;
+        remote_nonnull_string      dom_xml;
+};
+struct remote_domain_migrate_prepare_tunnel3_ret {
+        struct {
+                u_int              cookie_out_len;
+                char *             cookie_out_val;
+        } cookie_out;
+};
+struct remote_domain_migrate_perform3_args {
+        remote_nonnull_domain      dom;
+        struct {
+                u_int              cookie_in_len;
+                char *             cookie_in_val;
+        } cookie_in;
+        remote_nonnull_string      uri;
+        uint64_t                   flags;
+        remote_string              dname;
+        uint64_t                   resource;
+};
+struct remote_domain_migrate_perform3_ret {
+        struct {
+                u_int              cookie_out_len;
+                char *             cookie_out_val;
+        } cookie_out;
+};
+struct remote_domain_migrate_finish3_args {
+        remote_nonnull_string      dname;
+        struct {
+                u_int              cookie_in_len;
+                char *             cookie_in_val;
+        } cookie_in;
+        remote_nonnull_string      uri;
+        uint64_t                   flags;
+        int                        cancelled;
+};
+struct remote_domain_migrate_finish3_ret {
+        remote_domain              ddom;
+        struct {
+                u_int              cookie_out_len;
+                char *             cookie_out_val;
+        } cookie_out;
+};
+struct remote_domain_migrate_confirm3_args {
+        remote_nonnull_domain      dom;
+        struct {
+                u_int              cookie_in_len;
+                char *             cookie_in_val;
+        } cookie_in;
+        uint64_t                   flags;
+        int                        cancelled;
+};
 struct remote_message_header {
         u_int                      prog;
         u_int                      vers;
-- 
1.7.4.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]