[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v2 11/22] block: New option to define the intervals
From: |
Alberto Garcia |
Subject: |
[Qemu-block] [PATCH v2 11/22] block: New option to define the intervals for collecting I/O statistics |
Date: |
Fri, 2 Oct 2015 17:26:21 +0300 |
The BlockAcctStats structure contains a list of BlockAcctTimedStats.
Each one of these collects statistics about the minimum, maximum and
average latencies of all I/O operations in a certain interval of time.
This patch adds a new "stats-intervals" option that allows defining
these intervals.
Signed-off-by: Alberto Garcia <address@hidden>
---
blockdev.c | 37 +++++++++++++++++++++++++++++++++++++
qapi/block-core.json | 4 ++++
2 files changed, 41 insertions(+)
diff --git a/blockdev.c b/blockdev.c
index 61a80fb..86dd03c 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -462,6 +462,7 @@ static BlockBackend *blockdev_init(const char *file, QDict
*bs_opts,
int bdrv_flags = 0;
int on_read_error, on_write_error;
bool account_invalid, account_failed;
+ const char *stats_intervals;
BlockBackend *blk;
BlockDriverState *bs;
ThrottleConfig cfg;
@@ -501,6 +502,8 @@ static BlockBackend *blockdev_init(const char *file, QDict
*bs_opts,
account_invalid = qemu_opt_get_bool(opts, "stats-account-invalid", true);
account_failed = qemu_opt_get_bool(opts, "stats-account-failed", true);
+ stats_intervals = qemu_opt_get(opts, "stats-intervals");
+
extract_common_blockdev_options(opts, &bdrv_flags, &cfg, &detect_zeroes,
&throttling_group, &error);
if (error) {
@@ -603,6 +606,35 @@ static BlockBackend *blockdev_init(const char *file, QDict
*bs_opts,
}
block_acct_init(blk_get_stats(blk), account_invalid, account_failed);
+
+ if (stats_intervals) {
+ char **intervals = g_strsplit(stats_intervals, ":", 0);
+ unsigned i;
+
+ if (*stats_intervals == '\0') {
+ error_setg(&error, "stats-intervals can't have an empty
value");
+ }
+
+ for (i = 0; !error && intervals[i] != NULL; i++) {
+ unsigned long long val;
+ if (parse_uint_full(intervals[i], &val, 10) == 0 &&
+ val > 0 && val <= UINT_MAX) {
+ block_acct_add_interval(blk_get_stats(blk), val);
+ } else {
+ error_setg(&error, "Invalid interval length: '%s'",
+ intervals[i]);
+ }
+ }
+
+ g_strfreev(intervals);
+
+ if (error) {
+ error_propagate(errp, error);
+ blk_unref(blk);
+ blk = NULL;
+ goto err_no_bs_opts;
+ }
+ }
}
blk_set_on_error(blk, on_read_error, on_write_error);
@@ -3544,6 +3576,11 @@ QemuOptsList qemu_common_drive_opts = {
.type = QEMU_OPT_BOOL,
.help = "whether to account for failed I/O operations "
"in the statistics",
+ },{
+ .name = "stats-intervals",
+ .type = QEMU_OPT_STRING,
+ .help = "colon-separated list of intervals "
+ "for collecting I/O statistics, in seconds",
},
{ /* end of list */ }
},
diff --git a/qapi/block-core.json b/qapi/block-core.json
index c6db03b..146d5ab 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1506,6 +1506,9 @@
# @stats-account-failed: #optional whether to include failed
# operations when computing latency and last
# access statistics (default: true) (Since 2.5)
+# @stats-intervals: #optional colon-separated list of intervals for
+# collecting I/O statistics, in seconds (default: none)
+# (Since 2.5)
# @detect-zeroes: #optional detect and optimize zero writes (Since 2.1)
# (default: off)
#
@@ -1523,6 +1526,7 @@
'*read-only': 'bool',
'*stats-account-invalid': 'bool',
'*stats-account-failed': 'bool',
+ '*stats-intervals': 'str',
'*detect-zeroes': 'BlockdevDetectZeroesOptions' } }
##
--
2.5.3
- [Qemu-block] [PATCH v2 00/22] Extended I/O accounting, Alberto Garcia, 2015/10/08
- [Qemu-block] [PATCH v2 11/22] block: New option to define the intervals for collecting I/O statistics,
Alberto Garcia <=
- [Qemu-block] [PATCH v2 04/22] util: Infrastructure for computing recent averages, Alberto Garcia, 2015/10/08
- [Qemu-block] [PATCH v2 02/22] ide: Account for write operations correctly, Alberto Garcia, 2015/10/08
- [Qemu-block] [PATCH v2 18/22] atapi: Account for failed and invalid operations, Alberto Garcia, 2015/10/08
- [Qemu-block] [PATCH v2 22/22] block: Update copyright of the accounting code, Alberto Garcia, 2015/10/08
- [Qemu-block] [PATCH v2 06/22] block: Add "supports_stats" field to BlockStats, Alberto Garcia, 2015/10/08