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

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

 



* 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            |   35 +++++++++++++++++++++++++++++++++++
 src/remote/qemu_protocol.x |   13 ++++++++++++-
 src/remote/remote_driver.c |   30 ++++++++++++++++++++++++++++++
 3 files changed, 77 insertions(+), 1 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 37fbed0..9b2c619 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -2778,6 +2778,41 @@ cleanup:
 }
 
 
+static int
+qemuDispatchDomainAttach(struct qemud_server *server ATTRIBUTE_UNUSED,
+                         struct qemud_client *client ATTRIBUTE_UNUSED,
+                         virConnectPtr conn,
+                         remote_message_header *hdr ATTRIBUTE_UNUSED,
+                         remote_error *rerr,
+                         qemu_domain_attach_args *args,
+                         qemu_domain_attach_ret *ret)
+{
+    virDomainPtr dom = NULL;
+    int rv = -1;
+
+    if (!conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(dom = virDomainQemuAttach(conn,
+                                    args->pid,
+                                    args->flags)))
+        goto cleanup;
+
+    make_nonnull_domain(&ret->dom, dom);
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+    if (dom)
+        virDomainFree(dom);
+    return rv;
+}
+
+
 #include "remote_dispatch_bodies.h"
 #include "qemu_dispatch_bodies.h"
 
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 13f8820..43dfdaa 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -4644,6 +4644,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,
@@ -6525,6 +6554,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

--
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]