Discussion of the VIRTIO specification
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: "Richard W.M. Jones" <rjones@redhat.com>
Cc: virtio-comment@lists.linux.dev
Subject: Re: [PATCH 1/1] device-types/blk/description.tex: Allow longer device IDs to be returned
Date: Mon, 7 Sep 2026 03:33:28 -0400	[thread overview]
Message-ID: <20260907032412-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20260906160625.GJ1436@redhat.com>

On Sun, Sep 06, 2026 at 05:06:25PM +0100, Richard W.M. Jones wrote:
> On Sun, Sep 06, 2026 at 11:13:39AM -0400, Michael S. Tsirkin wrote:
> > On Sun, Sep 06, 2026 at 03:54:44PM +0100, Richard W.M. Jones wrote:
> [...]
> > U also want a feature bit otherwise driver does not know if it's safe to
> > send VIRTIO_BLK_T_GET_LONG_ID.
> 
> Interestingly (at least for Linux) sending VIRTIO_BLK_T_GET_LONG_ID
> when the hypervisor doesn't support it returns -EOPNOTSUPP, but I can
> add a feature bit as well.
> 
> > >  \end{lstlisting}
> > >  
> > >  The \field{flags} bitfield is ignored by the device unless
> > > @@ -515,9 +516,26 @@ \subsection{Device Operation}\label{sec:Device Types / Block Device / Device Ope
> > >  the device to discard the specified range, provided that following reads return
> > >  zeroes.
> > >  
> > > -VIRTIO_BLK_T_GET_ID requests fetch the device ID string from the device into
> > > -\field{data}.  The device ID string is a NUL-padded ASCII string up to 20 bytes
> > > -long.  If the string is 20 bytes long then there is no NUL terminator.
> > > +VIRTIO_BLK_T_GET_ID or VIRTIO_BLK_T_GET_LONG_ID requests fetch the
> > > +device ID string from the device into \field{data}.  The device ID
> > > +string is an ASCII string which can be up to 247 bytes long.
> > > +
> > > +VIRTIO_BLK_T_GET_ID fetches the first 20 bytes of the device ID
> > > +string.  If the ID is shorter than 20 bytes, then the response is
> > > +padded with NUL bytes so its length is 20 bytes.  (Note that if the ID
> > > +is 20 bytes or longer, this means the response will not be NUL
> > > +terminated.)
> > > +
> > > +VIRTIO_BLK_T_GET_LONG_ID fetches the complete device ID string.  The
> > > +response is always 248 bytes long, padded to this length with NUL
> > > +bytes.  Since the longest permitted device ID string is 247 bytes, the
> > > +response MUST be NUL terminated.
> > 
> > That's a lot of padding) Sure u do not want to use the actual length?
> 
> I'm not too clear on this (and the spec is also unclear), but it seems
> the buffer is allocated in the guest RAM?



Yes. But the driver specifies the length to the device.
So do we need a new type of request? We could just
change the length depending on a feature bit.


>  In that case since it
> doesn't know the length in advance it must allocate a fixed size buffer.
> 
> [...]

That's certainly the simplest way to do it, so that's what the spec
does:

The length of \field{data} MUST be 20 bytes for VIRTIO_BLK_T_GET_ID requests.




> > > +(non-truncated) device ID.  In this case a guest which has not opted
> > 
> > avoid "guest"
> 
> Is "driver" preferred?


yes

> I'll send a follow up addressing your other points, but probably not today.
> 
> Rich.

I have some more comments from reading more about it.

> -- 
> Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
> Read my programming and virtualization blog: http://rwmj.wordpress.com
> nbdkit - Flexible, fast NBD server with plugins
> https://gitlab.com/nbdkit/nbdkit


  reply	other threads:[~2026-09-07  7:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-06 14:54 [PATCH 0/1] [PATCH] device-types/blk/description.tex: Allow longer device IDs to be returned Richard W.M. Jones
2026-09-06 14:54 ` [PATCH 1/1] " Richard W.M. Jones
2026-09-06 15:13   ` Michael S. Tsirkin
2026-09-06 16:06     ` Richard W.M. Jones
2026-09-07  7:33       ` Michael S. Tsirkin [this message]
2026-09-07  7:56   ` Michael S. Tsirkin
2026-09-07 14:02     ` Richard W.M. Jones
2026-09-07 19:27       ` Michael S. Tsirkin
2026-09-08  9:35         ` Richard W.M. Jones
2026-09-08 10:06           ` Michael S. Tsirkin
2026-09-08 10:43             ` Richard W.M. Jones
2026-09-08 10:57               ` Michael S. Tsirkin

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=20260907032412-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=rjones@redhat.com \
    --cc=virtio-comment@lists.linux.dev \
    /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