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

[libvirt] [PATCH 5/8] Getting Block IO Throttle support to remote driver



Add getting Block IO Throttle support to remote driver.

Signed-off-by: Zhi Yong Wu <wuzhy linux vnet ibm com>
Signed-off-by: Lei Li <lilei linux vnet ibm com>
---
 daemon/remote.c              |   43 ++++++++++++++++++++++++++++++++++++++++++
 src/remote/remote_driver.c   |   42 +++++++++++++++++++++++++++++++++++++++++
 src/remote/remote_protocol.x |   23 ++++++++++++++++++++++
 src/remote_protocol-structs  |   21 ++++++++++++++++++++
 4 files changed, 129 insertions(+), 0 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index c604556..ae8d5ed 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -1890,6 +1890,49 @@ cleanup:
     return rv;
 }
 
+static int
+remoteDispatchDomainGetBlockIoThrottle(virNetServerPtr server ATTRIBUTE_UNUSED,
+                                       virNetServerClientPtr client ATTRIBUTE_UNUSED,
+                                       virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                       virNetMessageErrorPtr rerr,
+                                       remote_domain_get_block_io_throttle_args *args,
+                                       remote_domain_get_block_io_throttle_ret *ret)
+{
+    virDomainPtr dom = NULL;
+    virDomainBlockIoThrottleInfo reply;
+    int rv = -1;
+    struct daemonClientPrivate *priv =
+        virNetServerClientGetPrivateData(client);
+
+    if (!priv->conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+        goto cleanup;
+
+    rv = virDomainGetBlockIoThrottle(dom, args->disk, &reply, args->flags);
+
+    if (rv < 0)
+        goto cleanup;
+
+    ret->bps     = reply.bps;
+    ret->bps_rd  = reply.bps_rd;
+    ret->bps_wr  = reply.bps_wr;
+    ret->iops    = reply.iops;
+    ret->iops_rd = reply.iops_rd;
+    ret->iops_wr = reply.iops_wr;
+    ret->found   = 1;
+
+cleanup:
+    if (rv < 0)
+        virNetMessageSaveError(rerr);
+    if (dom)
+        virDomainFree(dom);
+    return rv;
+}
+
 /*-------------------------------------------------------------*/
 
 static int
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index a2d78f0..3c54184 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -2187,6 +2187,47 @@ done:
     return rv;
 }
 
+static int remoteDomainGetBlockIoThrottle(virDomainPtr domain,
+                                          const char *disk,
+                                          virDomainBlockIoThrottleInfoPtr reply,
+                                          unsigned int flags)
+{
+    int rv = -1;
+    remote_domain_get_block_io_throttle_args args;
+    remote_domain_get_block_io_throttle_ret ret;
+    struct private_data *priv = domain->conn->privateData;
+
+    remoteDriverLock(priv);
+
+    make_nonnull_domain(&args.dom, domain);
+    args.disk = (char *)disk;
+    args.flags = flags;
+
+    memset(&ret, 0, sizeof(ret));
+
+    if (call(domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_BLOCK_IO_THROTTLE,
+             (xdrproc_t) xdr_remote_domain_get_block_io_throttle_args,
+               (char *) &args,
+             (xdrproc_t) xdr_remote_domain_get_block_io_throttle_ret,
+               (char *) &ret) == -1) {
+        goto done;
+    }
+
+    if (ret.found) {
+        reply->bps     = ret.bps;
+        reply->bps_rd  = ret.bps_rd;
+        reply->bps_wr  = ret.bps_wr;
+        reply->iops    = ret.iops;
+        reply->iops_rd = ret.iops_rd;
+        reply->iops_wr = ret.iops_wr;
+    }
+    rv = 0;
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+}
+
 /*----------------------------------------------------------------------*/
 
 static virDrvOpenStatus ATTRIBUTE_NONNULL (1)
@@ -4512,6 +4553,7 @@ static virDriver remote_driver = {
     .domainBlockJobSetSpeed = remoteDomainBlockJobSetSpeed, /* 0.9.4 */
     .domainBlockPull = remoteDomainBlockPull, /* 0.9.4 */
     .domainSetBlockIoThrottle = remoteDomainSetBlockIoThrottle, /* 0.9.8 */
+    .domainGetBlockIoThrottle = remoteDomainGetBlockIoThrottle, /* 0.9.8 */
 };
 
 static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index b467952..46774cc 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -1085,6 +1085,28 @@ struct remote_domain_set_block_io_throttle_args {
     unsigned int flags;
 };
 
+struct remote_domain_get_block_io_throttle_args {
+    remote_nonnull_domain dom;
+    remote_nonnull_string disk;
+    unsigned hyper bps;
+    unsigned hyper bps_rd;
+    unsigned hyper bps_wr;
+    unsigned hyper iops;
+    unsigned hyper iops_rd;
+    unsigned hyper iops_wr;
+    unsigned int flags;
+};
+
+struct remote_domain_get_block_io_throttle_ret {
+    unsigned hyper bps;
+    unsigned hyper bps_rd;
+    unsigned hyper bps_wr;
+    unsigned hyper iops;
+    unsigned hyper iops_rd;
+    unsigned hyper iops_wr;
+    unsigned int found;
+};
+
 /* Network calls: */
 
 struct remote_num_of_networks_ret {
@@ -2569,6 +2591,7 @@ enum remote_procedure {
     REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_CHILDREN_NAMES = 247, /* autogen autogen priority:high */
     REMOTE_PROC_DOMAIN_EVENT_DISK_CHANGE = 248, /* skipgen skipgen */
     REMOTE_PROC_DOMAIN_SET_BLOCK_IO_THROTTLE = 249, /* skipgen skipgen */
+    REMOTE_PROC_DOMAIN_GET_BLOCK_IO_THROTTLE = 250 /* skipgen skipgen */
 
     /*
      * Notice how the entries are grouped in sets of 10 ?
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 4f8bcf6..6aa1186 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -768,6 +768,26 @@ struct remote_domain_set_block_io_throttle_args {
         uint64_t                   iops_wr;
         u_int                      flags;
 };
+struct remote_domain_get_block_io_throttle_args {
+        remote_nonnull_domain      dom;
+        remote_nonnull_string      disk;
+        uint64_t                   bps;
+        uint64_t                   bps_rd;
+        uint64_t                   bps_wr;
+        uint64_t                   iops;
+        uint64_t                   iops_rd;
+        uint64_t                   iops_wr;
+        u_int                      flags;
+};
+struct remote_domain_get_block_io_throttle_ret {
+        uint64_t                   bps;
+        uint64_t                   bps_rd;
+        uint64_t                   bps_wr;
+        uint64_t                   iops;
+        uint64_t                   iops_rd;
+        uint64_t                   iops_wr;
+        u_int                      found;
+};
 struct remote_num_of_networks_ret {
         int                        num;
 };
@@ -2011,4 +2031,5 @@ enum remote_procedure {
         REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_CHILDREN_NAMES = 247,
         REMOTE_PROC_DOMAIN_EVENT_DISK_CHANGE = 248,
         REMOTE_PROC_DOMAIN_SET_BLOCK_IO_THROTTLE = 249,
+        REMOTE_PROC_DOMAIN_GET_BLOCK_IO_THROTTLE = 250,
 };
-- 
1.7.1


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