[libvirt] [PATCH 3/9] Remote driver implmentation of job info API

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

 



* src/remote/remote_protocol.x: Define wire protocol format
  for virDomainGetJobInfo API
* src/remote/remote_driver.c, daemon/remote.c: Implement client
  and server marshalling code for virDomainGetJobInfo()
* 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: Rebuild
  files from src/remote/remote_protocol.x
---
 daemon/remote.c                     |   44 +++++++++++++++++++++++++++++++++++
 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          |   43 +++++++++++++++++++++++++++++++++-
 src/remote/remote_protocol.c        |   42 +++++++++++++++++++++++++++++++++
 src/remote/remote_protocol.h        |   27 +++++++++++++++++++++
 src/remote/remote_protocol.x        |   27 ++++++++++++++++++++-
 9 files changed, 196 insertions(+), 2 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 299f971..e434591 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -5312,6 +5312,50 @@ remoteDispatchCpuCompare(struct qemud_server *server ATTRIBUTE_UNUSED,
 }
 
 
+static int
+remoteDispatchDomainGetJobInfo (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_get_job_info_args *args,
+                                remote_domain_get_job_info_ret *ret)
+{
+    virDomainPtr dom;
+    virDomainJobInfo info;
+
+    dom = get_nonnull_domain (conn, args->dom);
+    if (dom == NULL) {
+        remoteDispatchConnError(rerr, conn);
+        return -1;
+    }
+
+    if (virDomainGetJobInfo (dom, &info) == -1) {
+        virDomainFree(dom);
+        remoteDispatchConnError(rerr, conn);
+        return -1;
+    }
+
+    ret->type = info.type;
+    ret->percentComplete = info.percentComplete;
+    ret->timeElapsed = info.timeElapsed;
+    ret->timeRemaining = info.timeRemaining;
+    ret->dataTotal = info.dataTotal;
+    ret->dataProcessed = info.dataProcessed;
+    ret->dataRemaining = info.dataRemaining;
+    ret->memTotal = info.memTotal;
+    ret->memProcessed = info.memProcessed;
+    ret->memRemaining = info.memRemaining;
+    ret->fileTotal = info.fileTotal;
+    ret->fileProcessed = info.fileProcessed;
+    ret->fileRemaining = info.fileRemaining;
+
+    virDomainFree(dom);
+
+    return 0;
+}
+
+
 /*----- Helpers. -----*/
 
 /* get_nonnull_domain and get_nonnull_network turn an on-wire
diff --git a/daemon/remote_dispatch_args.h b/daemon/remote_dispatch_args.h
index c1801d0..b66af1c 100644
--- a/daemon/remote_dispatch_args.h
+++ b/daemon/remote_dispatch_args.h
@@ -135,3 +135,4 @@
     remote_interface_is_active_args val_remote_interface_is_active_args;
     remote_cpu_compare_args val_remote_cpu_compare_args;
     remote_domain_memory_stats_args val_remote_domain_memory_stats_args;
+    remote_domain_get_job_info_args val_remote_domain_get_job_info_args;
diff --git a/daemon/remote_dispatch_prototypes.h b/daemon/remote_dispatch_prototypes.h
index 1a0f8d8..b520f7d 100644
--- a/daemon/remote_dispatch_prototypes.h
+++ b/daemon/remote_dispatch_prototypes.h
@@ -170,6 +170,14 @@ static int remoteDispatchDomainGetInfo(
     remote_error *err,
     remote_domain_get_info_args *args,
     remote_domain_get_info_ret *ret);
+static int remoteDispatchDomainGetJobInfo(
+    struct qemud_server *server,
+    struct qemud_client *client,
+    virConnectPtr conn,
+    remote_message_header *hdr,
+    remote_error *err,
+    remote_domain_get_job_info_args *args,
+    remote_domain_get_job_info_ret *ret);
 static int remoteDispatchDomainGetMaxMemory(
     struct qemud_server *server,
     struct qemud_client *client,
diff --git a/daemon/remote_dispatch_ret.h b/daemon/remote_dispatch_ret.h
index d7811de..02a1734 100644
--- a/daemon/remote_dispatch_ret.h
+++ b/daemon/remote_dispatch_ret.h
@@ -117,3 +117,4 @@
     remote_get_lib_version_ret val_remote_get_lib_version_ret;
     remote_cpu_compare_ret val_remote_cpu_compare_ret;
     remote_domain_memory_stats_ret val_remote_domain_memory_stats_ret;
+    remote_domain_get_job_info_ret val_remote_domain_get_job_info_ret;
diff --git a/daemon/remote_dispatch_table.h b/daemon/remote_dispatch_table.h
index 09ebeee..18acba8 100644
--- a/daemon/remote_dispatch_table.h
+++ b/daemon/remote_dispatch_table.h
@@ -802,3 +802,8 @@
     .args_filter = (xdrproc_t) xdr_remote_domain_memory_stats_args,
     .ret_filter = (xdrproc_t) xdr_remote_domain_memory_stats_ret,
 },
+{   /* DomainGetJobInfo => 160 */
+    .fn = (dispatch_fn) remoteDispatchDomainGetJobInfo,
+    .args_filter = (xdrproc_t) xdr_remote_domain_get_job_info_args,
+    .ret_filter = (xdrproc_t) xdr_remote_domain_get_job_info_ret,
+},
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 692c83c..f45bcae 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -7535,6 +7535,47 @@ done:
     return rv;
 }
 
+
+static int
+remoteDomainGetJobInfo (virDomainPtr domain, virDomainJobInfoPtr info)
+{
+    int rv = -1;
+    remote_domain_get_job_info_args args;
+    remote_domain_get_job_info_ret ret;
+    struct private_data *priv = domain->conn->privateData;
+
+    remoteDriverLock(priv);
+
+    make_nonnull_domain (&args.dom, domain);
+
+    memset (&ret, 0, sizeof ret);
+    if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_JOB_INFO,
+              (xdrproc_t) xdr_remote_domain_get_job_info_args, (char *) &args,
+              (xdrproc_t) xdr_remote_domain_get_job_info_ret, (char *) &ret) == -1)
+        goto done;
+
+    info->type = ret.type;
+    info->percentComplete = ret.percentComplete;
+    info->timeElapsed = ret.timeElapsed;
+    info->timeRemaining = ret.timeRemaining;
+    info->dataTotal = ret.dataTotal;
+    info->dataProcessed = ret.dataProcessed;
+    info->dataRemaining = ret.dataRemaining;
+    info->memTotal = ret.memTotal;
+    info->memProcessed = ret.memProcessed;
+    info->memRemaining = ret.memRemaining;
+    info->fileTotal = ret.fileTotal;
+    info->fileProcessed = ret.fileProcessed;
+    info->fileRemaining = ret.fileRemaining;
+
+    rv = 0;
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+}
+
+
 /*----------------------------------------------------------------------*/
 
 
@@ -8923,7 +8964,7 @@ static virDriver remote_driver = {
     remoteDomainIsActive, /* domainIsActive */
     remoteDomainIsPersistent, /* domainIsPersistent */
     remoteCPUCompare, /* cpuCompare */
-    NULL, /* domainGetJobInfo */
+    remoteDomainGetJobInfo, /* domainGetJobInfo */
 };
 
 static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.c b/src/remote/remote_protocol.c
index 834eb6b..662170d 100644
--- a/src/remote/remote_protocol.c
+++ b/src/remote/remote_protocol.c
@@ -2912,6 +2912,48 @@ xdr_remote_cpu_compare_ret (XDR *xdrs, remote_cpu_compare_ret *objp)
 }
 
 bool_t
+xdr_remote_domain_get_job_info_args (XDR *xdrs, remote_domain_get_job_info_args *objp)
+{
+
+         if (!xdr_remote_nonnull_domain (xdrs, &objp->dom))
+                 return FALSE;
+        return TRUE;
+}
+
+bool_t
+xdr_remote_domain_get_job_info_ret (XDR *xdrs, remote_domain_get_job_info_ret *objp)
+{
+
+         if (!xdr_int (xdrs, &objp->type))
+                 return FALSE;
+         if (!xdr_int (xdrs, &objp->percentComplete))
+                 return FALSE;
+         if (!xdr_uint64_t (xdrs, &objp->timeElapsed))
+                 return FALSE;
+         if (!xdr_uint64_t (xdrs, &objp->timeRemaining))
+                 return FALSE;
+         if (!xdr_uint64_t (xdrs, &objp->dataTotal))
+                 return FALSE;
+         if (!xdr_uint64_t (xdrs, &objp->dataProcessed))
+                 return FALSE;
+         if (!xdr_uint64_t (xdrs, &objp->dataRemaining))
+                 return FALSE;
+         if (!xdr_uint64_t (xdrs, &objp->memTotal))
+                 return FALSE;
+         if (!xdr_uint64_t (xdrs, &objp->memProcessed))
+                 return FALSE;
+         if (!xdr_uint64_t (xdrs, &objp->memRemaining))
+                 return FALSE;
+         if (!xdr_uint64_t (xdrs, &objp->fileTotal))
+                 return FALSE;
+         if (!xdr_uint64_t (xdrs, &objp->fileProcessed))
+                 return FALSE;
+         if (!xdr_uint64_t (xdrs, &objp->fileRemaining))
+                 return FALSE;
+        return TRUE;
+}
+
+bool_t
 xdr_remote_procedure (XDR *xdrs, remote_procedure *objp)
 {
 
diff --git a/src/remote/remote_protocol.h b/src/remote/remote_protocol.h
index 3f3b520..47ff223 100644
--- a/src/remote/remote_protocol.h
+++ b/src/remote/remote_protocol.h
@@ -1649,6 +1649,28 @@ struct remote_cpu_compare_ret {
         int result;
 };
 typedef struct remote_cpu_compare_ret remote_cpu_compare_ret;
+
+struct remote_domain_get_job_info_args {
+        remote_nonnull_domain dom;
+};
+typedef struct remote_domain_get_job_info_args remote_domain_get_job_info_args;
+
+struct remote_domain_get_job_info_ret {
+        int type;
+        int percentComplete;
+        uint64_t timeElapsed;
+        uint64_t timeRemaining;
+        uint64_t dataTotal;
+        uint64_t dataProcessed;
+        uint64_t dataRemaining;
+        uint64_t memTotal;
+        uint64_t memProcessed;
+        uint64_t memRemaining;
+        uint64_t fileTotal;
+        uint64_t fileProcessed;
+        uint64_t fileRemaining;
+};
+typedef struct remote_domain_get_job_info_ret remote_domain_get_job_info_ret;
 #define REMOTE_PROGRAM 0x20008086
 #define REMOTE_PROTOCOL_VERSION 1
 
@@ -1812,6 +1834,7 @@ enum remote_procedure {
         REMOTE_PROC_GET_LIB_VERSION = 157,
         REMOTE_PROC_CPU_COMPARE = 158,
         REMOTE_PROC_DOMAIN_MEMORY_STATS = 159,
+        REMOTE_PROC_DOMAIN_GET_JOB_INFO = 160,
 };
 typedef enum remote_procedure remote_procedure;
 
@@ -2114,6 +2137,8 @@ extern  bool_t xdr_remote_interface_is_active_args (XDR *, remote_interface_is_a
 extern  bool_t xdr_remote_interface_is_active_ret (XDR *, remote_interface_is_active_ret*);
 extern  bool_t xdr_remote_cpu_compare_args (XDR *, remote_cpu_compare_args*);
 extern  bool_t xdr_remote_cpu_compare_ret (XDR *, remote_cpu_compare_ret*);
+extern  bool_t xdr_remote_domain_get_job_info_args (XDR *, remote_domain_get_job_info_args*);
+extern  bool_t xdr_remote_domain_get_job_info_ret (XDR *, remote_domain_get_job_info_ret*);
 extern  bool_t xdr_remote_procedure (XDR *, remote_procedure*);
 extern  bool_t xdr_remote_message_type (XDR *, remote_message_type*);
 extern  bool_t xdr_remote_message_status (XDR *, remote_message_status*);
@@ -2390,6 +2415,8 @@ extern bool_t xdr_remote_interface_is_active_args ();
 extern bool_t xdr_remote_interface_is_active_ret ();
 extern bool_t xdr_remote_cpu_compare_args ();
 extern bool_t xdr_remote_cpu_compare_ret ();
+extern bool_t xdr_remote_domain_get_job_info_args ();
+extern bool_t xdr_remote_domain_get_job_info_ret ();
 extern bool_t xdr_remote_procedure ();
 extern bool_t xdr_remote_message_type ();
 extern bool_t xdr_remote_message_status ();
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index bed3940..9b37bb4 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -1461,6 +1461,30 @@ struct remote_cpu_compare_ret {
 };
 
 
+struct remote_domain_get_job_info_args {
+    remote_nonnull_domain dom;
+};
+
+struct remote_domain_get_job_info_ret {
+    int type;
+    int percentComplete;
+
+    unsigned hyper timeElapsed;
+    unsigned hyper timeRemaining;
+
+    unsigned hyper dataTotal;
+    unsigned hyper dataProcessed;
+    unsigned hyper dataRemaining;
+
+    unsigned hyper memTotal;
+    unsigned hyper memProcessed;
+    unsigned hyper memRemaining;
+
+    unsigned hyper fileTotal;
+    unsigned hyper fileProcessed;
+    unsigned hyper fileRemaining;
+};
+
 /*----- Protocol. -----*/
 
 /* Define the program number, protocol version and procedure numbers here. */
@@ -1641,7 +1665,8 @@ enum remote_procedure {
     REMOTE_PROC_INTERFACE_IS_ACTIVE = 156,
     REMOTE_PROC_GET_LIB_VERSION = 157,
     REMOTE_PROC_CPU_COMPARE = 158,
-    REMOTE_PROC_DOMAIN_MEMORY_STATS = 159
+    REMOTE_PROC_DOMAIN_MEMORY_STATS = 159,
+    REMOTE_PROC_DOMAIN_GET_JOB_INFO = 160
 
     /*
      * Notice how the entries are grouped in sets of 10 ?
-- 
1.6.6

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