[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 06/22] block: Add "supports_stats" field to Block
From: |
Alberto Garcia |
Subject: |
[Qemu-devel] [PATCH v2 06/22] block: Add "supports_stats" field to BlockStats |
Date: |
Fri, 2 Oct 2015 17:26:16 +0300 |
query-blockstats always returns a BlockDeviceStats structure for each
BDS, regardless of whether it implements accounting or not. Since the
field is mandatory there's no way to tell that from the values alone.
This field solves that problem by indicating which BDSs support I/O
accounting.
Signed-off-by: Alberto Garcia <address@hidden>
---
block/qapi.c | 2 ++
qapi/block-core.json | 3 +++
qmp-commands.hx | 6 ++++++
3 files changed, 11 insertions(+)
diff --git a/block/qapi.c b/block/qapi.c
index 66f2604..518b658 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -343,6 +343,8 @@ static BlockStats *bdrv_query_stats(const BlockDriverState
*bs,
s->node_name = g_strdup(bdrv_get_node_name(bs));
}
+ s->supports_stats = bs->blk != NULL;
+
s->stats = g_malloc0(sizeof(*s->stats));
if (bs->blk) {
BlockAcctStats *stats = blk_get_stats(bs->blk);
diff --git a/qapi/block-core.json b/qapi/block-core.json
index a529e2f..903884b 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -471,6 +471,8 @@
#
# @node-name: #optional The node name of the device. (Since 2.3)
#
+# @supports_stats: Whether the device supports I/O stats (Since 2.5)
+#
# @stats: A @BlockDeviceStats for the device.
#
# @parent: #optional This describes the file block device if it has one.
@@ -482,6 +484,7 @@
##
{ 'struct': 'BlockStats',
'data': {'*device': 'str', '*node-name': 'str',
+ 'supports_stats': 'bool',
'stats': 'BlockDeviceStats',
'*parent': 'BlockStats',
'*backing': 'BlockStats'} }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 13c1bdc..2f48bb6 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -2496,6 +2496,7 @@ value is a json-array of all devices.
Each json-object contain the following:
- "device": device name (json-string)
+- "supports_stats": whether the device supports I/O stats (json-bool)
- "stats": A json-object with the statistics information, it contains:
- "rd_bytes": bytes read (json-int)
- "wr_bytes": bytes written (json-int)
@@ -2528,6 +2529,7 @@ Example:
{
"device":"ide0-hd0",
"parent":{
+ "supports_stats":true,
"stats":{
"wr_highest_offset":3686448128,
"wr_bytes":9786368,
@@ -2543,6 +2545,7 @@ Example:
"idle_time_ns":2953431879
}
},
+ "supports_stats":true,
"stats":{
"wr_highest_offset":2821110784,
"wr_bytes":9786368,
@@ -2560,6 +2563,7 @@ Example:
},
{
"device":"ide1-cd0",
+ "supports_stats":false,
"stats":{
"wr_highest_offset":0,
"wr_bytes":0,
@@ -2576,6 +2580,7 @@ Example:
},
{
"device":"floppy0",
+ "supports_stats":false,
"stats":{
"wr_highest_offset":0,
"wr_bytes":0,
@@ -2592,6 +2597,7 @@ Example:
},
{
"device":"sd0",
+ "supports_stats":false,
"stats":{
"wr_highest_offset":0,
"wr_bytes":0,
--
2.5.3
- [Qemu-devel] [PATCH v2 00/22] Extended I/O accounting, Alberto Garcia, 2015/10/08
- [Qemu-devel] [PATCH v2 16/22] virtio-blk: Account for failed and invalid operations, Alberto Garcia, 2015/10/08
- [Qemu-devel] [PATCH v2 01/22] xen_disk: Account for flush operations, Alberto Garcia, 2015/10/08
- [Qemu-devel] [PATCH v2 04/22] util: Infrastructure for computing recent averages, Alberto Garcia, 2015/10/08
- [Qemu-devel] [PATCH v2 22/22] block: Update copyright of the accounting code, Alberto Garcia, 2015/10/08
- [Qemu-devel] [PATCH v2 05/22] block: Add idle_time_ns to BlockDeviceStats, Alberto Garcia, 2015/10/08
- [Qemu-devel] [PATCH v2 06/22] block: Add "supports_stats" field to BlockStats,
Alberto Garcia <=
[Qemu-devel] [PATCH v2 07/22] block: Add statistics for failed and invalid I/O operations, Alberto Garcia, 2015/10/08
[Qemu-devel] [PATCH v2 03/22] block: define 'clock_type' for the accounting code, Alberto Garcia, 2015/10/08