From: Markus Armbruster <armbru@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Cc: kwolf@redhat.com, pkrempa@redhat.com, berrange@redhat.com,
ehabkost@redhat.com, qemu-block@nongnu.org,
libvir-list@redhat.com, dim@virtuozzo.com, igor@virtuozzo.com,
armbru@redhat.com, qemu-devel@nongnu.org, yur@virtuozzo.com,
nshirokovskiy@virtuozzo.com, stefanha@redhat.com, den@openvz.org,
pbonzini@redhat.com, mreitz@redhat.com, eblake@redhat.com
Subject: Re: [PATCH 6/8] qdev: realize BlockParentClass
Date: Mon, 20 Sep 2021 08:08:28 +0200 [thread overview]
Message-ID: <87v92v4w4j.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20210802185416.50877-7-vsementsov@virtuozzo.com> (Vladimir Sementsov-Ogievskiy's message of "Mon, 2 Aug 2021 21:54:14 +0300")
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> writes:
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
> softmmu/qdev-monitor.c | 42 ++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 42 insertions(+)
>
> diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
> index 0117989009..2e149aa9b8 100644
> --- a/softmmu/qdev-monitor.c
> +++ b/softmmu/qdev-monitor.c
> @@ -18,6 +18,7 @@
> */
>
> #include "qemu/osdep.h"
> +#include "block/block-parent.h"
> #include "hw/sysbus.h"
> #include "monitor/hmp.h"
> #include "monitor/monitor.h"
> @@ -1023,3 +1024,44 @@ bool qmp_command_available(const QmpCommand *cmd, Error **errp)
> }
> return true;
> }
> +
> +static int qdev_find_child(const char *parent_id, const char *child_name,
> + BlockDriverState *child_bs,
> + BdrvChild **child, Error **errp)
> +{
> + int ret;
> + DeviceState *dev;
> + BlockBackend *blk;
> +
> + ret = find_device_state(parent_id, &dev, errp);
> + if (ret <= 0) {
> + return ret;
> + }
> +
> + blk = blk_by_dev(dev);
> + if (!blk || !blk_root(blk)) {
> + error_setg(errp, "Device '%s' does not have a block device backend",
> + parent_id);
> + return -EINVAL;
> + }
> +
> + if (child_bs && blk_bs(blk) != child_bs) {
> + error_setg(errp, "Root child of device '%s' doesn't match", parent_id);
What is a "root child", and why would a user care?
The contract missing in PATCH 2 leaves me floundering.
> + return -EINVAL;
> + }
> +
> + *child = blk_root(blk);
> + return 1;
> +}
> +
> +BlockParentClass block_parent_qdev = {
> + .name = "qdev",
> + .find_child = qdev_find_child,
> +};
> +
> +static void qdev_monitor_init(void)
> +{
> + block_parent_class_register(&block_parent_qdev);
> +}
> +
> +block_init(qdev_monitor_init);
next prev parent reply other threads:[~2021-09-20 6:09 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-02 18:54 [PATCH RFC 0/8] blockdev-replace Vladimir Sementsov-Ogievskiy
2021-08-02 18:54 ` [PATCH 1/8] block-backend: blk_root(): drop const specifier on return type Vladimir Sementsov-Ogievskiy
2021-08-02 18:54 ` [PATCH 2/8] block: add BlockParentClass class Vladimir Sementsov-Ogievskiy
2021-09-16 8:34 ` Markus Armbruster
2021-09-16 10:12 ` Vladimir Sementsov-Ogievskiy
2021-09-20 5:28 ` Markus Armbruster
2021-08-02 18:54 ` [PATCH 3/8] block: realize BlockParentClass for BlockDriverState Vladimir Sementsov-Ogievskiy
2021-08-02 18:54 ` [PATCH 4/8] block/export: realize BlockParentClass functionality Vladimir Sementsov-Ogievskiy
2021-08-02 18:54 ` [PATCH 5/8] qdev: improve find_device_state() to distinguish simple not found case Vladimir Sementsov-Ogievskiy
2021-09-16 10:48 ` Markus Armbruster
2021-09-16 12:54 ` Vladimir Sementsov-Ogievskiy
2021-08-02 18:54 ` [PATCH 6/8] qdev: realize BlockParentClass Vladimir Sementsov-Ogievskiy
2021-09-20 6:08 ` Markus Armbruster [this message]
2021-08-02 18:54 ` [PATCH 7/8] block: improve bdrv_replace_node_noperm() Vladimir Sementsov-Ogievskiy
2021-08-02 18:54 ` [PATCH 8/8] qapi: add blockdev-replace command Vladimir Sementsov-Ogievskiy
2021-09-20 6:44 ` Markus Armbruster
2021-09-20 10:02 ` Vladimir Sementsov-Ogievskiy
2021-09-23 10:09 ` Markus Armbruster
2021-09-23 11:54 ` Vladimir Sementsov-Ogievskiy
2021-09-20 11:25 ` Vladimir Sementsov-Ogievskiy
2021-09-02 9:28 ` [PATCH RFC 0/8] blockdev-replace 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=87v92v4w4j.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=den@openvz.org \
--cc=dim@virtuozzo.com \
--cc=eblake@redhat.com \
--cc=ehabkost@redhat.com \
--cc=igor@virtuozzo.com \
--cc=kwolf@redhat.com \
--cc=libvir-list@redhat.com \
--cc=mreitz@redhat.com \
--cc=nshirokovskiy@virtuozzo.com \
--cc=pbonzini@redhat.com \
--cc=pkrempa@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=vsementsov@virtuozzo.com \
--cc=yur@virtuozzo.com \
/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).