[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/6] block-backend: improve blk_root_get_parent_desc()
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH 3/6] block-backend: improve blk_root_get_parent_desc() |
Date: |
Mon, 3 May 2021 14:33:59 +0300 |
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>
---
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 6fca9853e1..2b7e9b5192 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -142,19 +142,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("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.29.2
- [PATCH 0/6] block permission updated follow-up, Vladimir Sementsov-Ogievskiy, 2021/05/03
- [PATCH 1/6] block: fix leak of tran in bdrv_root_attach_child, Vladimir Sementsov-Ogievskiy, 2021/05/03
- [PATCH 2/6] block: bdrv_reopen_multiple(): fix leak of tran object, Vladimir Sementsov-Ogievskiy, 2021/05/03
- [PATCH 6/6] block: improve permission conflict error message, Vladimir Sementsov-Ogievskiy, 2021/05/03
- [PATCH 3/6] block-backend: improve blk_root_get_parent_desc(),
Vladimir Sementsov-Ogievskiy <=
- [PATCH 4/6] block: improve bdrv_child_get_parent_desc(), Vladimir Sementsov-Ogievskiy, 2021/05/03
- [PATCH 5/6] block: simplify bdrv_child_user_desc(), Vladimir Sementsov-Ogievskiy, 2021/05/03
- [PATCH 7/6] block: document child argument of bdrv_attach_child_common(), Vladimir Sementsov-Ogievskiy, 2021/05/03