[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 13/73] block/qapi: Add cache information to query-blo
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 13/73] block/qapi: Add cache information to query-block |
Date: |
Wed, 10 Dec 2014 11:33:39 +0100 |
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
block/qapi.c | 7 +++++++
hmp.c | 8 ++++++++
qapi/block-core.json | 20 +++++++++++++++++++-
tests/qemu-iotests/051.out | 1 +
tests/qemu-iotests/067.out | 25 +++++++++++++++++++++++++
5 files changed, 60 insertions(+), 1 deletion(-)
diff --git a/block/qapi.c b/block/qapi.c
index 3a14559..fa68ba7 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -40,6 +40,13 @@ BlockDeviceInfo *bdrv_block_device_info(BlockDriverState *bs)
info->encrypted = bs->encrypted;
info->encryption_key_missing = bdrv_key_required(bs);
+ info->cache = g_new(BlockdevCacheInfo, 1);
+ *info->cache = (BlockdevCacheInfo) {
+ .writeback = bdrv_enable_write_cache(bs),
+ .direct = !!(bs->open_flags & BDRV_O_NOCACHE),
+ .no_flush = !!(bs->open_flags & BDRV_O_NO_FLUSH),
+ };
+
if (bs->node_name[0]) {
info->has_node_name = true;
info->node_name = g_strdup(bs->node_name);
diff --git a/hmp.c b/hmp.c
index 94b27df..05c3730 100644
--- a/hmp.c
+++ b/hmp.c
@@ -294,6 +294,7 @@ void hmp_info_block(Monitor *mon, const QDict *qdict)
{
BlockInfoList *block_list, *info;
ImageInfo *image_info;
+ BlockDeviceInfo *inserted;
const char *device = qdict_get_try_str(qdict, "device");
bool verbose = qdict_get_try_bool(qdict, "verbose", 0);
@@ -335,6 +336,13 @@ void hmp_info_block(Monitor *mon, const QDict *qdict)
continue;
}
+ inserted = info->value->inserted;
+
+ monitor_printf(mon, " Cache mode: %s%s%s\n",
+ inserted->cache->writeback ? "writeback" :
"writethrough",
+ inserted->cache->direct ? ", direct" : "",
+ inserted->cache->no_flush ? ", ignore flushes" : "");
+
if (info->value->inserted->has_backing_file) {
monitor_printf(mon,
" Backing file: %s "
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 8e51e78..6e8db15 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -183,6 +183,22 @@
'*fragmented-clusters': 'int', '*compressed-clusters': 'int' } }
##
+# @BlockdevCacheInfo
+#
+# Cache mode information for a block device
+#
+# @writeback: true if writeback mode is enabled
+# @direct: true if the host page cache is bypassed (O_DIRECT)
+# @no-flush: true if flush requests are ignored for the device
+#
+# Since: 2.3
+##
+{ 'type': 'BlockdevCacheInfo',
+ 'data': { 'writeback': 'bool',
+ 'direct': 'bool',
+ 'no-flush': 'bool' } }
+
+##
# @BlockDeviceInfo:
#
# Information about the backing device for a block device.
@@ -239,6 +255,8 @@
#
# @iops_size: #optional an I/O size in bytes (Since 1.7)
#
+# @cache: the cache mode used for the block device (since: 2.3)
+#
# Since: 0.14.0
#
##
@@ -253,7 +271,7 @@
'*bps_max': 'int', '*bps_rd_max': 'int',
'*bps_wr_max': 'int', '*iops_max': 'int',
'*iops_rd_max': 'int', '*iops_wr_max': 'int',
- '*iops_size': 'int' } }
+ '*iops_size': 'int', 'cache': 'BlockdevCacheInfo' } }
##
# @BlockDeviceIoStatus:
diff --git a/tests/qemu-iotests/051.out b/tests/qemu-iotests/051.out
index 2c7e808..7f16134 100644
--- a/tests/qemu-iotests/051.out
+++ b/tests/qemu-iotests/051.out
@@ -50,6 +50,7 @@ Testing: -drive
file=TEST_DIR/t.qcow2,driver=qcow2,backing.file.filename=TEST_DI
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) i[K[Din[K[D[Dinf[K[D[D[Dinfo[K[D[D[D[Dinfo
[K[D[D[D[D[Dinfo b[K[D[D[D[D[D[Dinfo
bl[K[D[D[D[D[D[D[Dinfo blo[K[D[D[D[D[D[D[D[Dinfo
bloc[K[D[D[D[D[D[D[D[D[Dinfo block[K
ide0-hd0: TEST_DIR/t.qcow2 (qcow2)
+ Cache mode: writeback
Backing file: TEST_DIR/t.qcow2.orig (chain depth: 1)
(qemu) q[K[Dqu[K[D[Dqui[K[D[D[Dquit[K
diff --git a/tests/qemu-iotests/067.out b/tests/qemu-iotests/067.out
index 929dc74..7c3735f 100644
--- a/tests/qemu-iotests/067.out
+++ b/tests/qemu-iotests/067.out
@@ -46,6 +46,11 @@ Testing: -drive
file=TEST_DIR/t.qcow2,format=qcow2,if=none,id=disk -device virti
"encrypted": false,
"bps": 0,
"bps_rd": 0,
+ "cache": {
+ "no-flush": false,
+ "direct": false,
+ "writeback": true
+ },
"file": "TEST_DIR/t.qcow2",
"encryption_key_missing": false
},
@@ -216,6 +221,11 @@ Testing: -drive
file=TEST_DIR/t.qcow2,format=qcow2,if=none,id=disk
"encrypted": false,
"bps": 0,
"bps_rd": 0,
+ "cache": {
+ "no-flush": false,
+ "direct": false,
+ "writeback": true
+ },
"file": "TEST_DIR/t.qcow2",
"encryption_key_missing": false
},
@@ -416,6 +426,11 @@ Testing:
"encrypted": false,
"bps": 0,
"bps_rd": 0,
+ "cache": {
+ "no-flush": false,
+ "direct": false,
+ "writeback": true
+ },
"file": "TEST_DIR/t.qcow2",
"encryption_key_missing": false
},
@@ -595,6 +610,11 @@ Testing:
"encrypted": false,
"bps": 0,
"bps_rd": 0,
+ "cache": {
+ "no-flush": false,
+ "direct": false,
+ "writeback": true
+ },
"file": "TEST_DIR/t.qcow2",
"encryption_key_missing": false
},
@@ -700,6 +720,11 @@ Testing:
"encrypted": false,
"bps": 0,
"bps_rd": 0,
+ "cache": {
+ "no-flush": false,
+ "direct": false,
+ "writeback": true
+ },
"file": "TEST_DIR/t.qcow2",
"encryption_key_missing": false
},
--
1.8.3.1
- [Qemu-devel] [PULL 00/73] Merging block-next for 2.3, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 01/73] block: Add bdrv_next_node, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 06/73] chardev: Add -qmp-pretty, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 07/73] iotests: _filter_qmp for pretty JSON output, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 09/73] blockdev: acquire AioContext in blockdev-snapshot-delete-internal-sync, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 02/73] block: Add bdrv_get_node_name, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 11/73] blockdev: acquire AioContext in eject, change, and block_passwd, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 03/73] block: Include "node-name" if present in query-blockstats, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 15/73] block/hmp: Allow info = NULL in print_block_info(), Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 13/73] block/qapi: Add cache information to query-block,
Kevin Wolf <=
- [Qemu-devel] [PULL 10/73] blockdev: check for BLOCK_OP_TYPE_INTERNAL_SNAPSHOT_DELETE, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 14/73] block/hmp: Factor out print_block_info(), Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 16/73] block/hmp: Allow node-name in 'info block', Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 17/73] monitor: Fix HMP tab completion, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 21/73] ahci: replace SATA FIS type magic numbers with constants, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 23/73] block: Add AioContextNotifier functions to BB, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 19/73] iotests: Plain blkdebug filename generation, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 20/73] ahci: avoid #ifdef DEBUG_AHCI bitrot, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 22/73] block: Lift more functions into BlockBackend, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 24/73] block: Add blk_add_close_notifier() for BB, Kevin Wolf, 2014/12/10