[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 02/34] block: Use bdrv_qapi_perm_to_blk_perm()
From: |
Max Reitz |
Subject: |
[PULL 02/34] block: Use bdrv_qapi_perm_to_blk_perm() |
Date: |
Mon, 6 Jan 2020 15:41:34 +0100 |
We can save some LoC in xdbg_graph_add_edge() by using
bdrv_qapi_perm_to_blk_perm().
Signed-off-by: Max Reitz <address@hidden>
Message-id: address@hidden
Reviewed-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
---
block.c | 29 ++++++++---------------------
1 file changed, 8 insertions(+), 21 deletions(-)
diff --git a/block.c b/block.c
index 28eb5a774c..ecd09dbbfd 100644
--- a/block.c
+++ b/block.c
@@ -4872,36 +4872,23 @@ static void
xdbg_graph_add_node(XDbgBlockGraphConstructor *gr, void *node,
static void xdbg_graph_add_edge(XDbgBlockGraphConstructor *gr, void *parent,
const BdrvChild *child)
{
- typedef struct {
- unsigned int flag;
- BlockPermission num;
- } PermissionMap;
-
- static const PermissionMap permissions[] = {
- { BLK_PERM_CONSISTENT_READ, BLOCK_PERMISSION_CONSISTENT_READ },
- { BLK_PERM_WRITE, BLOCK_PERMISSION_WRITE },
- { BLK_PERM_WRITE_UNCHANGED, BLOCK_PERMISSION_WRITE_UNCHANGED },
- { BLK_PERM_RESIZE, BLOCK_PERMISSION_RESIZE },
- { BLK_PERM_GRAPH_MOD, BLOCK_PERMISSION_GRAPH_MOD },
- { 0, 0 }
- };
- const PermissionMap *p;
+ BlockPermission qapi_perm;
XDbgBlockGraphEdge *edge;
- QEMU_BUILD_BUG_ON(1UL << (ARRAY_SIZE(permissions) - 1) != BLK_PERM_ALL +
1);
-
edge = g_new0(XDbgBlockGraphEdge, 1);
edge->parent = xdbg_graph_node_num(gr, parent);
edge->child = xdbg_graph_node_num(gr, child->bs);
edge->name = g_strdup(child->name);
- for (p = permissions; p->flag; p++) {
- if (p->flag & child->perm) {
- QAPI_LIST_ADD(edge->perm, p->num);
+ for (qapi_perm = 0; qapi_perm < BLOCK_PERMISSION__MAX; qapi_perm++) {
+ uint64_t flag = bdrv_qapi_perm_to_blk_perm(qapi_perm);
+
+ if (flag & child->perm) {
+ QAPI_LIST_ADD(edge->perm, qapi_perm);
}
- if (p->flag & child->shared_perm) {
- QAPI_LIST_ADD(edge->shared_perm, p->num);
+ if (flag & child->shared_perm) {
+ QAPI_LIST_ADD(edge->shared_perm, qapi_perm);
}
}
--
2.24.1
- [PULL 00/34] Block patches, Max Reitz, 2020/01/06
- [PULL 01/34] block: Add bdrv_qapi_perm_to_blk_perm(), Max Reitz, 2020/01/06
- [PULL 02/34] block: Use bdrv_qapi_perm_to_blk_perm(),
Max Reitz <=
- [PULL 04/34] iotests: Add @error to wait_until_completed, Max Reitz, 2020/01/06
- [PULL 03/34] blkdebug: Allow taking/unsharing permissions, Max Reitz, 2020/01/06
- [PULL 05/34] iotests: Add test for failing mirror complete, Max Reitz, 2020/01/06
- [PULL 06/34] throttle-groups: fix memory leak in throttle_group_set_limit:, Max Reitz, 2020/01/06
- [PULL 07/34] qcow2-bitmaps: fix qcow2_can_store_new_dirty_bitmap, Max Reitz, 2020/01/06
- [PULL 08/34] iotests: s/qocw2/qcow2/, Max Reitz, 2020/01/06
- [PULL 09/34] iotests/qcow2.py: Add dump-header-exts, Max Reitz, 2020/01/06
- [PULL 10/34] iotests/qcow2.py: Split feature fields into bits, Max Reitz, 2020/01/06
- [PULL 11/34] iotests: Add _filter_json_filename, Max Reitz, 2020/01/06
- [PULL 13/34] iotests: Replace IMGOPTS by _unsupported_imgopts, Max Reitz, 2020/01/06