qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 1/6] block/qapi: Add cache information to query-bloc


From: Kevin Wolf
Subject: [Qemu-devel] [PATCH 1/6] block/qapi: Add cache information to query-block
Date: Tue, 16 Sep 2014 17:36:31 +0200

Signed-off-by: Kevin Wolf <address@hidden>
---
 block/qapi.c               | 10 ++++++++++
 hmp.c                      |  8 ++++++++
 qapi/block-core.json       |  4 +++-
 tests/qemu-iotests/051.out |  1 +
 tests/qemu-iotests/067.out | 10 +++++-----
 5 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/block/qapi.c b/block/qapi.c
index 9733ebd..6b43bc3 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -46,6 +46,16 @@ BlockDeviceInfo *bdrv_block_device_info(BlockDriverState *bs)
     info->encrypted              = bs->encrypted;
     info->encryption_key_missing = bdrv_key_required(bs);
 
+    info->cache = g_new(BlockdevCacheOptions, 1);
+    *info->cache = (BlockdevCacheOptions) {
+        .writeback      = bdrv_enable_write_cache(bs),
+        .has_writeback  = true,
+        .direct         = !!(bs->open_flags & BDRV_O_NOCACHE),
+        .has_direct     = true,
+        .no_flush       = !!(bs->open_flags & BDRV_O_NO_FLUSH),
+        .has_no_flush   = true,
+    };
+
     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 40a90da..c3846b8 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 95dcd81..c53b587 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -238,6 +238,8 @@
 #
 # @iops_size: #optional an I/O size in bytes (Since 1.7)
 #
+# @cache: the cache mode used for the block device (since: 2.2)
+#
 # Since: 0.14.0
 #
 ##
@@ -252,7 +254,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': 'BlockdevCacheOptions' } }
 
 ##
 # @BlockDeviceIoStatus:
diff --git a/tests/qemu-iotests/051.out b/tests/qemu-iotests/051.out
index a3f2820..fee597e 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) iininfinfoinfo 
info binfo 
blinfo bloinfo 
blocinfo block
 ide0-hd0: TEST_DIR/t.qcow2 (qcow2)
+    Cache mode:       writeback
     Backing file:     TEST_DIR/t.qcow2.orig (chain depth: 1)
 (qemu) qququiquit
 
diff --git a/tests/qemu-iotests/067.out b/tests/qemu-iotests/067.out
index 7e090b9..3774c95 100644
--- a/tests/qemu-iotests/067.out
+++ b/tests/qemu-iotests/067.out
@@ -6,7 +6,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,if=none,id=disk -device 
virtio-blk-pci,drive=disk,id=virtio0
 QMP_VERSION
 {"return": {}}
-{"return": [{"io-status": "ok", "device": "disk", "locked": false, 
"removable": false, "inserted": {"iops_rd": 0, "detect_zeroes": "off", "image": 
{"virtual-size": 134217728, "filename": "TEST_DIR/t.qcow2", "cluster-size": 
65536, "format": "qcow2", "actual-size": SIZE, "format-specific": {"type": 
"qcow2", "data": {"compat": "1.1", "lazy-refcounts": false}}, "dirty-flag": 
false}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, "drv": "qcow2", 
"iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file": 
"TEST_DIR/t.qcow2", "encryption_key_missing": false}, "type": "unknown"}, 
{"io-status": "ok", "device": "ide1-cd0", "locked": false, "removable": true, 
"tray_open": false, "type": "unknown"}, {"device": "floppy0", "locked": false, 
"removable": true, "tray_open": false, "type": "unknown"}, {"device": "sd0", 
"locked": false, "removable": true, "tray_open": false, "type": "unknown"}]}
+{"return": [{"io-status": "ok", "device": "disk", "locked": false, 
"removable": false, "inserted": {"iops_rd": 0, "detect_zeroes": "off", "image": 
{"virtual-size": 134217728, "filename": "TEST_DIR/t.qcow2", "cluster-size": 
65536, "format": "qcow2", "actual-size": SIZE, "format-specific": {"type": 
"qcow2", "data": {"compat": "1.1", "lazy-refcounts": false}}, "dirty-flag": 
false}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, "drv": "qcow2", 
"iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "cache": 
{"no-flush": false, "direct": false, "writeback": true}, "file": 
"TEST_DIR/t.qcow2", "encryption_key_missing": false}, "type": "unknown"}, 
{"io-status": "ok", "device": "ide1-cd0", "locked": false, "removable": true, 
"tray_open": false, "type": "unknown"}, {"device": "floppy0", "locked": false, 
"removable": true, "tray_open": false, "type": "unknown"}, {"device": "sd0", 
"locked": false, "removable": true, "tray_open": false, "type": "unknown"}]}
 {"return": {}}
 {"return": {}}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
"DEVICE_DELETED", "data": {"path": 
"/machine/peripheral/virtio0/virtio-backend"}}
@@ -24,7 +24,7 @@ QMP_VERSION
 Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,if=none,id=disk
 QMP_VERSION
 {"return": {}}
-{"return": [{"device": "disk", "locked": false, "removable": true, "inserted": 
{"iops_rd": 0, "detect_zeroes": "off", "image": {"virtual-size": 134217728, 
"filename": "TEST_DIR/t.qcow2", "cluster-size": 65536, "format": "qcow2", 
"actual-size": SIZE, "format-specific": {"type": "qcow2", "data": {"compat": 
"1.1", "lazy-refcounts": false}}, "dirty-flag": false}, "iops_wr": 0, "ro": 
false, "backing_file_depth": 0, "drv": "qcow2", "iops": 0, "bps_wr": 0, 
"encrypted": false, "bps": 0, "bps_rd": 0, "file": "TEST_DIR/t.qcow2", 
"encryption_key_missing": false}, "tray_open": false, "type": "unknown"}, 
{"io-status": "ok", "device": "ide1-cd0", "locked": false, "removable": true, 
"tray_open": false, "type": "unknown"}, {"device": "floppy0", "locked": false, 
"removable": true, "tray_open": false, "type": "unknown"}, {"device": "sd0", 
"locked": false, "removable": true, "tray_open": false, "type": "unknown"}]}
+{"return": [{"device": "disk", "locked": false, "removable": true, "inserted": 
{"iops_rd": 0, "detect_zeroes": "off", "image": {"virtual-size": 134217728, 
"filename": "TEST_DIR/t.qcow2", "cluster-size": 65536, "format": "qcow2", 
"actual-size": SIZE, "format-specific": {"type": "qcow2", "data": {"compat": 
"1.1", "lazy-refcounts": false}}, "dirty-flag": false}, "iops_wr": 0, "ro": 
false, "backing_file_depth": 0, "drv": "qcow2", "iops": 0, "bps_wr": 0, 
"encrypted": false, "bps": 0, "bps_rd": 0, "cache": {"no-flush": false, 
"direct": false, "writeback": true}, "file": "TEST_DIR/t.qcow2", 
"encryption_key_missing": false}, "tray_open": false, "type": "unknown"}, 
{"io-status": "ok", "device": "ide1-cd0", "locked": false, "removable": true, 
"tray_open": false, "type": "unknown"}, {"device": "floppy0", "locked": false, 
"removable": true, "tray_open": false, "type": "unknown"}, {"device": "sd0", 
"locked": false, "removable": true, "tray_open": false, "type": "unknown"}]}
 {"return": {}}
 {"return": {}}
 {"return": {}}
@@ -44,7 +44,7 @@ Testing:
 QMP_VERSION
 {"return": {}}
 {"return": "OK\r\n"}
-{"return": [{"io-status": "ok", "device": "ide1-cd0", "locked": false, 
"removable": true, "tray_open": false, "type": "unknown"}, {"device": 
"floppy0", "locked": false, "removable": true, "tray_open": false, "type": 
"unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": 
false, "type": "unknown"}, {"device": "disk", "locked": false, "removable": 
true, "inserted": {"iops_rd": 0, "detect_zeroes": "off", "image": 
{"virtual-size": 134217728, "filename": "TEST_DIR/t.qcow2", "cluster-size": 
65536, "format": "qcow2", "actual-size": SIZE, "format-specific": {"type": 
"qcow2", "data": {"compat": "1.1", "lazy-refcounts": false}}, "dirty-flag": 
false}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, "drv": "qcow2", 
"iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file": 
"TEST_DIR/t.qcow2", "encryption_key_missing": false}, "tray_open": false, 
"type": "unknown"}]}
+{"return": [{"io-status": "ok", "device": "ide1-cd0", "locked": false, 
"removable": true, "tray_open": false, "type": "unknown"}, {"device": 
"floppy0", "locked": false, "removable": true, "tray_open": false, "type": 
"unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": 
false, "type": "unknown"}, {"device": "disk", "locked": false, "removable": 
true, "inserted": {"iops_rd": 0, "detect_zeroes": "off", "image": 
{"virtual-size": 134217728, "filename": "TEST_DIR/t.qcow2", "cluster-size": 
65536, "format": "qcow2", "actual-size": SIZE, "format-specific": {"type": 
"qcow2", "data": {"compat": "1.1", "lazy-refcounts": false}}, "dirty-flag": 
false}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, "drv": "qcow2", 
"iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "cache": 
{"no-flush": false, "direct": false, "writeback": true}, "file": 
"TEST_DIR/t.qcow2", "encryption_key_missing": false}, "tray_open": false, 
"type": "unknown"}]}
 {"return": {}}
 {"return": {}}
 {"return": {}}
@@ -64,14 +64,14 @@ Testing:
 QMP_VERSION
 {"return": {}}
 {"return": {}}
-{"return": [{"io-status": "ok", "device": "ide1-cd0", "locked": false, 
"removable": true, "tray_open": false, "type": "unknown"}, {"device": 
"floppy0", "locked": false, "removable": true, "tray_open": false, "type": 
"unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": 
false, "type": "unknown"}, {"device": "disk", "locked": false, "removable": 
true, "inserted": {"iops_rd": 0, "detect_zeroes": "off", "image": 
{"virtual-size": 134217728, "filename": "TEST_DIR/t.qcow2", "cluster-size": 
65536, "format": "qcow2", "actual-size": SIZE, "format-specific": {"type": 
"qcow2", "data": {"compat": "1.1", "lazy-refcounts": false}}, "dirty-flag": 
false}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, "drv": "qcow2", 
"iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file": 
"TEST_DIR/t.qcow2", "encryption_key_missing": false}, "tray_open": false, 
"type": "unknown"}]}
+{"return": [{"io-status": "ok", "device": "ide1-cd0", "locked": false, 
"removable": true, "tray_open": false, "type": "unknown"}, {"device": 
"floppy0", "locked": false, "removable": true, "tray_open": false, "type": 
"unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": 
false, "type": "unknown"}, {"device": "disk", "locked": false, "removable": 
true, "inserted": {"iops_rd": 0, "detect_zeroes": "off", "image": 
{"virtual-size": 134217728, "filename": "TEST_DIR/t.qcow2", "cluster-size": 
65536, "format": "qcow2", "actual-size": SIZE, "format-specific": {"type": 
"qcow2", "data": {"compat": "1.1", "lazy-refcounts": false}}, "dirty-flag": 
false}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, "drv": "qcow2", 
"iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "cache": 
{"no-flush": false, "direct": false, "writeback": true}, "file": 
"TEST_DIR/t.qcow2", "encryption_key_missing": false}, "tray_open": false, 
"type": "unknown"}]}
 {"return": {}}
 {"return": {}}
 {"return": {}}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
"DEVICE_DELETED", "data": {"path": 
"/machine/peripheral/virtio0/virtio-backend"}}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
"DEVICE_DELETED", "data": {"device": "virtio0", "path": 
"/machine/peripheral/virtio0"}}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
"RESET"}
-{"return": [{"io-status": "ok", "device": "ide1-cd0", "locked": false, 
"removable": true, "tray_open": false, "type": "unknown"}, {"device": 
"floppy0", "locked": false, "removable": true, "tray_open": false, "type": 
"unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": 
false, "type": "unknown"}, {"io-status": "ok", "device": "disk", "locked": 
false, "removable": true, "inserted": {"iops_rd": 0, "detect_zeroes": "off", 
"image": {"virtual-size": 134217728, "filename": "TEST_DIR/t.qcow2", 
"cluster-size": 65536, "format": "qcow2", "actual-size": SIZE, 
"format-specific": {"type": "qcow2", "data": {"compat": "1.1", 
"lazy-refcounts": false}}, "dirty-flag": false}, "iops_wr": 0, "ro": false, 
"backing_file_depth": 0, "drv": "qcow2", "iops": 0, "bps_wr": 0, "encrypted": 
false, "bps": 0, "bps_rd": 0, "file": "TEST_DIR/t.qcow2", 
"encryption_key_missing": false}, "tray_open": false, "type": "unknown"}]}
+{"return": [{"io-status": "ok", "device": "ide1-cd0", "locked": false, 
"removable": true, "tray_open": false, "type": "unknown"}, {"device": 
"floppy0", "locked": false, "removable": true, "tray_open": false, "type": 
"unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": 
false, "type": "unknown"}, {"io-status": "ok", "device": "disk", "locked": 
false, "removable": true, "inserted": {"iops_rd": 0, "detect_zeroes": "off", 
"image": {"virtual-size": 134217728, "filename": "TEST_DIR/t.qcow2", 
"cluster-size": 65536, "format": "qcow2", "actual-size": SIZE, 
"format-specific": {"type": "qcow2", "data": {"compat": "1.1", 
"lazy-refcounts": false}}, "dirty-flag": false}, "iops_wr": 0, "ro": false, 
"backing_file_depth": 0, "drv": "qcow2", "iops": 0, "bps_wr": 0, "encrypted": 
false, "bps": 0, "bps_rd": 0, "cache": {"no-flush": false, "direct": false, 
"writeback": true}, "file": "TEST_DIR/t.qcow2", "encryption_key_missing": 
false}, "tray_open": false, "type": "unkno!
 wn"}]}
 {"return": {}}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
"SHUTDOWN"}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": 
"DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}}
-- 
1.8.3.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]