qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [RFC] libvhost-user: implement VHOST_USER_PROTOCOL_F_KICK_CALL_MSGS
Date: Mon, 09 Sep 2019 17:26:13 +0200	[thread overview]
Message-ID: <49378faefb98abafb64ff105a7941c47395426e7.camel@sipsolutions.net> (raw)
In-Reply-To: <20190909105057-mutt-send-email-mst@kernel.org>

On Mon, 2019-09-09 at 10:59 -0400, Michael S. Tsirkin wrote:

> > > Next command is GET_FEATURES. Return an error response from that
> > > and device init will fail.
> > 
> > Hmm, what's an error here though? You can only return a value, no?
> 
> Either returning id that does not match GET_FEATURES or
> returning size != 8 bytes will work.

Hmm, right.

> Using 0 size payload has precedent in VHOST_USER_GET_CONFIG:
> 	vhost-user slave uses zero length of
> 	  payload to indicate an error to vhost-user master.

OK, I think zero-len makes sense, that's certainly something that must
be checked by the receiver already.

> It's annoying that we don't get an error indicator in that case though.
> Worth returning e.g. a 4 byte code?

That also would need to be checked by the receiver, but

1) Then we have to start defining an error code enum, as there's no
   natural space. Is that worth it for what's basically a corner case?
2) It'd also be annoying that we now have a 4-byte error code, but with
   F_REPLY_ACK / need_reply you get an 8-byte status code, which would
   be incompatible in a way.

> And let's generalize for all other messages with response?

We could theoretically have a message in the future that wants a 4-byte
response, though by convention basically everything uses u64 anyway ...

OTOH, 0-byte as error doesn't generalize, VHOST_USER_POSTCOPY_ADVISE has
only a file descriptor as slave payload AFAICT... But then possibly in
those cases the master also wouldn't check the response size at all,
since it never uses it. Qemu does though, and is probably the currently
relevant implementation? Our UML implementation doesn't use this.


Maybe instead we should just add a "VHOST_USER_REPLY_ERROR" bit (e.g.
bit 4 after NEED_REPLY). Qemu in vhost_user_read_header() validates that
it received REPLY_MASK | VERSION, so it would reject the message at that
point.

Another possibility would be to define the highest bit of the 'request'
field to indicate an error, so for GET_FEATURES we'd return the value
0x80000000 | GET_FEATURES.

For even more safety we could make a 4-byte response which is never
valid for anything right now, but it feels overly cautious given that we
currently do check both the request and flag fields. If you think a
response status is needed and want to define an enum with possible
values, then I'd probably prefer an 8-byte status since that's the way
everything works now, but I don't really care much either way.

johannes



  reply	other threads:[~2019-09-09 15:27 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-02 12:12 [Qemu-devel] [RFC] vhost-user simulation extension Johannes Berg
2019-09-02 12:12 ` [Qemu-devel] [RFC] docs: vhost-user: add in-band kick/call messages Johannes Berg
2019-09-05 20:28   ` Johannes Berg
2019-09-09 16:00     ` Stefan Hajnoczi
2019-09-09 17:34       ` Johannes Berg
2019-09-10 15:03         ` Stefan Hajnoczi
2019-09-10 15:14           ` Johannes Berg
2019-09-10 15:33             ` Michael S. Tsirkin
2019-09-10 15:34               ` Johannes Berg
2019-09-11  6:56                 ` Stefan Hajnoczi
2019-09-11  7:35             ` Stefan Hajnoczi
2019-09-11  8:26               ` Johannes Berg
2019-09-11 15:17                 ` Stefan Hajnoczi
2019-09-11 15:31   ` Stefan Hajnoczi
2019-09-11 15:36     ` Johannes Berg
2019-09-11 15:38       ` Johannes Berg
2019-09-12 12:22       ` Stefan Hajnoczi
2019-09-12 20:37         ` Johannes Berg
2019-09-06 12:13 ` [Qemu-devel] [RFC] libvhost-user: implement VHOST_USER_PROTOCOL_F_KICK_CALL_MSGS Johannes Berg
2019-09-06 14:22   ` Michael S. Tsirkin
2019-09-06 14:48     ` Johannes Berg
2019-09-06 15:12       ` Michael S. Tsirkin
2019-09-06 15:32         ` Johannes Berg
2019-09-08 13:13           ` Michael S. Tsirkin
2019-09-09 11:35             ` Johannes Berg
2019-09-09 12:41               ` Michael S. Tsirkin
2019-09-09 13:05                 ` Johannes Berg
2019-09-09 13:48                   ` Michael S. Tsirkin
2019-09-09 13:50                     ` Johannes Berg
2019-09-09 14:59                       ` Michael S. Tsirkin
2019-09-09 15:26                         ` Johannes Berg [this message]
2019-09-09 15:34                           ` Johannes Berg
2019-09-09 15:45                             ` Michael S. Tsirkin
2019-09-09 15:47                               ` Johannes Berg
2019-09-10 15:52                       ` Johannes Berg
2019-09-11  9:16                         ` Michael S. Tsirkin
2019-09-11  9:20                           ` Johannes Berg
2019-09-11  9:54                             ` 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=49378faefb98abafb64ff105a7941c47395426e7.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=mst@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 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).