[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/3] virtio-net: Only enable userland vq if using tap backend
From: |
Jason Wang |
Subject: |
Re: [PATCH 2/3] virtio-net: Only enable userland vq if using tap backend |
Date: |
Thu, 18 Nov 2021 13:06:25 +0800 |
On Thu, Nov 18, 2021 at 3:29 AM Eugenio Pérez <eperezma@redhat.com> wrote:
>
> Qemu falls back on userland handlers even if vhost-user and vhost-vdpa
> cases. These assumes a tap device can handle the packets.
>
> If a vdpa device fail to start, it can trigger a sigsegv because of
> that. Do not resort on them unless actually possible.
It would be better to show the calltrace here then we can see the root cause.
>
> Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> ---
> include/hw/virtio/virtio.h | 2 ++
> hw/net/virtio-net.c | 4 ++++
> hw/virtio/virtio.c | 21 +++++++++++++--------
> 3 files changed, 19 insertions(+), 8 deletions(-)
>
> diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
> index 8bab9cfb75..1712ba0b4c 100644
> --- a/include/hw/virtio/virtio.h
> +++ b/include/hw/virtio/virtio.h
> @@ -105,6 +105,8 @@ struct VirtIODevice
> VMChangeStateEntry *vmstate;
> char *bus_name;
> uint8_t device_endian;
> + /* backend does not support userspace handler */
> + bool disable_ioeventfd_handler;
> bool use_guest_notifier_mask;
> AddressSpace *dma_as;
> QLIST_HEAD(, VirtQueue) *vector_queues;
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index 004acf858f..8c5c4e5a9d 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -3501,6 +3501,10 @@ static void virtio_net_device_realize(DeviceState
> *dev, Error **errp)
> nc = qemu_get_queue(n->nic);
> nc->rxfilter_notify_enabled = 1;
>
> + if (!nc->peer || nc->peer->info->type != NET_CLIENT_DRIVER_TAP) {
> + /* Only tap can use userspace networking */
> + vdev->disable_ioeventfd_handler = true;
> + }
> if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) {
> struct virtio_net_config netcfg = {};
> memcpy(&netcfg.mac, &n->nic_conf.macaddr, ETH_ALEN);
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index ea7c079fb0..1e04db6650 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -3734,17 +3734,22 @@ static int
> virtio_device_start_ioeventfd_impl(VirtIODevice *vdev)
> err = r;
> goto assign_error;
> }
> - event_notifier_set_handler(&vq->host_notifier,
> - virtio_queue_host_notifier_read);
> +
> + if (!vdev->disable_ioeventfd_handler) {
> + event_notifier_set_handler(&vq->host_notifier,
> + virtio_queue_host_notifier_read);
This is just about not responding to ioeventfd. Does this happen only
when ioeventfd is enabled? If yes, we probably need a consistent way
to deal with that. Will having a dummy receiver be more simpler?
Thanks
> + }
> }
>
> - for (n = 0; n < VIRTIO_QUEUE_MAX; n++) {
> - /* Kick right away to begin processing requests already in vring */
> - VirtQueue *vq = &vdev->vq[n];
> - if (!vq->vring.num) {
> - continue;
> + if (!vdev->disable_ioeventfd_handler) {
> + for (n = 0; n < VIRTIO_QUEUE_MAX; n++) {
> + /* Kick right away to begin processing requests already in vring
> */
> + VirtQueue *vq = &vdev->vq[n];
> + if (!vq->vring.num) {
> + continue;
> + }
> + event_notifier_set(&vq->host_notifier);
> }
> - event_notifier_set(&vq->host_notifier);
> }
> memory_region_transaction_commit();
> return 0;
> --
> 2.27.0
>
- [PATCH 0/3] virtio-net: Only enable userland vq if using tap backend, Eugenio Pérez, 2021/11/17
- [PATCH 1/3] virtio-net: Fix indentation, Eugenio Pérez, 2021/11/17
- [PATCH 2/3] virtio-net: Only enable userland vq if using tap backend, Eugenio Pérez, 2021/11/17
- Re: [PATCH 2/3] virtio-net: Only enable userland vq if using tap backend,
Jason Wang <=
- Re: [PATCH 2/3] virtio-net: Only enable userland vq if using tap backend, Eugenio Perez Martin, 2021/11/18
- Re: [PATCH 2/3] virtio-net: Only enable userland vq if using tap backend, Jason Wang, 2021/11/18
- Re: [PATCH 2/3] virtio-net: Only enable userland vq if using tap backend, Eugenio Perez Martin, 2021/11/19
- Re: [PATCH 2/3] virtio-net: Only enable userland vq if using tap backend, Jason Wang, 2021/11/21
- Re: [PATCH 2/3] virtio-net: Only enable userland vq if using tap backend, Eugenio Perez Martin, 2021/11/22
- Re: [PATCH 2/3] virtio-net: Only enable userland vq if using tap backend, Jason Wang, 2021/11/22
[PATCH 3/3] virtio-net: Fix log message, Eugenio Pérez, 2021/11/17