[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 11/20] block-backend: improve blk_root_get_parent_desc()
From: |
Kevin Wolf |
Subject: |
[PULL 11/20] block-backend: improve blk_root_get_parent_desc() |
Date: |
Wed, 2 Jun 2021 15:45:20 +0200 |
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
We have different types of parents: block nodes, block backends and
jobs. So, it makes sense to specify type together with name.
While being here also use g_autofree.
iotest 307 output is updated.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Message-Id: <20210601075218.79249-3-vsementsov@virtuozzo.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/block-backend.c | 9 ++++-----
tests/qemu-iotests/307.out | 2 +-
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/block/block-backend.c b/block/block-backend.c
index d1a33a2c8e..5be32c0c42 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -141,19 +141,18 @@ static void blk_root_set_aio_ctx(BdrvChild *child,
AioContext *ctx,
static char *blk_root_get_parent_desc(BdrvChild *child)
{
BlockBackend *blk = child->opaque;
- char *dev_id;
+ g_autofree char *dev_id = NULL;
if (blk->name) {
- return g_strdup(blk->name);
+ return g_strdup_printf("block device '%s'", blk->name);
}
dev_id = blk_get_attached_dev_id(blk);
if (*dev_id) {
- return dev_id;
+ return g_strdup_printf("block device '%s'", dev_id);
} else {
/* TODO Callback into the BB owner for something more detailed */
- g_free(dev_id);
- return g_strdup("a block device");
+ return g_strdup("an unnamed block device");
}
}
diff --git a/tests/qemu-iotests/307.out b/tests/qemu-iotests/307.out
index daa8ad2da0..66bf2ddb74 100644
--- a/tests/qemu-iotests/307.out
+++ b/tests/qemu-iotests/307.out
@@ -53,7 +53,7 @@ exports available: 1
=== Add a writable export ===
{"execute": "block-export-add", "arguments": {"description": "This is the
writable second export", "id": "export1", "name": "export1", "node-name":
"fmt", "type": "nbd", "writable": true, "writethrough": true}}
-{"error": {"class": "GenericError", "desc": "Conflicts with use by sda as
'root', which does not allow 'write' on fmt"}}
+{"error": {"class": "GenericError", "desc": "Conflicts with use by block
device 'sda' as 'root', which does not allow 'write' on fmt"}}
{"execute": "device_del", "arguments": {"id": "sda"}}
{"return": {}}
{"data": {"device": "sda", "path": "/machine/peripheral/sda"}, "event":
"DEVICE_DELETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
--
2.30.2
- [PULL 02/20] qemu-io-cmds: assert that we don't have .perm requested in no-blk case, (continued)
- [PULL 02/20] qemu-io-cmds: assert that we don't have .perm requested in no-blk case, Kevin Wolf, 2021/06/02
- [PULL 01/20] block/quorum: Provide .bdrv_co_flush instead of .bdrv_co_flush_to_disk, Kevin Wolf, 2021/06/02
- [PULL 03/20] block/vvfat: child_vvfat_qcow: add .get_parent_aio_context, fix crash, Kevin Wolf, 2021/06/02
- [PULL 04/20] block/vvfat: fix vvfat_child_perm crash, Kevin Wolf, 2021/06/02
- [PULL 05/20] block: consistently use bdrv_is_read_only(), Kevin Wolf, 2021/06/02
- [PULL 06/20] block: drop BlockDriverState::read_only, Kevin Wolf, 2021/06/02
- [PULL 08/20] block/file-posix: Fix problem with fallocate(PUNCH_HOLE) on GPFS, Kevin Wolf, 2021/06/02
- [PULL 07/20] block: drop BlockBackendRootState::read_only, Kevin Wolf, 2021/06/02
- [PULL 10/20] block: document child argument of bdrv_attach_child_common(), Kevin Wolf, 2021/06/02
- [PULL 09/20] block/file-posix: Try other fallbacks after invalid FALLOC_FL_ZERO_RANGE, Kevin Wolf, 2021/06/02
- [PULL 11/20] block-backend: improve blk_root_get_parent_desc(),
Kevin Wolf <=
- [PULL 12/20] block: improve bdrv_child_get_parent_desc(), Kevin Wolf, 2021/06/02
- [PULL 13/20] block/vvfat: inherit child_vvfat_qcow from child_of_bds, Kevin Wolf, 2021/06/02
- [PULL 14/20] block: simplify bdrv_child_user_desc(), Kevin Wolf, 2021/06/02
- [PULL 15/20] block: improve permission conflict error message, Kevin Wolf, 2021/06/02
- [PULL 17/20] nbd/server: Use drained block ops to quiesce the server, Kevin Wolf, 2021/06/02
- [PULL 16/20] block-backend: add drained_poll, Kevin Wolf, 2021/06/02
- [PULL 20/20] docs/secure-coding-practices: Describe how to use 'null-co' block driver, Kevin Wolf, 2021/06/02
- [PULL 18/20] block-copy: fix block_copy_task_entry() progress update, Kevin Wolf, 2021/06/02
- [PULL 19/20] block-copy: refactor copy_range handling, Kevin Wolf, 2021/06/02
- Re: [PULL 00/20] Block layer patches, Peter Maydell, 2021/06/03