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

[libvirt] [PATCH 2/8] Add Block IO Throttle support setting to the remote driver



Support Block IO Throttle setting 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              |   42 ++++++++++++++++++++++++++++++++++++++++++
 src/remote/remote_driver.c   |   38 ++++++++++++++++++++++++++++++++++++++
 src/remote/remote_protocol.x |   15 ++++++++++++++-
 src/remote_protocol-structs  |   12 ++++++++++++
 4 files changed, 106 insertions(+), 1 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 9d70163..c604556 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -1847,6 +1847,48 @@ cleanup:
     return rv;
 }
 
+static int
+remoteDispatchDomainSetBlockIoThrottle(virNetServerPtr server ATTRIBUTE_UNUSED,
+                                       virNetServerClientPtr client ATTRIBUTE_UNUSED,
+                                       virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
+                                       virNetMessageErrorPtr rerr,
+                                       remote_domain_set_block_io_throttle_args *args)
+{
+    virDomainPtr dom = NULL;
+    virDomainBlockIoThrottleInfo tmp;
+    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;
+
+    if (args) {
+        tmp.bps     = args->bps;
+        tmp.bps_rd  = args->bps_rd;
+        tmp.bps_wr  = args->bps_wr;
+        tmp.iops    = args->iops;
+        tmp.iops_rd = args->iops_rd;
+        tmp.iops_wr = args->iops_wr;
+    }
+
+    rv = virDomainSetBlockIoThrottle(dom, args->disk, &tmp, args->flags);
+
+    if (rv < 0)
+        goto cleanup;
+
+cleanup:
+    if (rv < 0)
+        virNetMessageSaveError(rerr);
+    if (dom)
+        virDomainFree(dom);
+    return rv;
+}
 
 /*-------------------------------------------------------------*/
 
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index e98ebd7..a2d78f0 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -2150,6 +2150,43 @@ done:
     return rv;
 }
 
+static int remoteDomainSetBlockIoThrottle(virDomainPtr domain,
+                                          const char *disk,
+                                          virDomainBlockIoThrottleInfoPtr info,
+                                          unsigned int flags)
+{
+    int rv = -1;
+    remote_domain_set_block_io_throttle_args args;
+    struct private_data *priv = domain->conn->privateData;
+
+    remoteDriverLock(priv);
+
+    memset(&args, 0, sizeof(args));
+
+    make_nonnull_domain(&args.dom, domain);
+    args.disk = (char *)disk;
+    args.bps = info->bps;
+    args.bps_rd = info->bps_rd;
+    args.bps_wr = info->bps_wr;
+    args.iops = info->iops;
+    args.iops_rd = info->iops_rd;
+    args.iops_wr = info->iops_wr;
+    args.flags = flags;
+
+    if (call(domain->conn, priv, 0, REMOTE_PROC_DOMAIN_SET_BLOCK_IO_THROTTLE,
+             (xdrproc_t) xdr_remote_domain_set_block_io_throttle_args,
+               (char *) &args,
+             (xdrproc_t) xdr_void,
+               (char *) NULL) == -1) {
+        goto done;
+    }
+    rv = 0;
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+}
+
 /*----------------------------------------------------------------------*/
 
 static virDrvOpenStatus ATTRIBUTE_NONNULL (1)
@@ -4474,6 +4511,7 @@ static virDriver remote_driver = {
     .domainGetBlockJobInfo = remoteDomainGetBlockJobInfo, /* 0.9.4 */
     .domainBlockJobSetSpeed = remoteDomainBlockJobSetSpeed, /* 0.9.4 */
     .domainBlockPull = remoteDomainBlockPull, /* 0.9.4 */
+    .domainSetBlockIoThrottle = remoteDomainSetBlockIoThrottle, /* 0.9.8 */
 };
 
 static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index d135653..b467952 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -1073,6 +1073,18 @@ struct remote_domain_block_pull_args {
     unsigned int flags;
 };
 
+struct remote_domain_set_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;
+};
+
 /* Network calls: */
 
 struct remote_num_of_networks_ret {
@@ -2555,7 +2567,8 @@ enum remote_procedure {
     REMOTE_PROC_DOMAIN_RESET = 245, /* autogen autogen */
     REMOTE_PROC_DOMAIN_SNAPSHOT_NUM_CHILDREN = 246, /* autogen autogen priority:high */
     REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_CHILDREN_NAMES = 247, /* autogen autogen priority:high */
-    REMOTE_PROC_DOMAIN_EVENT_DISK_CHANGE = 248 /* skipgen skipgen */
+    REMOTE_PROC_DOMAIN_EVENT_DISK_CHANGE = 248, /* skipgen skipgen */
+    REMOTE_PROC_DOMAIN_SET_BLOCK_IO_THROTTLE = 249, /* 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 569fcb3..4f8bcf6 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -757,6 +757,17 @@ struct remote_domain_block_pull_args {
         uint64_t                   bandwidth;
         u_int                      flags;
 };
+struct remote_domain_set_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_num_of_networks_ret {
         int                        num;
 };
@@ -1999,4 +2010,5 @@ enum remote_procedure {
         REMOTE_PROC_DOMAIN_SNAPSHOT_NUM_CHILDREN = 246,
         REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_CHILDREN_NAMES = 247,
         REMOTE_PROC_DOMAIN_EVENT_DISK_CHANGE = 248,
+        REMOTE_PROC_DOMAIN_SET_BLOCK_IO_THROTTLE = 249,
 };
-- 
1.7.1


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