From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, mreitz@redhat.com, kwolf@redhat.com,
vsementsov@virtuozzo.com, berto@igalia.com
Subject: [PATCH v2 2/5] block-backend: improve blk_root_get_parent_desc()
Date: Tue, 4 May 2021 12:45:07 +0300 [thread overview]
Message-ID: <20210504094510.25032-3-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20210504094510.25032-1-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>
---
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
next prev parent reply other threads:[~2021-05-04 9:49 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-04 9:45 [PATCH v2 0/5] block permission updated follow-up Vladimir Sementsov-Ogievskiy
2021-05-04 9:45 ` [PATCH v2 1/5] block: document child argument of bdrv_attach_child_common() Vladimir Sementsov-Ogievskiy
2021-05-04 9:45 ` Vladimir Sementsov-Ogievskiy [this message]
2021-05-31 15:45 ` [PATCH v2 2/5] block-backend: improve blk_root_get_parent_desc() Kevin Wolf
2021-05-31 16:18 ` Vladimir Sementsov-Ogievskiy
2021-05-04 9:45 ` [PATCH v2 3/5] block: improve bdrv_child_get_parent_desc() Vladimir Sementsov-Ogievskiy
2021-05-10 15:30 ` Alberto Garcia
2021-05-04 9:45 ` [PATCH v2 4/5] block: simplify bdrv_child_user_desc() Vladimir Sementsov-Ogievskiy
2021-05-10 15:33 ` Alberto Garcia
2021-05-10 15:35 ` Vladimir Sementsov-Ogievskiy
2021-05-31 15:50 ` Kevin Wolf
2021-05-31 16:22 ` Vladimir Sementsov-Ogievskiy
2021-05-04 9:45 ` [PATCH v2 5/5] block: improve permission conflict error message Vladimir Sementsov-Ogievskiy
2021-05-31 16:07 ` Kevin Wolf
2021-05-31 16:18 ` Vladimir Sementsov-Ogievskiy
2021-05-31 16:35 ` Kevin Wolf
2021-05-31 16:44 ` Vladimir Sementsov-Ogievskiy
2021-05-24 14:24 ` [PATCH v2 0/5] block permission updated follow-up Vladimir Sementsov-Ogievskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210504094510.25032-3-vsementsov@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=berto@igalia.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).