From: "Michael S. Tsirkin" <mst@redhat.com>
To: Didier Pallard <didier.pallard@6wind.com>
Cc: thibaut.collet@6wind.com, jmg@6wind.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 3/3] vhost-net: force guest_notifier_mask bypass in vhost-user case
Date: Thu, 4 Feb 2016 15:06:37 +0200 [thread overview]
Message-ID: <20160204150403-mutt-send-email-mst@redhat.com> (raw)
In-Reply-To: <1449136399-4158-4-git-send-email-didier.pallard@6wind.com>
On Thu, Dec 03, 2015 at 10:53:19AM +0100, Didier Pallard wrote:
> Since guest_mask_notifier can not be used in vhost-user
> mode due to buffering implied by unix control socket,
> force VIRTIO_PCI_FLAG_USE_NOTIFIERMASK on virtio pci
> of vhost-user interfaces, and send correct callfd
> to the guest at vhost start.
>
> Signed-off-by: Didier Pallard <didier.pallard@6wind.com>
> Reviewed-by: Thibaut Collet <thibaut.collet@6wind.com>
I queued this now so we have a bugfix, but I think we
should clean this up using a property and avoid
depending on virtio pci.
> ---
> hw/net/vhost_net.c | 19 ++++++++++++++++++-
> hw/virtio/vhost.c | 13 +++++++++++++
> 2 files changed, 31 insertions(+), 1 deletion(-)
>
> diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
> index 318c3e6..74318dc 100644
> --- a/hw/net/vhost_net.c
> +++ b/hw/net/vhost_net.c
> @@ -36,9 +36,11 @@
> #include <stdio.h>
>
> #include "standard-headers/linux/virtio_ring.h"
> +#include "hw/pci/pci.h"
> #include "hw/virtio/vhost.h"
> #include "hw/virtio/virtio-bus.h"
> #include "hw/virtio/virtio-access.h"
> +#include "hw/virtio/virtio-pci.h"
>
> struct vhost_net {
> struct vhost_dev dev;
> @@ -314,7 +316,22 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
> }
>
> for (i = 0; i < total_queues; i++) {
> - vhost_net_set_vq_index(get_vhost_net(ncs[i].peer), i * 2);
> + struct vhost_net *net= get_vhost_net(ncs[i].peer);
> + vhost_net_set_vq_index(net, i * 2);
> +
> + /* Force VIRTIO_PCI_FLAG_USE_NOTIFIERMASK reset in vhost user case
> + * Must be done before set_guest_notifier call
> + */
> + if (net->nc->info->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER) {
> + BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(dev)));
> + DeviceState *d = DEVICE(qbus->parent);
> + if (!strcmp(object_get_typename(OBJECT(d)), TYPE_VIRTIO_NET_PCI)) {
> + VirtIOPCIProxy *proxy = VIRTIO_PCI(d);
> +
> + /* Force proxy to not use mask notifier */
> + proxy->flags &= ~VIRTIO_PCI_FLAG_USE_NOTIFIERMASK;
> + }
> + }
> }
>
> r = k->set_guest_notifiers(qbus->parent, total_queues * 2, true);
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index de29968..7a4c1d3 100644
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -854,8 +854,21 @@ static int vhost_virtqueue_start(struct vhost_dev *dev,
> /* Clear and discard previous events if any. */
> event_notifier_test_and_clear(&vq->masked_notifier);
>
> + /* If vhost user, register now the call eventfd, guest_notifier_mask
> + * function is not used anymore
> + */
> + if (dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER) {
> + file.fd = event_notifier_get_fd(virtio_queue_get_guest_notifier(vvq));
> + r = dev->vhost_ops->vhost_set_vring_call(dev, &file);
> + if (r) {
> + r = -errno;
> + goto fail_call;
> + }
> + }
> +
> return 0;
>
> +fail_call:
> fail_kick:
> fail_alloc:
> cpu_physical_memory_unmap(vq->ring, virtio_queue_get_ring_size(vdev, idx),
> --
> 2.1.4
>
next prev parent reply other threads:[~2016-02-04 13:06 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-03 9:53 [Qemu-devel] Linux vhost-user interrupt management fixes Didier Pallard
2015-12-03 9:53 ` [Qemu-devel] [PATCH 1/3] char: fix vhost-user socket full Didier Pallard
2015-12-07 13:31 ` Marc-André Lureau
2015-12-09 15:59 ` Victor Kaplansky
2015-12-09 17:06 ` Didier Pallard
2015-12-10 12:56 ` Victor Kaplansky
2015-12-10 15:09 ` Didier Pallard
2015-12-17 14:41 ` Victor Kaplansky
2016-02-04 13:13 ` Michael S. Tsirkin
2016-02-04 14:10 ` Michael S. Tsirkin
2016-02-08 13:12 ` Didier Pallard
2016-02-09 11:37 ` Michael S. Tsirkin
2016-02-09 11:48 ` Daniel P. Berrange
2016-02-09 12:21 ` Michael S. Tsirkin
2016-02-09 16:17 ` Didier Pallard
2016-02-09 16:50 ` Michael S. Tsirkin
2016-02-09 17:04 ` Daniel P. Berrange
2016-02-10 9:35 ` Didier Pallard
2016-02-10 11:53 ` Michael S. Tsirkin
2016-02-10 12:15 ` Daniel P. Berrange
2016-02-19 9:09 ` Didier Pallard
2015-12-03 9:53 ` [Qemu-devel] [PATCH 2/3] virtio-pci: add an option to bypass guest_notifier_mask Didier Pallard
2015-12-07 13:37 ` Marc-André Lureau
2015-12-07 13:59 ` Marc-André Lureau
2015-12-09 15:06 ` Didier Pallard
2016-02-04 13:08 ` Michael S. Tsirkin
2016-02-08 13:24 ` Didier Pallard
2016-02-15 15:38 ` Victor Kaplansky
2015-12-03 9:53 ` [Qemu-devel] [PATCH 3/3] vhost-net: force guest_notifier_mask bypass in vhost-user case Didier Pallard
2016-02-04 13:06 ` Michael S. Tsirkin [this message]
2015-12-04 10:04 ` [Qemu-devel] Linux vhost-user interrupt management fixes Didier Pallard
2016-01-25 9:22 ` Victor Kaplansky
2016-01-26 9:25 ` Didier Pallard
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=20160204150403-mutt-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=didier.pallard@6wind.com \
--cc=jmg@6wind.com \
--cc=qemu-devel@nongnu.org \
--cc=thibaut.collet@6wind.com \
/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).