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

[libvirt] [PATCH 2/8] Define remote wire protocol & impls for virDomainQemuAttach



* daemon/remote.c: Server side dispatcher
* src/remote/remote_driver.c: Client side dispatcher
* src/remote/qemu_protocol.x: Wire protocol definition
---
 daemon/remote.c            |   41 +++++++++++++++++++++++++++++++++++++++++
 src/remote/qemu_protocol.x |   13 ++++++++++++-
 src/remote/remote_driver.c |   30 ++++++++++++++++++++++++++++++
 3 files changed, 83 insertions(+), 1 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 2889908..85fc978 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -2645,6 +2645,47 @@ cleanup:
 
 
 static int
+qemuDispatchDomainAttach(virNetServerPtr server ATTRIBUTE_UNUSED,
+                         virNetServerClientPtr client ATTRIBUTE_UNUSED,
+                         virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                         virNetMessageErrorPtr rerr,
+                         qemu_domain_attach_args *args,
+                         qemu_domain_attach_ret *ret)
+{
+    virDomainPtr dom = NULL;
+    int rv = -1;
+    struct daemonClientPrivate *priv =
+        virNetServerClientGetPrivateData(client);
+
+    if (!priv->conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(dom = virDomainQemuAttach(priv->conn,
+                                    args->pid,
+                                    args->flags)))
+        goto cleanup;
+
+    make_nonnull_domain(&ret->dom, dom);
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        virNetMessageSaveError(rerr);
+    if (dom)
+        virDomainFree(dom);
+    return rv;
+}
+
+
+#include "remote_dispatch_bodies.h"
+#include "qemu_dispatch_bodies.h"
+
+
+>>>>>>> Define remote wire protocol & impls for virDomainQemuAttach
+static int
 remoteDispatchDomainMigrateBegin3(virNetServerPtr server ATTRIBUTE_UNUSED,
                                   virNetServerClientPtr client ATTRIBUTE_UNUSED,
                                   virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
diff --git a/src/remote/qemu_protocol.x b/src/remote/qemu_protocol.x
index fa453f4..4d510ff 100644
--- a/src/remote/qemu_protocol.x
+++ b/src/remote/qemu_protocol.x
@@ -37,6 +37,16 @@ struct qemu_monitor_command_ret {
     remote_nonnull_string result;
 };
 
+
+struct qemu_domain_attach_args {
+    unsigned hyper pid;
+    unsigned int flags;
+};
+
+struct qemu_domain_attach_ret {
+    remote_nonnull_domain dom;
+};
+
 /* Define the program number, protocol version and procedure numbers here. */
 const QEMU_PROGRAM = 0x20008087;
 const QEMU_PROTOCOL_VERSION = 1;
@@ -45,5 +55,6 @@ enum qemu_procedure {
     /* Each function must have a two-word comment.  The first word is
      * whether remote_generator.pl handles daemon, the second whether
      * it handles src/remote.  */
-    QEMU_PROC_MONITOR_COMMAND = 1 /* skipgen skipgen */
+    QEMU_PROC_MONITOR_COMMAND = 1, /* skipgen skipgen */
+    QEMU_PROC_DOMAIN_ATTACH = 2 /* skipgen skipgen */
 };
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index f318740..c4842a2 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -3547,6 +3547,35 @@ done:
 }
 
 
+static virDomainPtr
+remoteQemuDomainAttach(virConnectPtr conn, unsigned long long pid, unsigned int flags)
+{
+    virDomainPtr rv = NULL;
+    struct private_data *priv = conn->privateData;
+    qemu_domain_attach_args args;
+    qemu_domain_attach_ret ret;
+
+    remoteDriverLock(priv);
+
+    args.pid = pid;
+    args.flags = flags;
+
+    memset(&ret, 0, sizeof ret);
+
+    if (call(conn, priv, REMOTE_CALL_QEMU, QEMU_PROC_DOMAIN_ATTACH,
+             (xdrproc_t)xdr_qemu_domain_attach_args, (char *)&args,
+             (xdrproc_t)xdr_qemu_domain_attach_ret, (char *)&ret) == -1)
+        goto done;
+
+    rv = get_nonnull_domain(conn, ret.dom);
+    xdr_free((xdrproc_t)xdr_qemu_domain_attach_ret, (char *)&ret);
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+}
+
+
 static char *
 remoteDomainMigrateBegin3(virDomainPtr domain,
                           const char *xmlin,
@@ -4222,6 +4251,7 @@ static virDriver remote_driver = {
     .domainRevertToSnapshot = remoteDomainRevertToSnapshot, /* 0.8.0 */
     .domainSnapshotDelete = remoteDomainSnapshotDelete, /* 0.8.0 */
     .qemuDomainMonitorCommand = remoteQemuDomainMonitorCommand, /* 0.8.3 */
+    .qemuDomainAttach = remoteQemuDomainAttach, /* 0.9.3 */
     .domainOpenConsole = remoteDomainOpenConsole, /* 0.8.6 */
     .domainInjectNMI = remoteDomainInjectNMI, /* 0.9.2 */
     .domainMigrateBegin3 = remoteDomainMigrateBegin3, /* 0.9.2 */
-- 
1.7.4.4


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