[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v8 27/43] block: Use child access functions for QAPI queries
From: |
Max Reitz |
Subject: |
[PATCH v8 27/43] block: Use child access functions for QAPI queries |
Date: |
Tue, 1 Sep 2020 16:34:08 +0200 |
query-block, query-named-block-nodes, and query-blockstats now return
any filtered child under "backing", not just bs->backing or COW
children. This is so that filters do not interrupt the reported backing
chain. This changes the output for iotest 184, as the throttled node
now appears as a backing child.
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
---
block/qapi.c | 33 ++++++++++++++++++++-------------
tests/qemu-iotests/184.out | 8 +++++++-
2 files changed, 27 insertions(+), 14 deletions(-)
diff --git a/block/qapi.c b/block/qapi.c
index c57b42d86d..2628323b63 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -163,9 +163,13 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk,
break;
}
- if (bs0->drv && bs0->backing) {
+ if (bs0->drv && bdrv_filter_or_cow_child(bs0)) {
+ /*
+ * Put any filtered child here (for backwards compatibility to when
+ * we put bs0->backing here, which might be any filtered child).
+ */
info->backing_file_depth++;
- bs0 = bs0->backing->bs;
+ bs0 = bdrv_filter_or_cow_bs(bs0);
(*p_image_info)->has_backing_image = true;
p_image_info = &((*p_image_info)->backing_image);
} else {
@@ -174,9 +178,8 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk,
/* Skip automatically inserted nodes that the user isn't aware of for
* query-block (blk != NULL), but not for query-named-block-nodes */
- while (blk && bs0->drv && bs0->implicit) {
- bs0 = backing_bs(bs0);
- assert(bs0);
+ if (blk) {
+ bs0 = bdrv_skip_implicit_filters(bs0);
}
}
@@ -362,9 +365,7 @@ static void bdrv_query_info(BlockBackend *blk, BlockInfo
**p_info,
char *qdev;
/* Skip automatically inserted nodes that the user isn't aware of */
- while (bs && bs->drv && bs->implicit) {
- bs = backing_bs(bs);
- }
+ bs = bdrv_skip_implicit_filters(bs);
info->device = g_strdup(blk_name(blk));
info->type = g_strdup("unknown");
@@ -527,6 +528,7 @@ static BlockStats *bdrv_query_bds_stats(BlockDriverState
*bs,
bool blk_level)
{
BdrvChild *parent_child;
+ BlockDriverState *filter_or_cow_bs;
BlockStats *s = NULL;
s = g_malloc0(sizeof(*s));
@@ -539,9 +541,8 @@ static BlockStats *bdrv_query_bds_stats(BlockDriverState
*bs,
/* Skip automatically inserted nodes that the user isn't aware of in
* a BlockBackend-level command. Stay at the exact node for a node-level
* command. */
- while (blk_level && bs->drv && bs->implicit) {
- bs = backing_bs(bs);
- assert(bs);
+ if (blk_level) {
+ bs = bdrv_skip_implicit_filters(bs);
}
if (bdrv_get_node_name(bs)[0]) {
@@ -587,9 +588,15 @@ static BlockStats *bdrv_query_bds_stats(BlockDriverState
*bs,
s->parent = bdrv_query_bds_stats(parent_child->bs, blk_level);
}
- if (blk_level && bs->backing) {
+ filter_or_cow_bs = bdrv_filter_or_cow_bs(bs);
+ if (blk_level && filter_or_cow_bs) {
+ /*
+ * Put any filtered or COW child here (for backwards
+ * compatibility to when we put bs0->backing here, which might
+ * be either)
+ */
s->has_backing = true;
- s->backing = bdrv_query_bds_stats(bs->backing->bs, blk_level);
+ s->backing = bdrv_query_bds_stats(filter_or_cow_bs, blk_level);
}
return s;
diff --git a/tests/qemu-iotests/184.out b/tests/qemu-iotests/184.out
index dec4017ad5..87c73070e3 100644
--- a/tests/qemu-iotests/184.out
+++ b/tests/qemu-iotests/184.out
@@ -27,6 +27,12 @@ Testing:
"iops_rd": 0,
"detect_zeroes": "off",
"image": {
+ "backing-image": {
+ "virtual-size": 1073741824,
+ "filename": "null-co://",
+ "format": "null-co",
+ "actual-size": 0
+ },
"virtual-size": 1073741824,
"filename": "json:{\"throttle-group\": \"group0\", \"driver\":
\"throttle\", \"file\": {\"driver\": \"null-co\"}}",
"format": "throttle",
@@ -35,7 +41,7 @@ Testing:
"iops_wr": 0,
"ro": false,
"node-name": "throttle0",
- "backing_file_depth": 0,
+ "backing_file_depth": 1,
"drv": "throttle",
"iops": 0,
"bps_wr": 0,
--
2.26.2
- [PATCH v8 16/43] block: Flush all children in generic code, (continued)
- [PATCH v8 16/43] block: Flush all children in generic code, Max Reitz, 2020/09/01
- [PATCH v8 18/43] block: Iterate over children in refresh_limits, Max Reitz, 2020/09/01
- [PATCH v8 19/43] block: Use CAFs in bdrv_refresh_filename(), Max Reitz, 2020/09/01
- [PATCH v8 20/43] block: Use CAF in bdrv_co_rw_vmstate(), Max Reitz, 2020/09/01
- [PATCH v8 21/43] block/snapshot: Fix fallback, Max Reitz, 2020/09/01
- [PATCH v8 24/43] block/null: Implement bdrv_get_allocated_file_size, Max Reitz, 2020/09/01
- [PATCH v8 22/43] block: Use CAFs for debug breakpoints, Max Reitz, 2020/09/01
- [PATCH v8 23/43] block: Improve get_allocated_file_size's default, Max Reitz, 2020/09/01
- [PATCH v8 25/43] blockdev: Use CAF in external_snapshot_prepare(), Max Reitz, 2020/09/01
- [PATCH v8 26/43] block: Report data child for query-blockstats, Max Reitz, 2020/09/01
- [PATCH v8 27/43] block: Use child access functions for QAPI queries,
Max Reitz <=
- [PATCH v8 28/43] block-copy: Use CAF to find sync=top base, Max Reitz, 2020/09/01
- [PATCH v8 29/43] mirror: Deal with filters, Max Reitz, 2020/09/01
- [PATCH v8 30/43] backup: Deal with filters, Max Reitz, 2020/09/01
- [PATCH v8 31/43] commit: Deal with filters, Max Reitz, 2020/09/01
- [PATCH v8 32/43] nbd: Use CAF when looking for dirty bitmap, Max Reitz, 2020/09/01
- [PATCH v8 33/43] qemu-img: Use child access functions, Max Reitz, 2020/09/01
- [PATCH v8 35/43] blockdev: Fix active commit choice, Max Reitz, 2020/09/01