[PATCH 4/7] screenshot: Implementing the remote protocol

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

 



---
 daemon/remote.c                     |   26 ++++++++++++++++++++++++++
 daemon/remote_dispatch_args.h       |    1 +
 daemon/remote_dispatch_prototypes.h |    8 ++++++++
 daemon/remote_dispatch_table.h      |    5 +++++
 src/remote/remote_driver.c          |   27 ++++++++++++++++++++++++++-
 src/remote/remote_protocol.c        |   13 +++++++++++++
 src/remote/remote_protocol.h        |   10 ++++++++++
 src/remote/remote_protocol.x        |    9 ++++++++-
 src/remote_protocol-structs         |    5 +++++
 9 files changed, 102 insertions(+), 2 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 1700c2d..8797c38 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -2310,6 +2310,32 @@ remoteDispatchDomainCoreDump (struct qemud_server *server ATTRIBUTE_UNUSED,
 }
 
 static int
+remoteDispatchDomainScreenshot (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_screenshot_args *args,
+                                void *ret ATTRIBUTE_UNUSED)
+{
+    virDomainPtr dom;
+
+    dom = get_nonnull_domain (conn, args->dom);
+    if (dom == NULL) {
+        remoteDispatchConnError(rerr, conn);
+        return -1;
+    }
+
+    if (virDomainScreenshot (dom, args->to, args->flags) == -1) {
+        remoteDispatchConnError(rerr, conn);
+        virDomainFree(dom);
+        return -1;
+    }
+    virDomainFree(dom);
+    return 0;
+}
+
+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..d4844b4 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,
+    void *ret);
 static int remoteDispatchDomainSetAutostart(
     struct qemud_server *server,
     struct qemud_client *client,
diff --git a/daemon/remote_dispatch_table.h b/daemon/remote_dispatch_table.h
index b39f7c2..349006a 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_void,
+},
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index d7772d0..3b6d141 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -2929,6 +2929,31 @@ done:
 }
 
 static int
+remoteDomainScreenshot (virDomainPtr domain, const char *to, int flags)
+{
+    int rv = -1;
+    remote_domain_screenshot_args args;
+    struct private_data *priv = domain->conn->privateData;
+
+    remoteDriverLock(priv);
+
+    make_nonnull_domain (&args.dom, domain);
+    args.to = (char *) to;
+    args.flags = flags;
+
+    if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_SCREENSHOT,
+              (xdrproc_t) xdr_remote_domain_screenshot_args, (char *) &args,
+              (xdrproc_t) xdr_void, (char *) NULL) == -1)
+        goto done;
+
+    rv = 0;
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+}
+
+static int
 remoteDomainSetVcpus (virDomainPtr domain, unsigned int nvcpus)
 {
     int rv = -1;
@@ -11223,7 +11248,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..00b51a0 100644
--- a/src/remote/remote_protocol.c
+++ b/src/remote/remote_protocol.c
@@ -1230,6 +1230,19 @@ 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_remote_nonnull_string (xdrs, &objp->to))
+                 return FALSE;
+         if (!xdr_int (xdrs, &objp->flags))
+                 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..826853c 100644
--- a/src/remote/remote_protocol.h
+++ b/src/remote/remote_protocol.h
@@ -666,6 +666,13 @@ 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;
+        remote_nonnull_string to;
+        int flags;
+};
+typedef struct remote_domain_screenshot_args remote_domain_screenshot_args;
+
 struct remote_domain_dump_xml_args {
         remote_nonnull_domain dom;
         int flags;
@@ -2413,6 +2420,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 +2549,7 @@ 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_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 +2907,7 @@ 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_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..090e959 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -714,6 +714,12 @@ struct remote_domain_core_dump_args {
     int flags;
 };
 
+struct remote_domain_screenshot_args {
+    remote_nonnull_domain dom;
+    remote_nonnull_string to;
+    int flags;
+};
+
 struct remote_domain_dump_xml_args {
     remote_nonnull_domain dom;
     int flags;
@@ -2176,7 +2182,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 944553c..9adc695 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -403,6 +403,11 @@ struct remote_domain_core_dump_args {
         remote_nonnull_string      to;
         int                        flags;
 };
+struct remote_domain_screenshot_args {
+        remote_nonnull_domain      dom;
+        remote_nonnull_string      to;
+        int                        flags;
+};
 struct remote_domain_dump_xml_args {
         remote_nonnull_domain      dom;
         int                        flags;
-- 
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]