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

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

 



* daemon/remote.c, src/remote/remote_driver.c: Implementation
  of screenshot API
* src/remote/remote_protocol.x: Wire protocol definition
* daemon/remote_dispatch_args.h, daemon/remote_dispatch_prototypes.h,
  daemon/remote_dispatch_ret.h, daemon/remote_dispatch_table.h,
  src/remote/remote_protocol.c, src/remote/remote_protocol.h:
  Re-generate
---
 daemon/remote.c                     |   61 +++++++++++++++++++++++++++++++++++
 daemon/remote_dispatch_args.h       |    1 +
 daemon/remote_dispatch_prototypes.h |    8 ++++
 daemon/remote_dispatch_ret.h        |    1 +
 daemon/remote_dispatch_table.h      |    5 +++
 src/remote/remote_driver.c          |   39 +++++++++++++++++++++-
 src/remote/remote_protocol.c        |   20 +++++++++++
 src/remote/remote_protocol.h        |   16 +++++++++
 src/remote/remote_protocol.x        |   12 ++++++-
 9 files changed, 161 insertions(+), 2 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index dd85ef1..c289e52 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -2318,6 +2318,67 @@ remoteDispatchDomainCoreDump (struct qemud_server *server ATTRIBUTE_UNUSED,
 }
 
 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) {
+        remoteDispatchConnError(rerr, conn);
+        goto cleanup;
+    }
+
+    stream = remoteCreateClientStream(conn, hdr);
+    if (!stream) {
+        remoteDispatchConnError(rerr, conn);
+        goto cleanup;
+    }
+
+    mime = virDomainScreenshot(dom, stream->st, args->flags);
+    if (mime == NULL) {
+        remoteDispatchConnError(rerr, conn);
+        goto cleanup;
+    }
+
+    if (remoteAddClientStream(client, stream, 1) < 0) {
+        remoteDispatchConnError(rerr, conn);
+        virStreamAbort(stream->st);
+        goto cleanup;
+    }
+
+    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;
+
+cleanup:
+    virDomainFree(dom);
+    if (stream && rv != 0)
+        remoteFreeClientStream(client, stream);
+    return rv;
+}
+
+static int
 remoteDispatchDomainSetAutostart (struct qemud_server *server ATTRIBUTE_UNUSED,
                                   struct qemud_client *client ATTRIBUTE_UNUSED,
                                   virConnectPtr conn,
diff --git a/daemon/remote_dispatch_args.h b/daemon/remote_dispatch_args.h
index f9537d7..2be8003 100644
--- a/daemon/remote_dispatch_args.h
+++ b/daemon/remote_dispatch_args.h
@@ -178,3 +178,4 @@
     remote_domain_migrate_set_max_speed_args val_remote_domain_migrate_set_max_speed_args;
     remote_storage_vol_upload_args val_remote_storage_vol_upload_args;
     remote_storage_vol_download_args val_remote_storage_vol_download_args;
+    remote_domain_screenshot_args val_remote_domain_screenshot_args;
diff --git a/daemon/remote_dispatch_prototypes.h b/daemon/remote_dispatch_prototypes.h
index 18bf41d..582a8dd 100644
--- a/daemon/remote_dispatch_prototypes.h
+++ b/daemon/remote_dispatch_prototypes.h
@@ -546,6 +546,14 @@ static int remoteDispatchDomainSave(
     remote_error *err,
     remote_domain_save_args *args,
     void *ret);
+static int remoteDispatchDomainScreenshot(
+    struct qemud_server *server,
+    struct qemud_client *client,
+    virConnectPtr conn,
+    remote_message_header *hdr,
+    remote_error *err,
+    remote_domain_screenshot_args *args,
+    remote_domain_screenshot_ret *ret);
 static int remoteDispatchDomainSetAutostart(
     struct qemud_server *server,
     struct qemud_client *client,
diff --git a/daemon/remote_dispatch_ret.h b/daemon/remote_dispatch_ret.h
index 114e832..1ecb8a9 100644
--- a/daemon/remote_dispatch_ret.h
+++ b/daemon/remote_dispatch_ret.h
@@ -140,3 +140,4 @@
     remote_domain_is_updated_ret val_remote_domain_is_updated_ret;
     remote_get_sysinfo_ret val_remote_get_sysinfo_ret;
     remote_domain_get_blkio_parameters_ret val_remote_domain_get_blkio_parameters_ret;
+    remote_domain_screenshot_ret val_remote_domain_screenshot_ret;
diff --git a/daemon/remote_dispatch_table.h b/daemon/remote_dispatch_table.h
index b39f7c2..b058db3 100644
--- a/daemon/remote_dispatch_table.h
+++ b/daemon/remote_dispatch_table.h
@@ -1052,3 +1052,8 @@
     .args_filter = (xdrproc_t) xdr_remote_storage_vol_download_args,
     .ret_filter = (xdrproc_t) xdr_void,
 },
+{   /* DomainScreenshot => 210 */
+    .fn = (dispatch_fn) remoteDispatchDomainScreenshot,
+    .args_filter = (xdrproc_t) xdr_remote_domain_screenshot_args,
+    .ret_filter = (xdrproc_t) xdr_remote_domain_screenshot_ret,
+},
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index f5b7c55..91a7651 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -11057,6 +11057,43 @@ remoteDomainEventQueueFlush(int timer ATTRIBUTE_UNUSED, void *opaque)
     remoteDriverUnlock(priv);
 }
 
+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;
+}
 
 /* get_nonnull_domain and get_nonnull_network turn an on-wire
  * (name, uuid) pair into virDomainPtr or virNetworkPtr object.
@@ -11227,7 +11264,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.c b/src/remote/remote_protocol.c
index 5604371..a4deb67 100644
--- a/src/remote/remote_protocol.c
+++ b/src/remote/remote_protocol.c
@@ -1230,6 +1230,26 @@ xdr_remote_domain_core_dump_args (XDR *xdrs, remote_domain_core_dump_args *objp)
 }
 
 bool_t
+xdr_remote_domain_screenshot_args (XDR *xdrs, remote_domain_screenshot_args *objp)
+{
+
+         if (!xdr_remote_nonnull_domain (xdrs, &objp->dom))
+                 return FALSE;
+         if (!xdr_u_int (xdrs, &objp->flags))
+                 return FALSE;
+        return TRUE;
+}
+
+bool_t
+xdr_remote_domain_screenshot_ret (XDR *xdrs, remote_domain_screenshot_ret *objp)
+{
+
+         if (!xdr_remote_string (xdrs, &objp->mime))
+                 return FALSE;
+        return TRUE;
+}
+
+bool_t
 xdr_remote_domain_dump_xml_args (XDR *xdrs, remote_domain_dump_xml_args *objp)
 {
 
diff --git a/src/remote/remote_protocol.h b/src/remote/remote_protocol.h
index d9bf151..d1b02d6 100644
--- a/src/remote/remote_protocol.h
+++ b/src/remote/remote_protocol.h
@@ -666,6 +666,17 @@ struct remote_domain_core_dump_args {
 };
 typedef struct remote_domain_core_dump_args remote_domain_core_dump_args;
 
+struct remote_domain_screenshot_args {
+        remote_nonnull_domain dom;
+        u_int flags;
+};
+typedef struct remote_domain_screenshot_args remote_domain_screenshot_args;
+
+struct remote_domain_screenshot_ret {
+        remote_string mime;
+};
+typedef struct remote_domain_screenshot_ret remote_domain_screenshot_ret;
+
 struct remote_domain_dump_xml_args {
         remote_nonnull_domain dom;
         int flags;
@@ -2413,6 +2424,7 @@ 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_SCREENSHOT = 210,
 };
 typedef enum remote_procedure remote_procedure;
 
@@ -2541,6 +2553,8 @@ extern  bool_t xdr_remote_domain_get_info_ret (XDR *, remote_domain_get_info_ret
 extern  bool_t xdr_remote_domain_save_args (XDR *, remote_domain_save_args*);
 extern  bool_t xdr_remote_domain_restore_args (XDR *, remote_domain_restore_args*);
 extern  bool_t xdr_remote_domain_core_dump_args (XDR *, remote_domain_core_dump_args*);
+extern  bool_t xdr_remote_domain_screenshot_args (XDR *, remote_domain_screenshot_args*);
+extern  bool_t xdr_remote_domain_screenshot_ret (XDR *, remote_domain_screenshot_ret*);
 extern  bool_t xdr_remote_domain_dump_xml_args (XDR *, remote_domain_dump_xml_args*);
 extern  bool_t xdr_remote_domain_dump_xml_ret (XDR *, remote_domain_dump_xml_ret*);
 extern  bool_t xdr_remote_domain_migrate_prepare_args (XDR *, remote_domain_migrate_prepare_args*);
@@ -2898,6 +2912,8 @@ extern bool_t xdr_remote_domain_get_info_ret ();
 extern bool_t xdr_remote_domain_save_args ();
 extern bool_t xdr_remote_domain_restore_args ();
 extern bool_t xdr_remote_domain_core_dump_args ();
+extern bool_t xdr_remote_domain_screenshot_args ();
+extern bool_t xdr_remote_domain_screenshot_ret ();
 extern bool_t xdr_remote_domain_dump_xml_args ();
 extern bool_t xdr_remote_domain_dump_xml_ret ();
 extern bool_t xdr_remote_domain_migrate_prepare_args ();
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 675eccd..6e5d09a 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 ?
-- 
1.7.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]