Skip to contentSkip to conversation

fsdev: qmp interface for io throttling

PATCH Superseded Pradeep Jagadeesh 1 participant 7 messages Sep 22, 2017 Kbuild

v12 of 13 Superseded Latest is v13 →

lore
Share & tools
lore
#0 lore raw

v12 cover fsdev: qmp interface for io throttling

These patches provide the qmp interface, to query the io throttle status of the all fsdev devices that are present in a vm. also, it provides an interface to set the io throttle parameters of a fsdev to a required value. Some of the patches also remove the duplicate code that was present in block and fsdev files.

Pradeep Jagadeesh (6):
throttle: factor out duplicate code
qmp: Use ThrottleLimits structure
qmp: factor out throttle code to reuse code
hmp: create a throttle initialization function for code reuse
fsdev: QMP interface for throttling
fsdev: hmp interface for throttling

 Makefile                        |   3 +-
 blockdev.c                      |  97 ++-------------------------
 fsdev/qemu-fsdev-dummy.c        |  11 +++
 fsdev/qemu-fsdev-throttle.c     | 144 ++++++++++++++++++++++++++--------------
 fsdev/qemu-fsdev-throttle.h     |   9 ++-
 fsdev/qemu-fsdev.c              |  30 +++++++++
 hmp-commands-info.hx            |  18 +++++
 hmp-commands.hx                 |  19 ++++++
 hmp.c                           |  81 ++++++++++++++++++++--
 hmp.h                           |   4 ++
 include/qemu/throttle-options.h |   3 +
 include/qemu/throttle.h         |   4 +-
 include/qemu/typedefs.h         |   1 +
 monitor.c                       |   5 ++
 qapi-schema.json                |   4 ++
 qapi/block-core.json            |  75 +--------------------
 qapi/fsdev.json                 |  94 ++++++++++++++++++++++++++
 qmp.c                           |  14 ++++
 util/throttle.c                 |  52 +++++++++++++++
 19 files changed, 444 insertions(+), 224 deletions(-)
 create mode 100644 qapi/fsdev.json

v0 -> v1:
Addressed comments from Eric Blake, Greg Kurz and Daniel P.Berrange Mainly renaming the functions and removing the redundant code.

v1 -> v2:
Addressed comments from Eric Blake and Greg Kurz.
As per the suggestion I split the patches into smaller patches. Removed some more duplicate code.

v2 -> v3:
Addresssed comments from Alberto Garcia.
Changed the comment from block to iothrottle in the iothrottle.json Added the dummy functions in qemu-fsdev-dummy.c to address the compilation issues that were observed.

v3 -> v4:
Addressed comments from Eric Blake and Greg Kurz
Re-ordered the patches
Added the dummy functions in qmp.c to address the cross compilation issues

v4 -> v5:
Addressed comments from Eric Blake and Greg Kurz
Split the fsdev qmp patch into hmp and qmp related patches Moved the common functionalities to throttle.c instead of creating a new file

v5 -> v6:
Addressed comments from Greg Kurz and Markus Armbruster Split the commits to specific to hmp and throttle as suggested by Greg Moved ThrottleConfig typedef to qemu/typedefs.h
Addressed compilation issue on FreeBSD by adding flags in qmp.c

v6 -> v7:
Addressed comments from Albert Garcia and Dr. David Alan Gilbert Fixed the hmp-commands-info.hx and hmp-commands.hx as per Dr. David's comments.
Fixed the bug with the hmp fsdev_set_io_throttle and info fsdev_iothrottle

v7 -> v8:
Addressed comments from Markus Armbruster and Eric Blake Removed unwanted headers from qmp-fsdev-throttle.h

v8 -> v9:
Addressed comments from Markus Armbruster and Eric Blake Removed the iothrottle.json and pushed the iothrottle struct to block-core.json

v9 -> v10:
Addressed comments from Albert Garcia
Fixed issue related to dynamically passing throttle configuration Removed some unused code

v10 -> v11:
Addressed the comments from Markus Armbruster and Eric Blake Rebased the patches over 2.10

v11 -> v12:
Addressed comments by Manos Pitsidiankis
Moved back the device id to the fsdeviothrottle structure

Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v12 1/6 throttle: factor out duplicate code

This patch factors out the duplicate throttle code that was still present in block and fsdev devices.

---
 blockdev.c                      | 44 +---------------------------------
 fsdev/qemu-fsdev-throttle.c     | 44 ++--------------------------------
 include/qemu/throttle-options.h |  3 +++
 include/qemu/throttle.h         |  4 ++--
 include/qemu/typedefs.h         |  1 +
 util/throttle.c                 | 52 +++++++++++++++++++++++++++++++++++++++++
 6 files changed, 61 insertions(+), 87 deletions(-)
blockdev.c +1 -43
index 56a6b24..9d33c25 100644
@@ -387,49 +387,7 @@ static void extract_common_blockdev_options(QemuOpts *opts, int *bdrv_flags,
     }
 
     if (throttle_cfg) {
-        throttle_config_init(throttle_cfg);
-        throttle_cfg->buckets[THROTTLE_BPS_TOTAL].avg =
-            qemu_opt_get_number(opts, "throttling.bps-total", 0);
-        throttle_cfg->buckets[THROTTLE_BPS_READ].avg  =
-            qemu_opt_get_number(opts, "throttling.bps-read", 0);
-        throttle_cfg->buckets[THROTTLE_BPS_WRITE].avg =
-            qemu_opt_get_number(opts, "throttling.bps-write", 0);
-        throttle_cfg->buckets[THROTTLE_OPS_TOTAL].avg =
-            qemu_opt_get_number(opts, "throttling.iops-total", 0);
-        throttle_cfg->buckets[THROTTLE_OPS_READ].avg =
-            qemu_opt_get_number(opts, "throttling.iops-read", 0);
-        throttle_cfg->buckets[THROTTLE_OPS_WRITE].avg =
-            qemu_opt_get_number(opts, "throttling.iops-write", 0);
-
-        throttle_cfg->buckets[THROTTLE_BPS_TOTAL].max =
-            qemu_opt_get_number(opts, "throttling.bps-total-max", 0);
-        throttle_cfg->buckets[THROTTLE_BPS_READ].max  =
-            qemu_opt_get_number(opts, "throttling.bps-read-max", 0);
-        throttle_cfg->buckets[THROTTLE_BPS_WRITE].max =
-            qemu_opt_get_number(opts, "throttling.bps-write-max", 0);
-        throttle_cfg->buckets[THROTTLE_OPS_TOTAL].max =
-            qemu_opt_get_number(opts, "throttling.iops-total-max", 0);
-        throttle_cfg->buckets[THROTTLE_OPS_READ].max =
-            qemu_opt_get_number(opts, "throttling.iops-read-max", 0);
-        throttle_cfg->buckets[THROTTLE_OPS_WRITE].max =
-            qemu_opt_get_number(opts, "throttling.iops-write-max", 0);
-
-        throttle_cfg->buckets[THROTTLE_BPS_TOTAL].burst_length =
-            qemu_opt_get_number(opts, "throttling.bps-total-max-length", 1);
-        throttle_cfg->buckets[THROTTLE_BPS_READ].burst_length  =
-            qemu_opt_get_number(opts, "throttling.bps-read-max-length", 1);
-        throttle_cfg->buckets[THROTTLE_BPS_WRITE].burst_length =
-            qemu_opt_get_number(opts, "throttling.bps-write-max-length", 1);
-        throttle_cfg->buckets[THROTTLE_OPS_TOTAL].burst_length =
-            qemu_opt_get_number(opts, "throttling.iops-total-max-length", 1);
-        throttle_cfg->buckets[THROTTLE_OPS_READ].burst_length =
-            qemu_opt_get_number(opts, "throttling.iops-read-max-length", 1);
-        throttle_cfg->buckets[THROTTLE_OPS_WRITE].burst_length =
-            qemu_opt_get_number(opts, "throttling.iops-write-max-length", 1);
-
-        throttle_cfg->op_size =
-            qemu_opt_get_number(opts, "throttling.iops-size", 0);
-
+        throttle_parse_options(throttle_cfg, opts);
         if (!throttle_is_valid(throttle_cfg, errp)) {
             return;
         }
fsdev/qemu-fsdev-throttle.c +2 -42

56 lines not on this page · raw message

include/qemu/throttle-options.h +3 -0
index 3528a8f..9709dcd 100644
@@ -9,6 +9,7 @@
  */
 #ifndef THROTTLE_OPTIONS_H
 #define THROTTLE_OPTIONS_H
+#include "typedefs.h"
 
 #define QEMU_OPT_IOPS_TOTAL "iops-total"
 #define QEMU_OPT_IOPS_TOTAL_MAX "iops-total-max"
@@ -111,4 +112,6 @@
             .help = "when limiting by iops max size of an I/O in bytes",\
         }
 
+void throttle_parse_options(ThrottleConfig *, QemuOpts *);
+
 #endif
include/qemu/throttle.h +2 -2
index 8c93237..b6ebc6d 100644
@@ -89,10 +89,10 @@ typedef struct LeakyBucket {
  * However it allows to keep the code clean and the bucket field is reset to
  * zero at the right time.
  */
-typedef struct ThrottleConfig {
+struct ThrottleConfig {
     LeakyBucket buckets[BUCKETS_COUNT]; /* leaky buckets */
     uint64_t op_size;         /* size of an operation in bytes */
-} ThrottleConfig;
+};
 
 typedef struct ThrottleState {
     ThrottleConfig cfg;       /* configuration */
include/qemu/typedefs.h +1 -0
index 39bc835..90fe0f9 100644
@@ -100,6 +100,7 @@ typedef struct uWireSlave uWireSlave;
 typedef struct VirtIODevice VirtIODevice;
 typedef struct Visitor Visitor;
 typedef struct node_info NodeInfo;
+typedef struct ThrottleConfig ThrottleConfig;
 typedef void SaveStateHandler(QEMUFile *f, void *opaque);
 typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
 
util/throttle.c +52 -0

61 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#2 lore raw

PATCH v12 2/6 qmp: Use ThrottleLimits structure

In reply to Pradeep Jagadeesh

This patch factors out code to use the ThrottleLimits structure.

---
 qapi/block-core.json | 75 +++-------------------------------------------------
 1 file changed, 3 insertions(+), 72 deletions(-)
qapi/block-core.json +3 -72
index bb11815..5ca4597 100644
@@ -1824,86 +1824,17 @@
 #
 # A set of parameters describing block throttling.
 #
-# @device: Block device name (deprecated, use @id instead)
-#
 # @id: The name or QOM path of the guest device (since: 2.8)
 #
-# @bps: total throughput limit in bytes per second
-#
-# @bps_rd: read throughput limit in bytes per second
-#
-# @bps_wr: write throughput limit in bytes per second
-#
-# @iops: total I/O operations per second
-#
-# @iops_rd: read I/O operations per second
-#
-# @iops_wr: write I/O operations per second
-#
-# @bps_max: total throughput limit during bursts,
-#                     in bytes (Since 1.7)
-#
-# @bps_rd_max: read throughput limit during bursts,
-#                        in bytes (Since 1.7)
-#
-# @bps_wr_max: write throughput limit during bursts,
-#                        in bytes (Since 1.7)
-#
-# @iops_max: total I/O operations per second during bursts,
-#                      in bytes (Since 1.7)
-#
-# @iops_rd_max: read I/O operations per second during bursts,
-#                         in bytes (Since 1.7)
-#
-# @iops_wr_max: write I/O operations per second during bursts,
-#                         in bytes (Since 1.7)
-#
-# @bps_max_length: maximum length of the @bps_max burst
-#                            period, in seconds. It must only
-#                            be set if @bps_max is set as well.
-#                            Defaults to 1. (Since 2.6)
-#
-# @bps_rd_max_length: maximum length of the @bps_rd_max
-#                               burst period, in seconds. It must only
-#                               be set if @bps_rd_max is set as well.
-#                               Defaults to 1. (Since 2.6)
-#
-# @bps_wr_max_length: maximum length of the @bps_wr_max
-#                               burst period, in seconds. It must only
-#                               be set if @bps_wr_max is set as well.
-#                               Defaults to 1. (Since 2.6)
-#
-# @iops_max_length: maximum length of the @iops burst
-#                             period, in seconds. It must only
-#                             be set if @iops_max is set as well.
-#                             Defaults to 1. (Since 2.6)
-#
-# @iops_rd_max_length: maximum length of the @iops_rd_max
-#                                burst period, in seconds. It must only
-#                                be set if @iops_rd_max is set as well.
-#                                Defaults to 1. (Since 2.6)
-#
-# @iops_wr_max_length: maximum length of the @iops_wr_max
-#                                burst period, in seconds. It must only
-#                                be set if @iops_wr_max is set as well.
-#                                Defaults to 1. (Since 2.6)
-#
-# @iops_size: an I/O size in bytes (Since 1.7)
+# @device: Block device name (deprecated, use @id instead)
 #
 # @group: throttle group name (Since 2.4)
 #
 # Since: 1.1
 ##
 { 'struct': 'BlockIOThrottle',
-  'data': { '*device': 'str', '*id': 'str', 'bps': 'int', 'bps_rd': 'int',
-            'bps_wr': 'int', 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
-            '*bps_max': 'int', '*bps_rd_max': 'int',
-            '*bps_wr_max': 'int', '*iops_max': 'int',
-            '*iops_rd_max': 'int', '*iops_wr_max': 'int',
-            '*bps_max_length': 'int', '*bps_rd_max_length': 'int',
-            '*bps_wr_max_length': 'int', '*iops_max_length': 'int',
-            '*iops_rd_max_length': 'int', '*iops_wr_max_length': 'int',
-            '*iops_size': 'int', '*group': 'str' } }
+  'base': 'ThrottleLimits',
+  'data': { '*device': 'str', '*id': 'str', '*group': 'str' } }
 
 ##
 # @ThrottleLimits:
Signature · 1 line
1.8.3.1
#3 lore raw

PATCH v12 3/6 qmp: factor out throttle code to reuse code

In reply to Pradeep Jagadeesh

This patch reuses the code to set throttle limits.

---
 blockdev.c | 53 +++--------------------------------------------------
 1 file changed, 3 insertions(+), 50 deletions(-)
blockdev.c +3 -50
index 9d33c25..2bd8ebd 100644
@@ -2569,6 +2569,7 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp)
     BlockDriverState *bs;
     BlockBackend *blk;
     AioContext *aio_context;
+    ThrottleLimits *tlimit;
 
     blk = qmp_get_blk(arg->has_device ? arg->device : NULL,
                       arg->has_id ? arg->id : NULL,
@@ -2586,56 +2587,8 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp)
         goto out;
     }
 
-    throttle_config_init(&cfg);
-    cfg.buckets[THROTTLE_BPS_TOTAL].avg = arg->bps;
-    cfg.buckets[THROTTLE_BPS_READ].avg  = arg->bps_rd;
-    cfg.buckets[THROTTLE_BPS_WRITE].avg = arg->bps_wr;
-
-    cfg.buckets[THROTTLE_OPS_TOTAL].avg = arg->iops;
-    cfg.buckets[THROTTLE_OPS_READ].avg  = arg->iops_rd;
-    cfg.buckets[THROTTLE_OPS_WRITE].avg = arg->iops_wr;
-
-    if (arg->has_bps_max) {
-        cfg.buckets[THROTTLE_BPS_TOTAL].max = arg->bps_max;
-    }
-    if (arg->has_bps_rd_max) {
-        cfg.buckets[THROTTLE_BPS_READ].max = arg->bps_rd_max;
-    }
-    if (arg->has_bps_wr_max) {
-        cfg.buckets[THROTTLE_BPS_WRITE].max = arg->bps_wr_max;
-    }
-    if (arg->has_iops_max) {
-        cfg.buckets[THROTTLE_OPS_TOTAL].max = arg->iops_max;
-    }
-    if (arg->has_iops_rd_max) {
-        cfg.buckets[THROTTLE_OPS_READ].max = arg->iops_rd_max;
-    }
-    if (arg->has_iops_wr_max) {
-        cfg.buckets[THROTTLE_OPS_WRITE].max = arg->iops_wr_max;
-    }
-
-    if (arg->has_bps_max_length) {
-        cfg.buckets[THROTTLE_BPS_TOTAL].burst_length = arg->bps_max_length;
-    }
-    if (arg->has_bps_rd_max_length) {
-        cfg.buckets[THROTTLE_BPS_READ].burst_length = arg->bps_rd_max_length;
-    }
-    if (arg->has_bps_wr_max_length) {
-        cfg.buckets[THROTTLE_BPS_WRITE].burst_length = arg->bps_wr_max_length;
-    }
-    if (arg->has_iops_max_length) {
-        cfg.buckets[THROTTLE_OPS_TOTAL].burst_length = arg->iops_max_length;
-    }
-    if (arg->has_iops_rd_max_length) {
-        cfg.buckets[THROTTLE_OPS_READ].burst_length = arg->iops_rd_max_length;
-    }
-    if (arg->has_iops_wr_max_length) {
-        cfg.buckets[THROTTLE_OPS_WRITE].burst_length = arg->iops_wr_max_length;
-    }
-
-    if (arg->has_iops_size) {
-        cfg.op_size = arg->iops_size;
-    }
+    tlimit = qapi_BlockIOThrottle_base(arg);
+    throttle_config_to_limits(&cfg, tlimit);
 
     if (!throttle_is_valid(&cfg, errp)) {
         goto out;
Signature · 1 line
1.8.3.1
#4 lore raw

PATCH v12 4/6 hmp: create a throttle initialization function for code reuse

In reply to Pradeep Jagadeesh

This patch creates a throttle initialization function to maximize the code reusability. The same code is also used by fsdev.

---
 hmp.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
hmp.c +14 -6
index cd046c6..acaf0e6 100644
@@ -1752,20 +1752,28 @@ void hmp_change(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, &err);
 }
 
+static void hmp_initialize_throttle_limits(ThrottleLimits *iot,
+                                           const QDict *qdict)
+{
+    iot->bps_total = qdict_get_int(qdict, "bps");
+    iot->bps_read = qdict_get_int(qdict, "bps_rd");
+    iot->bps_write = qdict_get_int(qdict, "bps_wr");
+    iot->iops_total = qdict_get_int(qdict, "iops");
+    iot->iops_read = qdict_get_int(qdict, "iops_rd");
+    iot->iops_write = qdict_get_int(qdict, "iops_wr");
+}
+
 void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict)
 {
     Error *err = NULL;
+    ThrottleLimits *tlimits;
     BlockIOThrottle throttle = {
         .has_device = true,
         .device = (char *) qdict_get_str(qdict, "device"),
-        .bps = qdict_get_int(qdict, "bps"),
-        .bps_rd = qdict_get_int(qdict, "bps_rd"),
-        .bps_wr = qdict_get_int(qdict, "bps_wr"),
-        .iops = qdict_get_int(qdict, "iops"),
-        .iops_rd = qdict_get_int(qdict, "iops_rd"),
-        .iops_wr = qdict_get_int(qdict, "iops_wr"),
     };
 
+    tlimits = qapi_BlockIOThrottle_base(&throttle);
+    hmp_initialize_throttle_limits(tlimits, qdict);
     qmp_block_set_io_throttle(&throttle, &err);
     hmp_handle_error(mon, &err);
 }
Signature · 1 line
1.8.3.1
#5 lore raw

PATCH v12 5/6 fsdev: QMP interface for throttling

In reply to Pradeep Jagadeesh

This patch introduces qmp interfaces for the fsdev devices. This provides two interfaces one
for querying info of all the fsdev devices. The second one to set the IO limits for the required fsdev device.

---
 Makefile                    |   3 +-
 fsdev/qemu-fsdev-dummy.c    |  11 +++++
 fsdev/qemu-fsdev-throttle.c | 100 +++++++++++++++++++++++++++++++++++++++++---
 fsdev/qemu-fsdev-throttle.h |   9 +++-
 fsdev/qemu-fsdev.c          |  30 +++++++++++++
 monitor.c                   |   5 +++
 qapi-schema.json            |   4 ++
 qapi/fsdev.json             |  94 +++++++++++++++++++++++++++++++++++++++++
 qmp.c                       |  14 +++++++
 9 files changed, 261 insertions(+), 9 deletions(-)
 create mode 100644 qapi/fsdev.json
Makefile +2 -1
index 337a1f6..6556dbf 100644
@@ -421,7 +421,8 @@ qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \
                $(SRC_PATH)/qapi/tpm.json \
                $(SRC_PATH)/qapi/trace.json \
                $(SRC_PATH)/qapi/transaction.json \
-               $(SRC_PATH)/qapi/ui.json
+               $(SRC_PATH)/qapi/ui.json \
+	             $(SRC_PATH)/qapi/fsdev.json
 
 qapi-types.c qapi-types.h :\
 $(qapi-modules) $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
fsdev/qemu-fsdev-dummy.c +11 -0
index 6dc0fbc..b775e66 100644
@@ -14,8 +14,19 @@
 #include "qemu-fsdev.h"
 #include "qemu/config-file.h"
 #include "qemu/module.h"
+#include "qmp-commands.h"
 
 int qemu_fsdev_add(QemuOpts *opts)
 {
     return 0;
 }
+
+void qmp_fsdev_set_io_throttle(FsdevIOThrottle *arg, Error **errp)
+{
+    return;
+}
+
+FsdevIOThrottleList *qmp_query_fsdev_io_throttle(Error **errp)
+{
+    return NULL;
+}
fsdev/qemu-fsdev-throttle.c +94 -6

125 lines not on this page · raw message

fsdev/qemu-fsdev-throttle.h +7 -2
index e418643..5331c23 100644
@@ -15,8 +15,6 @@
 #ifndef _FSDEV_THROTTLE_H
 #define _FSDEV_THROTTLE_H
 
-#include "block/aio.h"
-#include "qemu/main-loop.h"
 #include "qemu/coroutine.h"
 #include "qapi/error.h"
 #include "qemu/throttle.h"
@@ -25,6 +23,7 @@ typedef struct FsThrottle {
     ThrottleState ts;
     ThrottleTimers tt;
     ThrottleConfig cfg;
+    AioContext *ctx;
     CoQueue      throttled_reqs[2];
 } FsThrottle;
 
@@ -36,4 +35,10 @@ void coroutine_fn fsdev_co_throttle_request(FsThrottle *, bool ,
                                             struct iovec *, int);
 
 void fsdev_throttle_cleanup(FsThrottle *);
+
+void fsdev_set_io_throttle(FsdevIOThrottle *, FsThrottle *, Error **errp);
+
+void fsdev_get_io_throttle(FsThrottle *, FsdevIOThrottle **iothp,
+                           char *);
+
 #endif /* _FSDEV_THROTTLE_H */
fsdev/qemu-fsdev.c +30 -0
index 266e442..4bfd233 100644
@@ -16,6 +16,7 @@
 #include "qemu-common.h"
 #include "qemu/config-file.h"
 #include "qemu/error-report.h"
+#include "qmp-commands.h"
 
 static QTAILQ_HEAD(FsDriverEntry_head, FsDriverListEntry) fsdriver_entries =
     QTAILQ_HEAD_INITIALIZER(fsdriver_entries);
@@ -98,3 +99,32 @@ FsDriverEntry *get_fsdev_fsentry(char *id)
     }
     return NULL;
 }
+
+void qmp_fsdev_set_io_throttle(FsdevIOThrottle *arg, Error **errp)
+{
+
+    FsDriverEntry *fse;
+
+    fse = get_fsdev_fsentry(arg->has_id ? arg->id : NULL);
+    if (!fse) {
+        error_setg(errp, "Not a valid fsdev device");
+        return;
+    }
+
+    fsdev_set_io_throttle(arg, &fse->fst, errp);
+}
+
+FsdevIOThrottleList *qmp_query_fsdev_io_throttle(Error **errp)
+{
+    FsdevIOThrottleList *head = NULL, *p_next;
+    struct FsDriverListEntry *fsle;
+
+    QTAILQ_FOREACH(fsle, &fsdriver_entries, next) {
+        p_next = g_new0(FsdevIOThrottleList, 1);
+        fsdev_get_io_throttle(&fsle->fse.fst, &p_next->value,
+                              fsle->fse.fsdev_id);
+        p_next->next = head;
+        head = p_next;
+    }
+    return head;
+}
monitor.c +5 -0
index 9239f7a..d12334f 100644
@@ -998,6 +998,11 @@ static void qmp_unregister_commands_hack(void)
     && !defined(TARGET_S390X)
     qmp_unregister_command(&qmp_commands, "query-cpu-definitions");
 #endif
+#ifndef CONFIG_VIRTFS
+    qmp_unregister_command(&qmp_commands, "fsdev-set-io-throttle");
+    qmp_unregister_command(&qmp_commands, "query-fsdev-io-throttle");
+#endif
+
 }
 
 void monitor_init_qmp_commands(void)
qapi-schema.json +4 -0
index f3af2cb..bd55190 100644
@@ -93,6 +93,10 @@
 { 'include': 'qapi/trace.json' }
 { 'include': 'qapi/introspect.json' }
 
+# QAPI fsdev definitions
+{ 'include': 'qapi/fsdev.json' }
+
+
 ##
 # = Miscellanea
 ##
qapi/fsdev.json new file +94 -0

94 lines not on this page · raw message

qmp.c +14 -0
index b86201e..bdbdbbe 100644
@@ -130,6 +130,20 @@ void qmp_cpu_add(int64_t id, Error **errp)
     }
 }
 
+#if defined(_WIN64) || defined(_WIN32) || defined(__FreeBSD__)
+
+void qmp_fsdev_set_io_throttle(FsdevIOThrottle *arg, Error **errp)
+{
+    return;
+}
+
+FsdevIOThrottleList *qmp_query_fsdev_io_throttle(Error **errp)
+{
+    return NULL;
+}
+
+#endif
+
 #ifndef CONFIG_VNC
 /* If VNC support is enabled, the "true" query-vnc command is
    defined in the VNC subsystem */
Signature · 1 line
1.8.3.1
#6 lore raw

PATCH v12 6/6 fsdev: hmp interface for throttling

In reply to Pradeep Jagadeesh

This patch introduces hmp interfaces for the fsdev devices.

---
 hmp-commands-info.hx | 18 ++++++++++++++++
 hmp-commands.hx      | 19 ++++++++++++++++
 hmp.c                | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 hmp.h                |  4 ++++
 4 files changed, 102 insertions(+)
hmp-commands-info.hx +18 -0
index 4ab7fce..54f1968 100644
@@ -84,6 +84,24 @@ STEXI
 Show block device statistics.
 ETEXI
 
+#if defined(CONFIG_VIRTFS)
+
+    {
+        .name       = "fsdev_iothrottle",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show fsdev iothrottle information",
+        .cmd        = hmp_info_fsdev_iothrottle,
+    },
+
+#endif
+
+STEXI
+@item info fsdev_iothrottle
+@findex fsdev_iothrottle
+Show fsdev device throttle info.
+ETEXI
+
     {
         .name       = "block-jobs",
         .args_type  = "",
hmp-commands.hx +19 -0
index 1941e19..aef9f79 100644
@@ -1680,6 +1680,25 @@ STEXI
 Change I/O throttle limits for a block drive to @var{bps} @var{bps_rd} @var{bps_wr} @var{iops} @var{iops_rd} @var{iops_wr}
 ETEXI
 
+#if defined(CONFIG_VIRTFS)
+
+    {
+        .name       = "fsdev_set_io_throttle",
+        .args_type  = "device:B,bps:l,bps_rd:l,bps_wr:l,iops:l,iops_rd:l,iops_wr:l",
+        .params     = "device bps bps_rd bps_wr iops iops_rd iops_wr",
+        .help       = "change I/O throttle limits for a fs devices",
+        .cmd        = hmp_fsdev_set_io_throttle,
+    },
+
+#endif
+
+STEXI
+@item fsdev_set_io_throttle @var{device} @var{bps} @var{bps_rd} @var{bps_wr} @var{iops} @var{iops_rd} @var{iops_wr}
+@findex fsdev_set_io_throttle
+Change I/O throttle limits for a fs devices to @var{bps} @var{bps_rd} @var{bps_wr} @var{iops} @var{iops_rd} @var{iops_wr}
+ETEXI
+
+
     {
         .name       = "set_password",
         .args_type  = "protocol:s,password:s,connected:s?",
hmp.c +61 -0

67 lines not on this page · raw message

hmp.h +4 -0
index 1ff4552..d700d7d 100644
@@ -81,6 +81,10 @@ void hmp_set_password(Monitor *mon, const QDict *qdict);
 void hmp_expire_password(Monitor *mon, const QDict *qdict);
 void hmp_eject(Monitor *mon, const QDict *qdict);
 void hmp_change(Monitor *mon, const QDict *qdict);
+#ifdef CONFIG_VIRTFS
+void hmp_fsdev_set_io_throttle(Monitor *mon, const QDict *qdict);
+void hmp_info_fsdev_iothrottle(Monitor *mon, const QDict *qdict);
+#endif
 void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict);
 void hmp_block_stream(Monitor *mon, const QDict *qdict);
 void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict);
Signature · 1 line
1.8.3.1