[PATCH v3 4/8] screenshot: Implementing the remote protocol

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

 



* src/remote/remote_protocol.x: Wire protocol definition
* daemon/remote.c: New function
* daemon/remote_generator.pl: Don't generate remote function body
* src/remote/remote_driver.c: Client side
* src/remote_protocol-structs: Add structures
---
 daemon/remote.c              |   57 ++++++++++++++++++++++++++++++++++++++++++
 daemon/remote_generator.pl   |    2 +
 src/remote/remote_driver.c   |   40 ++++++++++++++++++++++++++++-
 src/remote/remote_protocol.x |   12 ++++++++-
 src/remote_protocol-structs  |    7 +++++
 5 files changed, 116 insertions(+), 2 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 2220655..81b400a 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -1692,6 +1692,63 @@ no_memory:
     goto cleanup;
 }
 
+static int
+remoteDispatchDomainScreenshot (struct qemud_server *server ATTRIBUTE_UNUSED,
+                                struct qemud_client *client,
+                                virConnectPtr conn,
+                                remote_message_header *hdr,
+                                remote_error *rerr,
+                                remote_domain_screenshot_args *args,
+                                remote_domain_screenshot_ret *ret)
+{
+    int rv = -1;
+    struct qemud_client_stream *stream = NULL;
+    virDomainPtr dom;
+    char *mime, **mime_p;
+
+    ret->mime = NULL;
+
+    dom = get_nonnull_domain (conn, args->dom);
+    if (dom == NULL)
+        goto err;
+
+    stream = remoteCreateClientStream(conn, hdr);
+    if (!stream)
+        goto err;
+
+    mime = virDomainScreenshot(dom, stream->st, args->flags);
+    if (!mime)
+        goto err;
+
+    if (remoteAddClientStream(client, stream, 1) < 0) {
+        virStreamAbort(stream->st);
+        goto err;
+    }
+
+    if (VIR_ALLOC(mime_p) < 0) {
+        remoteDispatchOOMError(rerr);
+        goto cleanup;
+    }
+
+    *mime_p = strdup(mime);
+    if (*mime_p == NULL) {
+        remoteDispatchOOMError(rerr);
+        goto cleanup;
+    }
+
+    ret->mime = mime_p;
+    rv = 0;
+
+err:
+    if (rv < 0)
+        remoteDispatchError(rerr);
+cleanup:
+    virDomainFree(dom);
+    if (stream && rv != 0)
+        remoteFreeClientStream(client, stream);
+    return rv;
+}
+
 /*-------------------------------------------------------------*/
 
 static int
diff --git a/daemon/remote_generator.pl b/daemon/remote_generator.pl
index 062ccc1..1837c2f 100755
--- a/daemon/remote_generator.pl
+++ b/daemon/remote_generator.pl
@@ -248,6 +248,7 @@ elsif ($opt_b) {
                           "DomainMigratePrepareTunnel",
                           "DomainOpenConsole",
                           "DomainPinVcpu",
+                          "DomainScreenshot",
                           "DomainSetSchedulerParameters",
                           "DomainSetMemoryParameters",
                           "DomainSetBlkioParameters",
@@ -737,6 +738,7 @@ elsif ($opt_k) {
                           "DomainEventsRegisterAny",
                           "DomainMigratePrepareTunnel",
                           "DomainOpenConsole",
+                          "DomainScreenshot",
                           "DomainSetSchedulerParameters",
                           "DomainSetMemoryParameters",
                           "DomainSetBlkioParameters",
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 67e91c3..26d9b02 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -4798,6 +4798,44 @@ done:
     return rv;
 }
 
+static char *
+remoteDomainScreenshot (virDomainPtr domain,
+                        virStreamPtr st,
+                        unsigned int flags)
+{
+    struct private_data *priv = domain->conn->privateData;
+    struct private_stream_data *privst = NULL;
+    remote_domain_screenshot_args args;
+    remote_domain_screenshot_ret ret;
+    char *rv = NULL;
+
+    remoteDriverLock(priv);
+
+    if (!(privst = remoteStreamOpen(st,
+                                    REMOTE_PROC_DOMAIN_SCREENSHOT,
+                                    priv->counter)))
+        goto done;
+
+    st->driver = &remoteStreamDrv;
+    st->privateData = privst;
+
+    make_nonnull_domain(&args.dom, domain);
+    args.flags = flags;
+
+    memset(&ret, 0, sizeof(ret));
+    if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_SCREENSHOT,
+              (xdrproc_t) xdr_remote_domain_screenshot_args, (char *) &args,
+              (xdrproc_t) xdr_remote_domain_screenshot_ret, (char *) &ret) == -1)
+        goto done;
+
+    rv = ret.mime ? *ret.mime : NULL;
+    VIR_FREE(ret.mime);
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+}
+
 static int
 remoteStorageVolUpload(virStorageVolPtr vol,
                        virStreamPtr st,
@@ -6420,7 +6458,7 @@ static virDriver remote_driver = {
     remoteDomainSave, /* domainSave */
     remoteDomainRestore, /* domainRestore */
     remoteDomainCoreDump, /* domainCoreDump */
-    NULL, /* domainScreenshot */
+    remoteDomainScreenshot, /* domainScreenshot */
     remoteDomainSetVcpus, /* domainSetVcpus */
     remoteDomainSetVcpusFlags, /* domainSetVcpusFlags */
     remoteDomainGetVcpusFlags, /* domainGetVcpusFlags */
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index c706c36..776dfe8 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -714,6 +714,15 @@ struct remote_domain_core_dump_args {
     int flags;
 };
 
+struct remote_domain_screenshot_args {
+    remote_nonnull_domain dom;
+    unsigned int flags;
+};
+
+struct remote_domain_screenshot_ret {
+    remote_string mime;
+};
+
 struct remote_domain_dump_xml_args {
     remote_nonnull_domain dom;
     int flags;
@@ -2176,7 +2185,8 @@ enum remote_procedure {
     REMOTE_PROC_DOMAIN_GET_BLKIO_PARAMETERS = 206,
     REMOTE_PROC_DOMAIN_MIGRATE_SET_MAX_SPEED = 207,
     REMOTE_PROC_STORAGE_VOL_UPLOAD = 208,
-    REMOTE_PROC_STORAGE_VOL_DOWNLOAD = 209
+    REMOTE_PROC_STORAGE_VOL_DOWNLOAD = 209,
+    REMOTE_PROC_DOMAIN_SCREENSHOT = 210
 
     /*
      * Notice how the entries are grouped in sets of 10 ?
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index f904c4d..10c6d4a 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -403,6 +403,13 @@ struct remote_domain_core_dump_args {
         remote_nonnull_string      to;
         int                        flags;
 };
+struct remote_domain_screenshot_args {
+        remote_nonnull_domain      dom;
+        unsigned int               flags;
+};
+struct remote_domain_screenshot_ret {
+        remote_string              mime;
+};
 struct remote_domain_dump_xml_args {
         remote_nonnull_domain      dom;
         int                        flags;
-- 
1.7.5.rc3

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