From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel <qemu-devel@nongnu.org>, Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [Qemu-devel] [RFC v2 06/12] vhost-user: add vhost_user_input_get_config()
Date: Mon, 4 Jun 2018 10:59:17 +0100 [thread overview]
Message-ID: <20180604095917.GA2628@work-vm> (raw)
In-Reply-To: <CAMxuvayhQPPkFbFUE+Onbe7=AEnVuJ3+dFkDiuQyLA2F0tmW_w@mail.gmail.com>
* Marc-André Lureau (marcandre.lureau@redhat.com) wrote:
> Hi
>
> On Mon, Jun 4, 2018 at 11:07 AM, Dr. David Alan Gilbert
> <dgilbert@redhat.com> wrote:
> > * Marc-André Lureau (marcandre.lureau@redhat.com) wrote:
> >> Ask vhost user input backend the list of virtio_input_config.
> >
> > Why is this vhost-user specific; shouldn't the vhost-input
> > behaviour be the same irrespective of if it's vhost-user or plain vhost?
> >
>
> A similar message could be used for plain vhost, in some ioctl form.
> Here we are documenting vhost-user protocol only.
The vhost-user protocol seems to be mostly independent of the device
it's carrying; for example I see there's a 'net_set_mtu' and 'send_rarp'
but I don't think there's anything for disk storage; what are the cases
whether these have to be done through a change to the vhost-user
protocol as opposed to stuff carried over it?
Dave
>
> Thanks
>
> > Dave
> >
> >
> >> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> >> ---
> >> include/hw/virtio/vhost-backend.h | 4 +++
> >> hw/virtio/vhost-user.c | 59 +++++++++++++++++++++++++++++++
> >> docs/interop/vhost-user.txt | 6 ++++
> >> 3 files changed, 69 insertions(+)
> >>
> >> diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h
> >> index 5dac61f9ea..6cc2edacc5 100644
> >> --- a/include/hw/virtio/vhost-backend.h
> >> +++ b/include/hw/virtio/vhost-backend.h
> >> @@ -12,6 +12,7 @@
> >> #define VHOST_BACKEND_H
> >>
> >> #include "exec/memory.h"
> >> +#include "standard-headers/linux/virtio_input.h"
> >>
> >> typedef enum VhostBackendType {
> >> VHOST_BACKEND_TYPE_NONE = 0,
> >> @@ -156,4 +157,7 @@ int vhost_backend_invalidate_device_iotlb(struct vhost_dev *dev,
> >> int vhost_backend_handle_iotlb_msg(struct vhost_dev *dev,
> >> struct vhost_iotlb_msg *imsg);
> >>
> >> +int vhost_user_input_get_config(struct vhost_dev *dev,
> >> + struct virtio_input_config **config);
> >> +
> >> #endif /* VHOST_BACKEND_H */
> >> diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
> >> index a87db01e55..19ed87d07c 100644
> >> --- a/hw/virtio/vhost-user.c
> >> +++ b/hw/virtio/vhost-user.c
> >> @@ -84,6 +84,7 @@ typedef enum VhostUserRequest {
> >> VHOST_USER_POSTCOPY_ADVISE = 28,
> >> VHOST_USER_POSTCOPY_LISTEN = 29,
> >> VHOST_USER_POSTCOPY_END = 30,
> >> + VHOST_USER_INPUT_GET_CONFIG,
> >> VHOST_USER_MAX
> >> } VhostUserRequest;
> >>
> >> @@ -324,6 +325,64 @@ static int vhost_user_write(struct vhost_dev *dev, VhostUserMsg *msg,
> >> return 0;
> >> }
> >>
> >> +static void *vhost_user_read_size(struct vhost_dev *dev, uint32_t size)
> >> +{
> >> + struct vhost_user *u = dev->opaque;
> >> + CharBackend *chr = u->chr;
> >> + int r;
> >> + uint8_t *p = g_malloc(size);
> >> +
> >> + r = qemu_chr_fe_read_all(chr, p, size);
> >> + if (r != size) {
> >> + error_report("Failed to read msg payload."
> >> + " Read %d instead of %d.", r, size);
> >> + return NULL;
> >> + }
> >> +
> >> + return p;
> >> +}
> >> +
> >> +int vhost_user_input_get_config(struct vhost_dev *dev,
> >> + struct virtio_input_config **config)
> >> +{
> >> + void *p = NULL;
> >> + VhostUserMsg msg = {
> >> + .hdr.request = VHOST_USER_INPUT_GET_CONFIG,
> >> + .hdr.flags = VHOST_USER_VERSION,
> >> + };
> >> +
> >> + if (vhost_user_write(dev, &msg, NULL, 0) < 0) {
> >> + goto err;
> >> + }
> >> +
> >> + if (vhost_user_read_header(dev, &msg) < 0) {
> >> + goto err;
> >> + }
> >> +
> >> + p = vhost_user_read_size(dev, msg.hdr.size);
> >> + if (!p) {
> >> + goto err;
> >> + }
> >> +
> >> + if (msg.hdr.request != VHOST_USER_INPUT_GET_CONFIG) {
> >> + error_report("Received unexpected msg type. Expected %d received %d",
> >> + VHOST_USER_INPUT_GET_CONFIG, msg.hdr.request);
> >> + goto err;
> >> + }
> >> +
> >> + if (msg.hdr.size % sizeof(struct virtio_input_config)) {
> >> + error_report("Invalid msg size");
> >> + goto err;
> >> + }
> >> +
> >> + *config = p;
> >> + return msg.hdr.size / sizeof(struct virtio_input_config);
> >> +
> >> +err:
> >> + g_free(p);
> >> + return -1;
> >> +}
> >> +
> >> static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base,
> >> struct vhost_log *log)
> >> {
> >> diff --git a/docs/interop/vhost-user.txt b/docs/interop/vhost-user.txt
> >> index 534caab18a..3df9927386 100644
> >> --- a/docs/interop/vhost-user.txt
> >> +++ b/docs/interop/vhost-user.txt
> >> @@ -744,6 +744,12 @@ Master message types
> >> was previously sent.
> >> The value returned is an error indication; 0 is success.
> >>
> >> + * VHOST_USER_INPUT_GET_CONFIG
> >> +
> >> + Slave payload: (struct virtio_input_config)*
> >> +
> >> + Ask vhost user input backend the list of virtio_input_config.
> >> +
> >> Slave message types
> >> -------------------
> >>
> >> --
> >> 2.17.1.906.g10fd178552
> >>
> >>
> > --
> > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2018-06-04 9:59 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-01 16:27 [Qemu-devel] [RFC v2 00/12] vhost-user for input & GPU Marc-André Lureau
2018-06-01 16:27 ` [Qemu-devel] [RFC v2 01/12] chardev: avoid crash if no associated address Marc-André Lureau
2018-06-08 14:52 ` Philippe Mathieu-Daudé
2018-06-11 8:59 ` Daniel P. Berrangé
2018-06-11 9:04 ` Daniel P. Berrangé
2018-06-01 16:27 ` [Qemu-devel] [RFC v2 02/12] libvhost-user: exit by default on VHOST_USER_NONE Marc-André Lureau
2018-06-08 14:48 ` Philippe Mathieu-Daudé
2018-06-01 16:27 ` [Qemu-devel] [RFC v2 03/12] vhost-user: wrap some read/write with retry handling Marc-André Lureau
2018-06-08 14:53 ` Philippe Mathieu-Daudé
2018-06-01 16:27 ` [Qemu-devel] [RFC v2 04/12] Add vhost-user-backend Marc-André Lureau
2018-06-04 9:36 ` Daniel P. Berrangé
2018-06-07 22:34 ` Marc-André Lureau
2018-06-08 8:43 ` Daniel P. Berrangé
2018-06-12 14:53 ` Marc-André Lureau
2018-06-12 15:08 ` Daniel P. Berrangé
2018-06-01 16:27 ` [Qemu-devel] [RFC v2 05/12] vhost-user: split vhost_user_read() Marc-André Lureau
2018-06-08 14:57 ` Philippe Mathieu-Daudé
2018-06-12 14:58 ` Marc-André Lureau
2018-06-01 16:27 ` [Qemu-devel] [RFC v2 06/12] vhost-user: add vhost_user_input_get_config() Marc-André Lureau
2018-06-04 9:07 ` Dr. David Alan Gilbert
2018-06-04 9:18 ` Marc-André Lureau
2018-06-04 9:59 ` Dr. David Alan Gilbert [this message]
2018-06-12 12:46 ` Marc-André Lureau
2018-06-01 16:27 ` [Qemu-devel] [RFC v2 07/12] libvhost-user: export vug_source_new Marc-André Lureau
2018-06-01 16:27 ` [Qemu-devel] [RFC v2 08/12] contrib: add vhost-user-input Marc-André Lureau
2018-06-01 16:27 ` [Qemu-devel] [RFC v2 09/12] Add vhost-input-pci Marc-André Lureau
2018-06-04 8:58 ` Gerd Hoffmann
2018-06-07 22:22 ` Marc-André Lureau
2018-06-08 5:41 ` Gerd Hoffmann
2018-06-01 16:27 ` [Qemu-devel] [RFC v2 10/12] vhost-user: add vhost_user_gpu_set_socket() Marc-André Lureau
2018-06-04 9:28 ` Gerd Hoffmann
2018-06-01 16:27 ` [Qemu-devel] [RFC v2 11/12] Add virtio-gpu vhost-user backend Marc-André Lureau
2018-06-04 9:37 ` Gerd Hoffmann
2018-06-08 17:25 ` Marc-André Lureau
2018-06-09 1:02 ` Marc-André Lureau
2018-06-11 6:49 ` Gerd Hoffmann
2018-06-01 16:27 ` [Qemu-devel] [RFC v2 12/12] contrib: add vhost-user-gpu Marc-André Lureau
2018-06-01 17:28 ` [Qemu-devel] [RFC v2 00/12] vhost-user for input & GPU no-reply
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=20180604095917.GA2628@work-vm \
--to=dgilbert@redhat.com \
--cc=kraxel@redhat.com \
--cc=marcandre.lureau@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).