]> git.proxmox.com Git - mirror_qemu.git/commitdiff
block/qapi: Add cache information to query-block
authorKevin Wolf <kwolf@redhat.com>
Thu, 22 May 2014 11:28:45 +0000 (13:28 +0200)
committerKevin Wolf <kwolf@redhat.com>
Wed, 10 Dec 2014 09:31:09 +0000 (10:31 +0100)
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
block/qapi.c
hmp.c
qapi/block-core.json
tests/qemu-iotests/051.out
tests/qemu-iotests/067.out

index 3a14559ca0afc5eb6e082c3c19f10f018f941727..fa68ba731f39b4e36ac7339202b31a87e60a0b57 100644 (file)
@@ -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 94b27df0861ea458b05ecadd93f6b2fe111a881a..05c373022710da65ff0be849bac8029d65df0150 100644 (file)
--- 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 "
index 8e51e78e1bc5d8563fba1d2479afa465aa45fc15..6e8db15861dae24c4df7f98c709b389e7c69e128 100644 (file)
            '*total-clusters': 'int', '*allocated-clusters': 'int',
            '*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:
 #
 #
 # @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
 #
 ##
             '*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:
index 2c7e8087655614bdad67840154641a265e1f2ea2..7f161342a2c64c098989e82c9ad2b5ac7c34e260 100644 (file)
@@ -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\e[K\e[Din\e[K\e[D\e[Dinf\e[K\e[D\e[D\e[Dinfo\e[K\e[D\e[D\e[D\e[Dinfo \e[K\e[D\e[D\e[D\e[D\e[Dinfo b\e[K\e[D\e[D\e[D\e[D\e[D\e[Dinfo bl\e[K\e[D\e[D\e[D\e[D\e[D\e[D\e[Dinfo blo\e[K\e[D\e[D\e[D\e[D\e[D\e[D\e[D\e[Dinfo bloc\e[K\e[D\e[D\e[D\e[D\e[D\e[D\e[D\e[D\e[Dinfo block\e[K
 ide0-hd0: TEST_DIR/t.qcow2 (qcow2)
+    Cache mode:       writeback
     Backing file:     TEST_DIR/t.qcow2.orig (chain depth: 1)
 (qemu) q\e[K\e[Dqu\e[K\e[D\e[Dqui\e[K\e[D\e[D\e[Dquit\e[K
 
index 929dc745e658a484b332d0af1e3a3597af8cba7b..7c3735f1811c234f4519d6b667991a65d4167838 100644 (file)
@@ -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
             },