[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          |   42 ++++++++++++++++++++++++++++++++-
 src/remote/remote_protocol.c        |   40 +++++++++++++++++++++++++++++++
 src/remote/remote_protocol.h        |   26 ++++++++++++++++++++
 src/remote/remote_protocol.x        |   27 ++++++++++++++++++++-
 9 files changed, 192 insertions(+), 2 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index eacc6f9..67d663e 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -5386,6 +5386,50 @@ remoteDispatchCpuBaseline(struct qemud_server *server ATTRIBUTE_UNUSED,
     }
 
     ret->cpu = cpu;
+
+    return 0;
+}
+
+
+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->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;
 }
 
diff --git a/daemon/remote_dispatch_args.h b/daemon/remote_dispatch_args.h
index 86a881e..3a40542 100644
--- a/daemon/remote_dispatch_args.h
+++ b/daemon/remote_dispatch_args.h
@@ -138,3 +138,4 @@
     remote_domain_attach_device_flags_args val_remote_domain_attach_device_flags_args;
     remote_domain_detach_device_flags_args val_remote_domain_detach_device_flags_args;
     remote_cpu_baseline_args val_remote_cpu_baseline_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 be67f9a..4b8992e 100644
--- a/daemon/remote_dispatch_prototypes.h
+++ b/daemon/remote_dispatch_prototypes.h
@@ -194,6 +194,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 5c6a78f..aa74480 100644
--- a/daemon/remote_dispatch_ret.h
+++ b/daemon/remote_dispatch_ret.h
@@ -118,3 +118,4 @@
     remote_cpu_compare_ret val_remote_cpu_compare_ret;
     remote_domain_memory_stats_ret val_remote_domain_memory_stats_ret;
     remote_cpu_baseline_ret val_remote_cpu_baseline_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 428057a..a1b34d4 100644
--- a/daemon/remote_dispatch_table.h
+++ b/daemon/remote_dispatch_table.h
@@ -817,3 +817,8 @@
     .args_filter = (xdrproc_t) xdr_remote_cpu_baseline_args,
     .ret_filter = (xdrproc_t) xdr_remote_cpu_baseline_ret,
 },
+{   /* DomainGetJobInfo => 163 */
+    .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 81016fc..82a6990 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -7621,6 +7621,46 @@ done:
     return cpu;
 }
 
+
+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->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;
+}
+
+
 /*----------------------------------------------------------------------*/
 
 
@@ -9012,7 +9052,7 @@ static virDriver remote_driver = {
     remoteDomainIsPersistent, /* domainIsPersistent */
     remoteCPUCompare, /* cpuCompare */
     remoteCPUBaseline, /* cpuBaseline */
-    NULL, /* domainGetJobInfo */
+    remoteDomainGetJobInfo, /* domainGetJobInfo */
 };
 
 static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.c b/src/remote/remote_protocol.c
index 164eca5..a1f33cc 100644
--- a/src/remote/remote_protocol.c
+++ b/src/remote/remote_protocol.c
@@ -2960,6 +2960,46 @@ xdr_remote_cpu_baseline_ret (XDR *xdrs, remote_cpu_baseline_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_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 0344077..be2df93 100644
--- a/src/remote/remote_protocol.h
+++ b/src/remote/remote_protocol.h
@@ -1678,6 +1678,27 @@ struct remote_cpu_baseline_ret {
         remote_nonnull_string cpu;
 };
 typedef struct remote_cpu_baseline_ret remote_cpu_baseline_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;
+        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
 
@@ -1844,6 +1865,7 @@ enum remote_procedure {
         REMOTE_PROC_DOMAIN_ATTACH_DEVICE_FLAGS = 160,
         REMOTE_PROC_DOMAIN_DETACH_DEVICE_FLAGS = 161,
         REMOTE_PROC_CPU_BASELINE = 162,
+        REMOTE_PROC_DOMAIN_GET_JOB_INFO = 163,
 };
 typedef enum remote_procedure remote_procedure;
 
@@ -2150,6 +2172,8 @@ 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_cpu_baseline_args (XDR *, remote_cpu_baseline_args*);
 extern  bool_t xdr_remote_cpu_baseline_ret (XDR *, remote_cpu_baseline_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*);
@@ -2430,6 +2454,8 @@ extern bool_t xdr_remote_cpu_compare_args ();
 extern bool_t xdr_remote_cpu_compare_ret ();
 extern bool_t xdr_remote_cpu_baseline_args ();
 extern bool_t xdr_remote_cpu_baseline_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 432359d..e54c739 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -1488,6 +1488,30 @@ struct remote_cpu_baseline_ret {
 };
 
 
+struct remote_domain_get_job_info_args {
+    remote_nonnull_domain dom;
+};
+
+struct remote_domain_get_job_info_ret {
+    int type;
+
+    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. */
@@ -1672,7 +1696,8 @@ enum remote_procedure {
     REMOTE_PROC_DOMAIN_ATTACH_DEVICE_FLAGS = 160,
 
     REMOTE_PROC_DOMAIN_DETACH_DEVICE_FLAGS = 161,
-    REMOTE_PROC_CPU_BASELINE = 162
+    REMOTE_PROC_CPU_BASELINE = 162,
+    REMOTE_PROC_DOMAIN_GET_JOB_INFO = 163
 
     /*
      * 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]