From: Markus Armbruster <armbru@redhat.com>
To: Zhang Chen <zhangckid@gmail.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>,
Kevin Wolf <kwolf@redhat.com>,
qemu-devel <qemu-devel@nongnu.org>,
"Dr . David Alan Gilbert" <dave@treblig.org>,
Eric Blake <eblake@redhat.com>,
"Michael S . Tsirkin" <mst@redhat.com>,
Hanna Czenczek <hreitz@redhat.com>
Subject: Re: [PATCH V5 04/13] blockdev: Update tracking iothread users with holder name
Date: Wed, 18 Mar 2026 07:19:10 +0100 [thread overview]
Message-ID: <87jyv9fyn5.fsf@pond.sub.org> (raw)
In-Reply-To: <CAK3tnvJc2U+c=sx=RASKHCAjcTQMx9dg0iOpe5eEui9U0-Ft_g@mail.gmail.com> (Zhang Chen's message of "Tue, 17 Mar 2026 21:25:06 +0800")
Zhang Chen <zhangckid@gmail.com> writes:
> On Thu, Mar 12, 2026 at 5:16 PM Markus Armbruster <armbru@redhat.com> wrote:
>>
>> Context... we're talking about this command:
>>
>> ##
>> # @x-blockdev-set-iothread:
>> #
>> # Move @node and its children into the @iothread. If @iothread is
>> # null then move @node and its children into the main loop.
>> #
>> # The node must not be attached to a BlockBackend.
>> #
>> # @node-name: the name of the block driver node
>> #
>> # @iothread: the name of the IOThread object or null for the main loop
>> #
>> # @force: true if the node and its children should be moved when a
>> # BlockBackend is already attached
>> #
>> # Features:
>> #
>> # @unstable: This command is experimental and intended for test cases
>> # that need control over IOThreads only.
>> #
>> # Since: 2.12
>> #
>> # .. qmp-example::
>> # :title: Move a node into an IOThread
>> #
>> # -> { "execute": "x-blockdev-set-iothread",
>> # "arguments": { "node-name": "disk1",
>> # "iothread": "iothread0" } }
>> # <- { "return": {} }
>> #
>> # .. qmp-example::
>> # :title: Move a node into the main loop
>> #
>> # -> { "execute": "x-blockdev-set-iothread",
>> # "arguments": { "node-name": "disk1",
>> # "iothread": null } }
>> # <- { "return": {} }
>> ##
>> { 'command': 'x-blockdev-set-iothread',
>> 'data' : { 'node-name': 'str',
>> 'iothread': 'StrOrNull',
>> '*force': 'bool' },
>> 'features': [ 'unstable' ],
>> 'allow-preconfig': true }
>>
>>
>> Stefan Hajnoczi <stefanha@redhat.com> writes:
>>
>> > On Tue, Mar 10, 2026 at 06:02:54PM +0800, Zhang Chen wrote:
>> >> On Mon, Mar 9, 2026 at 4:15 PM Stefan Hajnoczi <stefanha@redhat.com> wrote:
>> >> >
>> >> > On Thu, Mar 05, 2026 at 10:24:50PM +0800, Zhang Chen wrote:
>> >> > > Update the usage of "iothread_get_aio_context()".
>> >> > >
>> >> > > Signed-off-by: Zhang Chen <zhangckid@gmail.com>
>> >> > > ---
>> >> > > blockdev.c | 9 ++++++++-
>> >> > > 1 file changed, 8 insertions(+), 1 deletion(-)
>> >> > >
>> >> > > diff --git a/blockdev.c b/blockdev.c
>> >> > > index 6e86c6262f..01ccf64b3f 100644
>> >> > > --- a/blockdev.c
>> >> > > +++ b/blockdev.c
>> >> > > @@ -3683,7 +3683,14 @@ void qmp_x_blockdev_set_iothread(const char *node_name, StrOrNull *iothread,
>> >> > > goto out;
>> >> > > }
>> >> > >
>> >> > > - new_context = iothread_get_aio_context(obj);
>> >> > > + char *path = object_get_canonical_path(OBJECT(bs));
>> >> >
>> >> > CCing Kevin and Markus in case they have an opinion on this.
>> >> >
>> >> > BlockDriverState is not a QOM Object so using OBJECT(bs) is undefined
>> >> > behavior and may crash.
>>
>> Yes.
>>
>> >> > node_name is unique across block driver graph nodes and could be used.
>> >> > Unfortunately it's not connected to the QOM Object hierarchy.
>>
>> Correct.
>>
>> >> > Maybe it's
>> >> > best to build a holder name that is an invalid QOM path so there can be
>> >> > no collisions between QOM paths and block driver graph nodes.
>>
>> I guess you're talking about the values that go into IOThreadInfo member
>> holders. From PATCH 13:
>>
>> # @holders: The parameter is an array of QOM paths indicating how many
>> # active devices are currently associated with this iothread
>> # (e.g. virtio-blk). In hotplug scenarios, users can
>> # pre-allocate multiple iothread objects to serve as a persistent
>> # thread pool. When a device is hot-unplugged, the corresponding
>> # IOThread is released but remains available, allowing subsequent
>> # hot-plugged devices to attach to and reuse the existing thread.
>> # Returns empty if no devices are attached. (since 11.0)
>> #
>>
>> I further guess you need it to refer to both QOM objects and block
>> nodes, and you worry about ambiguity.
>>
>> Ambiguity indeed exists: a block node name can be a valid QOM path.
>>
>> We could restrict QOM paths to absolute paths. These start with '/'.
>> If I remember correctly, node names cannot contain '/'.
>>
>> Note that canonical paths (returned object_get_canonical_path()) are
>> absolute.
>>
>> We ran into a similar design issue in review of Vladimir's "[PATCH v10
>> 4/8] qapi: add blockdev-replace command" not too long ago:
>>
>> Subject: Re: [PATCH v10 4/8] qapi: add blockdev-replace command
>> Date: Wed, 04 Feb 2026 13:26:35 +0100
>> Message-ID: <87wm0sy9s4.fsf@pond.sub.org>
>>
>> There, the new command needs to refer to QOM object, block node, or
>> block export.
>>
>> >> > g_autofree char *holder = g_strdup_printf("BlockDriverState %s", node_name);
>> >> >
>> >> > (A cleaner long-term solution would be making BlockDriverStates QOM
>> >> > Objects so they have a proper path.)
>>
>> Yes, but that's a beefy project, isn't it?
>>
>> >> If no other comments, it's OK for me. This issue like I mentioned in
>> >> patch 7 and 9.
>> >
>> > A thought about the QAPI interface:
>> >
>> > QAPI expresses as much information in the schema as possible, so I think
>> > the right approach would be a {'union': 'IOThreadHolder',
>> > 'discriminator': 'type', ...} that supports at least "qom" and
>> > "block-node". That way there are proper types to encode QOM Object paths
>> > vs block node-names. Let's avoid having a single string value that takes
>> > on different meaning depending on the type of holder.
>>
>> This shifts the complexity from semantics to syntax.
>>
>> Semantics: the member can have multiple meanings, and you have to
>> examine its value to decide which one applies. The member's
>> documentation should specify how to decide. Say something like "if the
>> value starts with '/', it's an absolute QOM path, else it's a block node
>> name".
>>
>> Syntax: meaning is syntactically obvious. For instance, union of QOM
>> path and block node name.
>>
>> Complex semantics tend to require more complex documentation.
>>
>> Which choice is better depends on the specific case. I generally lean
>> towards syntax.
>>
>
> I agree Markus's suggestion.
> Compare with standard QOM path:
> /machine/peripheral/blk0/virtio-backend
>
> I will try to implement block nodes path like this:
> /machine/blockdriverstate/node-name
I gather you'd like to try creating QOM objects for block nodes.
First, this should not go into /machine. We already have /chardevs and
/audiodevs, which suggests something like /blockdevs or /block-nodes.
Second, QOMifying block nodes feels ambitious to me. Please discuss it
with block maintainers Kevin and Hanna.
> And Markus, could you please take a look at patch 13?
> I will prepare the V6 after your comments.
Done. It may need an update for changes made here, though.
next prev parent reply other threads:[~2026-03-18 6:19 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-05 14:24 [PATCH V5 00/13] iothread: Support tracking and querying IOThread holders Zhang Chen
2026-03-05 14:24 ` [PATCH V5 01/13] qapi/misc: Fix missed query-iothreads items Zhang Chen
2026-03-05 14:24 ` [PATCH V5 02/13] iothread: introduce iothread_ref/unref to track attached devices Zhang Chen
2026-03-09 7:49 ` Stefan Hajnoczi
2026-03-10 9:49 ` Zhang Chen
2026-03-05 14:24 ` [PATCH V5 03/13] iothread: tracking iothread users with holder name Zhang Chen
2026-03-09 8:02 ` Stefan Hajnoczi
2026-03-10 9:49 ` Zhang Chen
2026-03-09 8:33 ` Stefan Hajnoczi
2026-03-10 9:51 ` Zhang Chen
2026-03-05 14:24 ` [PATCH V5 04/13] blockdev: Update " Zhang Chen
2026-03-09 8:15 ` Stefan Hajnoczi
2026-03-10 10:02 ` Zhang Chen
2026-03-12 5:24 ` Stefan Hajnoczi
2026-03-12 7:05 ` Zhang Chen
2026-03-12 7:44 ` Stefan Hajnoczi
2026-03-12 9:16 ` Markus Armbruster
2026-03-17 13:25 ` Zhang Chen
2026-03-18 6:19 ` Markus Armbruster [this message]
2026-03-18 9:13 ` Stefan Hajnoczi
2026-03-30 3:13 ` Zhang Chen
2026-03-30 9:02 ` Markus Armbruster
2026-03-30 13:31 ` Stefan Hajnoczi
2026-03-30 17:43 ` Zhang Chen
2026-03-30 17:52 ` Stefan Hajnoczi
2026-03-30 18:58 ` Zhang Chen
2026-03-31 5:14 ` Markus Armbruster
2026-03-05 14:24 ` [PATCH V5 05/13] virtio-vq-mapping: track iothread-vq-mapping references using device path Zhang Chen
2026-03-09 8:21 ` Stefan Hajnoczi
2026-03-10 10:03 ` Zhang Chen
2026-03-05 14:24 ` [PATCH V5 06/13] virtio: use iothread_get/put_aio_context for thread pinning Zhang Chen
2026-03-09 8:27 ` Stefan Hajnoczi
2026-03-10 10:07 ` Zhang Chen
2026-03-05 14:24 ` [PATCH V5 07/13] net/colo: track IOThread references using path-based holder Zhang Chen
2026-03-09 8:44 ` Stefan Hajnoczi
2026-03-10 10:15 ` Zhang Chen
2026-03-12 5:36 ` Stefan Hajnoczi
2026-03-12 6:31 ` Zhang Chen
2026-03-12 7:36 ` Stefan Hajnoczi
2026-03-12 8:45 ` Zhang Chen
2026-03-05 14:24 ` [PATCH V5 08/13] block/export: Update tracking iothread users with holder name Zhang Chen
2026-03-09 8:52 ` Stefan Hajnoczi
2026-03-05 14:24 ` [PATCH V5 09/13] monitor: " Zhang Chen
2026-03-09 8:56 ` Stefan Hajnoczi
2026-03-10 10:24 ` Zhang Chen
2026-03-05 14:24 ` [PATCH V5 10/13] virtio-balloon: " Zhang Chen
2026-03-05 14:24 ` [PATCH V5 11/13] vfio-user/proxy: " Zhang Chen
2026-03-05 14:24 ` [PATCH V5 12/13] xen-block: " Zhang Chen
2026-03-05 14:24 ` [PATCH V5 13/13] qapi: examine IOThread attachment status via query-iothreads Zhang Chen
2026-03-18 6:09 ` Markus Armbruster
2026-03-18 13:25 ` Zhang Chen
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=87jyv9fyn5.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=dave@treblig.org \
--cc=eblake@redhat.com \
--cc=hreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=zhangckid@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.