All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@pond.sub.org>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org,  Kevin Wolf <kwolf@redhat.com>,
	 Hanna Czenczek <hreitz@redhat.com>
Subject: Re: How to replace deprecated nbd-server-add by block-export-add
Date: Fri, 04 Dec 2026 10:31:37 +0100	[thread overview]
Message-ID: <87ik198k92.fsf@pond.sub.org> (raw)
In-Reply-To: <axGc9JNQ27ey9Ddq@redhat.com> (Eric Blake's message of "Thu, 3 Dec 2026 11:06:44 -0600")

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.


  reply	other threads:[~2026-12-04  9:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=87ik198k92.fsf@pond.sub.org \
    --to=armbru@pond.sub.org \
    --cc=eblake@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --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 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.