* How to replace deprecated nbd-server-add by block-export-add
@ 2026-12-03 12:14 Markus Armbruster
2026-12-03 17:06 ` Eric Blake
2026-12-04 13:43 ` Kevin Wolf
0 siblings, 2 replies; 7+ messages in thread
From: Markus Armbruster @ 2026-12-03 12:14 UTC (permalink / raw)
To: qemu-devel; +Cc: Eric Blake, Kevin Wolf, Hanna Czenczek
It's been years since commit 443127e81b9b (nbd: Deprecate
nbd-server-add/remove) went into v5.2.0. I tried to remove it, but
there are speedbumps:
(1) The HMP commands still wrap around the deprecated QMP commands
instead of their replacements or the internal interface.
(2) There are several occurences in docs/.
(3) There are quite a few occurences in tests/qemu-iotests/.
I can take care of (1) on my own, but I'm having difficulties with
replacing nbd-server-add by block-export-add for (2) and (3). Let me
explain.
nbd-server-add's handler qmp_nbd_server_add() wraps around internal
blk_exp_add(), which is basically the same as QMP block-export-add.
Okay.
nbd-server-add takes the following arguments (according to the QEMU QMP
Reference Manual):
* name (string, optional) – Export name. If unspecified, the device
parameter is used as the export name. (Since 2.12)
* description (string, optional) – Free-form description of the export,
up to 4096 bytes. (Since 5.0)
* device (string) – The device name or node name of the node to be
exported
* writable (boolean, optional) – Whether clients should be able to write
to the device via the NBD connection (default false).
* bitmap (string, optional) – Also export a single dirty bitmap
reachable from device, so the NBD client can use
NBD_OPT_SET_META_CONTEXT with the metadata context name
“qemu:dirty-bitmap:BITMAP” to inspect the bitmap (since 4.0).
qmp_nbd_server_add() translates them to blk_exp_add() / block-export-add
like this:
block-export-add nbd-server-add
@type BLOCK_EXPORT_TYPE_NBD
@id @name or else @device
@node-name node name of @device
@writable @writable, possibly downgraded
@bitmaps list containing @bitmap
` @name @name or else @device
@description @description
When replacing an nbd-server-add command by a block_export_type_nbd
command
* "@name or else @device" is not a problem: I pass one or the other to
block_export_type_nbd.
* "@writable, possibly downgraded" is only a minor problem: I need to
take care not to ask for writable when the exported node isn't.
* "node name of @device" is the spicy one:
- If @device is a node name, I need to pass that. Not a problem.
- If @device is a device name, I need to figure out its node name, and
pass that.
· If the thing was created with a user-specified node name, I need
to find the command that created it in the test / the doc example.
Not a problem.
· Else, the node name is something QEMU made up on the spot, such as
"#block158". Problem: I can't predict that name.
Is block-export-add missing a way to specify a device name?
Or is exporting something without a node-name deprecated without
replacement?
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: How to replace deprecated nbd-server-add by block-export-add 2026-12-03 12:14 How to replace deprecated nbd-server-add by block-export-add Markus Armbruster @ 2026-12-03 17:06 ` Eric Blake 2026-12-04 9:31 ` Markus Armbruster 2026-12-04 13:43 ` Kevin Wolf 1 sibling, 1 reply; 7+ messages in thread From: Eric Blake @ 2026-12-03 17:06 UTC (permalink / raw) To: Markus Armbruster; +Cc: qemu-devel, Kevin Wolf, Hanna Czenczek On Thu, Dec 03, 2026 at 01:14:23PM +0100, Markus Armbruster wrote: > It's been years since commit 443127e81b9b (nbd: Deprecate > nbd-server-add/remove) went into v5.2.0. I tried to remove it, but > there are speedbumps: > > (1) The HMP commands still wrap around the deprecated QMP commands > instead of their replacements or the internal interface. > > (2) There are several occurences in docs/. > > (3) There are quite a few occurences in tests/qemu-iotests/. Instances in qemu-iotests are internal, so we should be able to update them without holding up any deprecation action. More telling is whether the out-of-date places in the iotests have been copied and pasted into clients outside of QEMU, where our internal use of old practices is prolonging their external use. > > * "node name of @device" is the spicy one: > > - If @device is a node name, I need to pass that. Not a problem. > > - If @device is a device name, I need to figure out its node name, and > pass that. > > · If the thing was created with a user-specified node name, I need > to find the command that created it in the test / the doc example. > Not a problem. > > · Else, the node name is something QEMU made up on the spot, such as > "#block158". Problem: I can't predict that name. > > Is block-export-add missing a way to specify a device name? Is it possible to see if a given string is a node name, and if not, automatically check if it is a device name? You're right that node names are not always predictable, although we've been encouraging people to use node names rather than rely on generated ones. The generated node names cannot match device names, but I recall that was intentional - the leading # is not valid in a device name, so we gave ourselves a namespace such that any device without a node name is guaranteed that it picks a node name that does not collide; although the choice of names is non-deterministic to avoid reliance on that algorithm. > > Or is exporting something without a node-name deprecated without > replacement? The libvirt folks would need to double check that they have been naming every node, and thus not relying on generated node names. I think another way to word your question is "Have we reached the point where use of generated node names is no longer supported", at which point we can get rid of ALL support for #block158 naming in the code base (a larger cleanup than just nbd-server-add changing to block-export-add). I think we've documented our intentions long enough, that I would be in favor of eliminating support for generated node names. Whether we can do it right away, or still need a couple more releases (but this time with actual warning messages being output any time a name is generated) may depend on what else we can dig up in the way of users that did not create devices with explicit node names. -- Eric Blake, Principal Software Engineer Red Hat, Inc. Virtualization: qemu.org | libguestfs.org ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to replace deprecated nbd-server-add by block-export-add 2026-12-03 17:06 ` Eric Blake @ 2026-12-04 9:31 ` Markus Armbruster 2026-12-04 9:49 ` Markus Armbruster 2026-12-04 13:33 ` Kevin Wolf 0 siblings, 2 replies; 7+ messages in thread From: Markus Armbruster @ 2026-12-04 9:31 UTC (permalink / raw) To: Eric Blake; +Cc: qemu-devel, Kevin Wolf, Hanna Czenczek Eric Blake <eblake@redhat.com> writes: > On Thu, Dec 03, 2026 at 01:14:23PM +0100, Markus Armbruster wrote: >> It's been years since commit 443127e81b9b (nbd: Deprecate >> nbd-server-add/remove) went into v5.2.0. I tried to remove it, but >> there are speedbumps: >> >> (1) The HMP commands still wrap around the deprecated QMP commands >> instead of their replacements or the internal interface. >> >> (2) There are several occurences in docs/. >> >> (3) There are quite a few occurences in tests/qemu-iotests/. > > Instances in qemu-iotests are internal, so we should be able to update > them without holding up any deprecation action. More telling is > whether the out-of-date places in the iotests have been copied and > pasted into clients outside of QEMU, where our internal use of old > practices is prolonging their external use. I started looking into this with a "time to finish the job, should be easy, just collect the garbage" attitude. I've since come to to realize the deprecation was flawed: we left internal uses alone, and because of that didn't realize that converting from the deprecated interface to its proposed replacement is unreasonably hard. I now think the job that needs finishing is the deprecation, and that we probably should restart the grace period once that's done. [...] >> * "node name of @device" is the spicy one: >> >> - If @device is a node name, I need to pass that. Not a problem. >> >> - If @device is a device name, I need to figure out its node name, and >> pass that. >> >> · If the thing was created with a user-specified node name, I need >> to find the command that created it in the test / the doc example. >> Not a problem. >> >> · Else, the node name is something QEMU made up on the spot, such as >> "#block158". Problem: I can't predict that name. >> >> Is block-export-add missing a way to specify a device name? > > Is it possible to see if a given string is a node name, and if not, > automatically check if it is a device name? We do that, but the other way round. We look up nodes by node name with bdrv_find_node(), and block backends by name with blk_by_name(). There's also bdrv_lookup_bs(), which looks up nodes by block backend or node name. It takes two arguments, block backend name @device and node name @node_name. If @device isn't null and blk_by_name(device) succeeds, it returns its node. Else if @node_name isn't null and bdrv_find_node(nodename) succeeds, it returns that. This enables several kinds of interfaces: * Accept both a device and a node name. This is problematic. What if you give both, and they resolve to different nodes? The device name would take precedence. Can't find examples in the schema, but see the next item. * Accept either a device or a node name, but not both. Example: block_resize, blockdev-snapshot-sync. As far as I can tell, these do not enforce "not both". Instead, the device name takes precedence. So this is actually the previous item's problematic interface. * Accept a single name with overloaded meaning, i.e. device or else node name. The parameter is commonly called @node-name, which could perhaps be confusing. Example: drive-backup, blockdev-backup, change-backing-file, block-commit, drive-mirror, blockdev-mirror, block-stream, blockdev-snapshot-internal-sync, blockdev-snapshot-delete-internal-sync, nbd-server-add. * Accept only node name. Example: blockdev-del, blockdev-set-active, block-set-write-threshold, blockdev-insert-medium, block-export-add. * Accept only device name. Can't find examples offhand. Having three kinds is unfortunate. But it is what it is. Changing block-export-add from "accept only node name" to "single name with overloaded meaning" would would take care of the spicy part of nbd-server-add to block-export-add conversion. But is this the interface we want for block-export-add? > You're right that node names are not always predictable, although > we've been encouraging people to use node names rather than rely on > generated ones. The generated node names cannot match device names, > but I recall that was intentional - the leading # is not valid in a > device name, so we gave ourselves a namespace such that any device > without a node name is guaranteed that it picks a node name that does > not collide; although the choice of names is non-deterministic to > avoid reliance on that algorithm. > >> >> Or is exporting something without a node-name deprecated without >> replacement? > > The libvirt folks would need to double check that they have been > naming every node, and thus not relying on generated node names. I > think another way to word your question is "Have we reached the point > where use of generated node names is no longer supported", at which > point we can get rid of ALL support for #block158 naming in the code > base (a larger cleanup than just nbd-server-add changing to > block-export-add). I do not think we have reached this point. -hda, -cdrom, -drive, and so forth still create nodes with generated node names. > I think we've documented our intentions long enough, that I would be > in favor of eliminating support for generated node names. Whether we > can do it right away, or still need a couple more releases (but this > time with actual warning messages being output any time a name is > generated) may depend on what else we can dig up in the way of users > that did not create devices with explicit node names. I don't think we can eliminate now. Even deprecation would take additional work. We'd first have to make -hda and the like create node names, not just device names. And either do the same for -drive, or find a way to deprecate it. If deprecating -drive was easy, we would've done it years ago, I believe. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to replace deprecated nbd-server-add by block-export-add 2026-12-04 9:31 ` Markus Armbruster @ 2026-12-04 9:49 ` Markus Armbruster 2026-12-04 13:33 ` Kevin Wolf 1 sibling, 0 replies; 7+ messages in thread From: Markus Armbruster @ 2026-12-04 9:49 UTC (permalink / raw) To: Eric Blake; +Cc: qemu-devel, Kevin Wolf, Hanna Czenczek Markus Armbruster <armbru@pond.sub.org> writes: [...] > This enables several kinds of interfaces: > > * Accept both a device and a node name. This is problematic. What if > you give both, and they resolve to different nodes? The device name > would take precedence. Can't find examples in the schema, but see the > next item. > > * Accept either a device or a node name, but not both. Example: > block_resize, blockdev-snapshot-sync. As far as I can tell, these do > not enforce "not both". Instead, the device name takes precedence. > So this is actually the previous item's problematic interface. > > * Accept a single name with overloaded meaning, i.e. device or else node > name. The parameter is commonly called @node-name, which could > perhaps be confusing. Example: drive-backup, blockdev-backup, > change-backing-file, block-commit, drive-mirror, blockdev-mirror, > block-stream, blockdev-snapshot-internal-sync, > blockdev-snapshot-delete-internal-sync, nbd-server-add. This is of course also problematic, because the name spaces aren't separate. If you have a block backend named "fred" *and* a node named "fred", you get the block backend's node, not the node. Even though the parameter is called @node-name. Trap for the unwary. > * Accept only node name. Example: blockdev-del, blockdev-set-active, > block-set-write-threshold, blockdev-insert-medium, block-export-add. > > * Accept only device name. Can't find examples offhand. > > Having three kinds is unfortunate. But it is what it is. [...] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to replace deprecated nbd-server-add by block-export-add 2026-12-04 9:31 ` Markus Armbruster 2026-12-04 9:49 ` Markus Armbruster @ 2026-12-04 13:33 ` Kevin Wolf 2026-12-05 7:18 ` Markus Armbruster 1 sibling, 1 reply; 7+ messages in thread From: Kevin Wolf @ 2026-12-04 13:33 UTC (permalink / raw) To: Markus Armbruster; +Cc: Eric Blake, qemu-devel, Hanna Czenczek Am 04.12.2026 um 10:31 hat Markus Armbruster geschrieben: > Eric Blake <eblake@redhat.com> writes: > > > On Thu, Dec 03, 2026 at 01:14:23PM +0100, Markus Armbruster wrote: > >> It's been years since commit 443127e81b9b (nbd: Deprecate > >> nbd-server-add/remove) went into v5.2.0. I tried to remove it, but > >> there are speedbumps: > >> > >> (1) The HMP commands still wrap around the deprecated QMP commands > >> instead of their replacements or the internal interface. > >> > >> (2) There are several occurences in docs/. > >> > >> (3) There are quite a few occurences in tests/qemu-iotests/. > > > > Instances in qemu-iotests are internal, so we should be able to update > > them without holding up any deprecation action. More telling is > > whether the out-of-date places in the iotests have been copied and > > pasted into clients outside of QEMU, where our internal use of old > > practices is prolonging their external use. > > I started looking into this with a "time to finish the job, should be > easy, just collect the garbage" attitude. I've since come to to realize > the deprecation was flawed: we left internal uses alone, and because of > that didn't realize that converting from the deprecated interface to its > proposed replacement is unreasonably hard. I now think the job that > needs finishing is the deprecation, and that we probably should restart > the grace period once that's done. > > [...] > >> * "node name of @device" is the spicy one: > >> > >> - If @device is a node name, I need to pass that. Not a problem. > >> > >> - If @device is a device name, I need to figure out its node name, and > >> pass that. > >> > >> · If the thing was created with a user-specified node name, I need > >> to find the command that created it in the test / the doc example. > >> Not a problem. > >> > >> · Else, the node name is something QEMU made up on the spot, such as > >> "#block158". Problem: I can't predict that name. > >> > >> Is block-export-add missing a way to specify a device name? > > > > Is it possible to see if a given string is a node name, and if not, > > automatically check if it is a device name? It is possible, but no, I definitely don't think we should make an option ambiguous. Other commands that need to accept both a node-name or a device ID just have two separate options. Note that nbd-server-add doesn't actually accept a device (i.e. qdev) ID, but just a BlockBackend name. BlockBackend names shouldn't exist in modern interfaces, it's either node-names if the command operates on the backend or qdev IDs if the command operates on the device. I haven't actually tried it out, but at first sight it seems the semantics of nbd-server-add with a BlockBackend is unexpected: It figures out the root node of the BlockBackend when it runs and then just attaches to that node. If a filter is inserted later or the root node changes (e.g. media change), it doesn't stay on top as you would expect if it were really attached to a BlockBackend, but it sticks to the original root node. So it clearly operates on the node level and I believe only accepting node-names is the right interface. > We do that, but the other way round. > > We look up nodes by node name with bdrv_find_node(), and block backends > by name with blk_by_name(). There's also bdrv_lookup_bs(), which looks > up nodes by block backend or node name. It takes two arguments, block > backend name @device and node name @node_name. If @device isn't null > and blk_by_name(device) succeeds, it returns its node. Else if > @node_name isn't null and bdrv_find_node(nodename) succeeds, it returns > that. Not that blk_by_name() is only non-NULL for BlockBackends created with -drive, so in practice it's irrelevant in most modern configurations. > This enables several kinds of interfaces: > > * Accept both a device and a node name. This is problematic. What if > you give both, and they resolve to different nodes? The device name > would take precedence. Can't find examples in the schema, but see the > next item. > > * Accept either a device or a node name, but not both. Example: > block_resize, blockdev-snapshot-sync. As far as I can tell, these do > not enforce "not both". Instead, the device name takes precedence. > So this is actually the previous item's problematic interface. > > * Accept a single name with overloaded meaning, i.e. device or else node > name. The parameter is commonly called @node-name, which could > perhaps be confusing. Example: drive-backup, blockdev-backup, > change-backing-file, block-commit, drive-mirror, blockdev-mirror, > block-stream, blockdev-snapshot-internal-sync, > blockdev-snapshot-delete-internal-sync, nbd-server-add. > > * Accept only node name. Example: blockdev-del, blockdev-set-active, > block-set-write-threshold, blockdev-insert-medium, block-export-add. > > * Accept only device name. Can't find examples offhand. > > Having three kinds is unfortunate. But it is what it is. > > Changing block-export-add from "accept only node name" to "single name > with overloaded meaning" would would take care of the spicy part of > nbd-server-add to block-export-add conversion. > > But is this the interface we want for block-export-add? Absolutely not. > > You're right that node names are not always predictable, although > > we've been encouraging people to use node names rather than rely on > > generated ones. The generated node names cannot match device names, > > but I recall that was intentional - the leading # is not valid in a > > device name, so we gave ourselves a namespace such that any device > > without a node name is guaranteed that it picks a node name that does > > not collide; although the choice of names is non-deterministic to > > avoid reliance on that algorithm. > > > >> > >> Or is exporting something without a node-name deprecated without > >> replacement? > > > > The libvirt folks would need to double check that they have been > > naming every node, and thus not relying on generated node names. I > > think another way to word your question is "Have we reached the point > > where use of generated node names is no longer supported", at which > > point we can get rid of ALL support for #block158 naming in the code > > base (a larger cleanup than just nbd-server-add changing to > > block-export-add). > > I do not think we have reached this point. -hda, -cdrom, -drive, and so > forth still create nodes with generated node names. Yes, but we also stated that in order to use new QMP interfaces, you have to assign node names, so it's expected that some functionality just isn't accessible with -hda and friends. > > I think we've documented our intentions long enough, that I would be > > in favor of eliminating support for generated node names. Whether we > > can do it right away, or still need a couple more releases (but this > > time with actual warning messages being output any time a name is > > generated) may depend on what else we can dig up in the way of users > > that did not create devices with explicit node names. > > I don't think we can eliminate now. Even deprecation would take > additional work. We'd first have to make -hda and the like create node > names, not just device names. And either do the same for -drive, or > find a way to deprecate it. > > If deprecating -drive was easy, we would've done it years ago, I > believe. It's worse than being hard. We don't even know how to figure out how hard it is. Kevin ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to replace deprecated nbd-server-add by block-export-add 2026-12-04 13:33 ` Kevin Wolf @ 2026-12-05 7:18 ` Markus Armbruster 0 siblings, 0 replies; 7+ messages in thread From: Markus Armbruster @ 2026-12-05 7:18 UTC (permalink / raw) To: Kevin Wolf; +Cc: Markus Armbruster, Eric Blake, qemu-devel, Hanna Czenczek Kevin Wolf <kwolf@redhat.com> writes: > Am 04.12.2026 um 10:31 hat Markus Armbruster geschrieben: >> Eric Blake <eblake@redhat.com> writes: >> >> > On Thu, Dec 03, 2026 at 01:14:23PM +0100, Markus Armbruster wrote: >> >> It's been years since commit 443127e81b9b (nbd: Deprecate >> >> nbd-server-add/remove) went into v5.2.0. I tried to remove it, but >> >> there are speedbumps: >> >> >> >> (1) The HMP commands still wrap around the deprecated QMP commands >> >> instead of their replacements or the internal interface. >> >> >> >> (2) There are several occurences in docs/. >> >> >> >> (3) There are quite a few occurences in tests/qemu-iotests/. >> > >> > Instances in qemu-iotests are internal, so we should be able to update >> > them without holding up any deprecation action. More telling is >> > whether the out-of-date places in the iotests have been copied and >> > pasted into clients outside of QEMU, where our internal use of old >> > practices is prolonging their external use. >> >> I started looking into this with a "time to finish the job, should be >> easy, just collect the garbage" attitude. I've since come to to realize >> the deprecation was flawed: we left internal uses alone, and because of >> that didn't realize that converting from the deprecated interface to its >> proposed replacement is unreasonably hard. I now think the job that >> needs finishing is the deprecation, and that we probably should restart >> the grace period once that's done. >> >> [...] >> >> * "node name of @device" is the spicy one: >> >> >> >> - If @device is a node name, I need to pass that. Not a problem. >> >> >> >> - If @device is a device name, I need to figure out its node name, and >> >> pass that. >> >> >> >> · If the thing was created with a user-specified node name, I need >> >> to find the command that created it in the test / the doc example. >> >> Not a problem. >> >> >> >> · Else, the node name is something QEMU made up on the spot, such as >> >> "#block158". Problem: I can't predict that name. >> >> >> >> Is block-export-add missing a way to specify a device name? >> > >> > Is it possible to see if a given string is a node name, and if not, >> > automatically check if it is a device name? > > It is possible, but no, I definitely don't think we should make an > option ambiguous. Other commands that need to accept both a node-name or > a device ID just have two separate options. Such commands exist, but even more commands take a single option. See [*] below. > Note that nbd-server-add doesn't actually accept a device (i.e. qdev) > ID, but just a BlockBackend name. Yes. but the QAPI schema doc comments still call it device, and the schema name is often @device. Example: # In case @device is a filter node, `block-stream` modifies the first # non-filter overlay node below it to point to the new backing node # instead of modifying @device itself. [...] # @device: the device or node name of the top image qmp_block_stream()'s use of device is bs = bdrv_lookup_bs(device, device, errp); which confirms my reading of "device name" as block backend name. > BlockBackend names shouldn't exist in > modern interfaces, it's either node-names if the command operates on > the backend or qdev IDs if the command operates on the device. Should we deprecate use of block backend names? > I haven't actually tried it out, but at first sight it seems the > semantics of nbd-server-add with a BlockBackend is unexpected: It > figures out the root node of the BlockBackend when it runs and then just > attaches to that node. If a filter is inserted later or the root node > changes (e.g. media change), it doesn't stay on top as you would expect > if it were really attached to a BlockBackend, but it sticks to the > original root node. > > So it clearly operates on the node level and I believe only accepting > node-names is the right interface. > >> We do that, but the other way round. >> >> We look up nodes by node name with bdrv_find_node(), and block backends >> by name with blk_by_name(). There's also bdrv_lookup_bs(), which looks >> up nodes by block backend or node name. It takes two arguments, block >> backend name @device and node name @node_name. If @device isn't null >> and blk_by_name(device) succeeds, it returns its node. Else if >> @node_name isn't null and bdrv_find_node(nodename) succeeds, it returns >> that. > > Not that blk_by_name() is only non-NULL for BlockBackends created with > -drive, so in practice it's irrelevant in most modern configurations. -drive (or its sugar-buddies -hda, -fda, -mtdblock, -sd, ...) is still *required* to configure onboard devices. These create a block backend (and its block node(s)) and ask board code to create the onboard frontend and connect it to the backend. What's the recommended way to configure onboard devices so that node-name only interfaces work for the backend's block node? If there is none, then the "most" in "most modern configurations" does a lot of work ;) More on this below. >> This enables several kinds of interfaces: >> >> * Accept both a device and a node name. This is problematic. What if >> you give both, and they resolve to different nodes? The device name >> would take precedence. Can't find examples in the schema, but see the >> next item. >> >> * Accept either a device or a node name, but not both. Example: >> block_resize, blockdev-snapshot-sync. As far as I can tell, these do >> not enforce "not both". Instead, the device name takes precedence. >> So this is actually the previous item's problematic interface. >> >> * Accept a single name with overloaded meaning, i.e. device or else node >> name. The parameter is commonly called @node-name, which could >> perhaps be confusing. Example: drive-backup, blockdev-backup, >> change-backing-file, block-commit, drive-mirror, blockdev-mirror, >> block-stream, blockdev-snapshot-internal-sync, >> blockdev-snapshot-delete-internal-sync, nbd-server-add. [*] Ten commands that take a single option vs. five that take two (next list item). >> * Accept only node name. Example: blockdev-del, blockdev-set-active, >> block-set-write-threshold, blockdev-insert-medium, block-export-add. >> >> * Accept only device name. Can't find examples offhand. I made this list based on a relatively quick reading of the QAPI schema. Its use of "device" for both block backends and device frontends might confuse me, so let's look for calls bdrv_lookup_bs(NAME, NAME, ...) in the code: blockdev.c:1047: bs = bdrv_lookup_bs(name, name, errp); This is qmp_get_root_bs(), called from qmp_blockdev_snapshot_delete_internal_sync(), internal_snapshot_action() on behalf of qmp_blockdev_snapshot_internal_sync(), qmp_block_commit(), qmp_change_backing_file(), blockdev.c:1470: bdrv_lookup_bs(snapshot_node_name, snapshot_node_name, NULL)) { external_snapshot_action() on behalf of qmp_blockdev_snapshot_sync(), blockdev.c:1683: bs = bdrv_lookup_bs(backup->device, backup->device, errp); drive_backup_action() on behalf of qmp_drive_backup(), blockdev.c:1857: bs = bdrv_lookup_bs(backup->device, backup->device, errp); blockdev.c:1862: target_bs = bdrv_lookup_bs(backup->target, backup->target, errp); blockdev_backup_action() on behalf of qmp_blockdev_backup(). blockdev.c:2400: bs = bdrv_lookup_bs(device, device, errp); qmp_block_stream(), blockdev.c:2547: bs = bdrv_lookup_bs(device, device, NULL); qmp_block_commit(), blockdev.c:2991: bs = bdrv_lookup_bs(arg->device, arg->device, errp); qmp_drive_mirror(), blockdev.c:3160: bs = bdrv_lookup_bs(device, device, errp); blockdev.c:3172: target_bs = bdrv_lookup_bs(target, target, errp); qmp_blockdev_mirror(), blockdev.c:3608: parent_bs = bdrv_lookup_bs(parent, parent, errp); qmp_x_blockdev_change(), block/replication.c:408: top_bs = bdrv_lookup_bs(s->top_id, s->top_id, NULL); block/replication.c:570: top_bs = bdrv_lookup_bs(s->top_id, s->top_id, NULL); backup_job_cleanup() and replication_start() on behalf of blockdev-add with driver "replication", block/monitor/bitmap-qmp-cmds.c:71: bs = bdrv_lookup_bs(node, node, NULL); block_dirty_bitmap_lookup() on behalf of something, but I can't be bothered to follow the threads right now, and block/monitor/bitmap-qmp-cmds.c:104: bs = bdrv_lookup_bs(node, node, errp); qmp_block_dirty_bitmap_add(). So it's even more than I found in the QAPI schema. >> Having three kinds is unfortunate. But it is what it is. >> >> Changing block-export-add from "accept only node name" to "single name >> with overloaded meaning" would would take care of the spicy part of >> nbd-server-add to block-export-add conversion. >> >> But is this the interface we want for block-export-add? > > Absolutely not. Confirms my doubts. What about the existing interfaces of this kind? Should we deprecate the use of block backend names there? bdrv_lookup_bs(name, name, errp) now: If name isn't null and blk_by_name(name) succeeds: return its node else if name isn't null and bdrv_find_node(name) succeeds: return that Maybe use logic like blk = blk_by_name(name) if name else null node = bdrv_find_node(name) if name else null if blk and blk != node: deprecated! if blk: return blk's node return node >> > You're right that node names are not always predictable, although >> > we've been encouraging people to use node names rather than rely on >> > generated ones. The generated node names cannot match device names, >> > but I recall that was intentional - the leading # is not valid in a >> > device name, so we gave ourselves a namespace such that any device >> > without a node name is guaranteed that it picks a node name that does >> > not collide; although the choice of names is non-deterministic to >> > avoid reliance on that algorithm. >> > >> >> >> >> Or is exporting something without a node-name deprecated without >> >> replacement? >> > >> > The libvirt folks would need to double check that they have been >> > naming every node, and thus not relying on generated node names. I >> > think another way to word your question is "Have we reached the point >> > where use of generated node names is no longer supported", at which >> > point we can get rid of ALL support for #block158 naming in the code >> > base (a larger cleanup than just nbd-server-add changing to >> > block-export-add). >> >> I do not think we have reached this point. -hda, -cdrom, -drive, and so >> forth still create nodes with generated node names. > > Yes, but we also stated that in order to use new QMP interfaces, you > have to assign node names, so it's expected that some functionality just > isn't accessible with -hda and friends. Yes, but is it expected and acceptable that functionality that used to be accessible ceases to be? Is it okay that QMP block-export-add can't work with nodes created with -hda and friends, but HMP nbd_server_add still can? We normally demand that HMP wraps around QMP. This doesn't. Delete the functionaility there, too? -hda and friends create block backends with well-known names. For instance: $ qemu-system-x86_64 -S -nodefaults -display none -monitor stdio -hda tmp.qcow2 QEMU 11.1.92 monitor - type 'help' for more information (qemu) info block ide0-hd0 (#block173): tmp.qcow2 (qcow2) Attached to: /machine/unattached/device[4] Cache mode: writeback Backing file: tmp.img (chain depth: 1) This created a block backend named "ide-hd0" and a block node named "#block173". The former is a fixed, well-known name, the latter is unstable. Any particular reason why the latter cannot or should not be a fixed, well-known name? >> > I think we've documented our intentions long enough, that I would be >> > in favor of eliminating support for generated node names. Whether we >> > can do it right away, or still need a couple more releases (but this >> > time with actual warning messages being output any time a name is >> > generated) may depend on what else we can dig up in the way of users >> > that did not create devices with explicit node names. >> >> I don't think we can eliminate now. Even deprecation would take >> additional work. We'd first have to make -hda and the like create node >> names, not just device names. And either do the same for -drive, or >> find a way to deprecate it. >> >> If deprecating -drive was easy, we would've done it years ago, I >> believe. > > It's worse than being hard. We don't even know how to figure out how > hard it is. > > Kevin ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to replace deprecated nbd-server-add by block-export-add 2026-12-03 12:14 How to replace deprecated nbd-server-add by block-export-add Markus Armbruster 2026-12-03 17:06 ` Eric Blake @ 2026-12-04 13:43 ` Kevin Wolf 1 sibling, 0 replies; 7+ messages in thread From: Kevin Wolf @ 2026-12-04 13:43 UTC (permalink / raw) To: Markus Armbruster; +Cc: qemu-devel, Eric Blake, Hanna Czenczek Am 03.12.2026 um 13:14 hat Markus Armbruster geschrieben: > When replacing an nbd-server-add command by a block_export_type_nbd > command > [...] > * "node name of @device" is the spicy one: > > - If @device is a node name, I need to pass that. Not a problem. > > - If @device is a device name, I need to figure out its node name, and > pass that. > > · If the thing was created with a user-specified node name, I need > to find the command that created it in the test / the doc example. > Not a problem. > > · Else, the node name is something QEMU made up on the spot, such as > "#block158". Problem: I can't predict that name. > > Is block-export-add missing a way to specify a device name? > > Or is exporting something without a node-name deprecated without > replacement? Just setting a node-name is the easiest way, I don't think there is ever a reason not to do this. (It would also be a nice opportunity to stop using -drive, except maybe in test cases explicitly testing -drive, but that makes the change a bit bigger.) If you insist on using BlockBackend names only when creating the VM, it's a bit more involved, but 'query-block' can tell you the node name of a given BlockBackend even if it's automatically generated, and then you can use that. Kevin ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-12-05 7:19 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-12-03 12:14 How to replace deprecated nbd-server-add by block-export-add Markus Armbruster 2026-12-03 17:06 ` Eric Blake 2026-12-04 9:31 ` Markus Armbruster 2026-12-04 9:49 ` Markus Armbruster 2026-12-04 13:33 ` Kevin Wolf 2026-12-05 7:18 ` Markus Armbruster 2026-12-04 13:43 ` Kevin Wolf
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.