On Thu, Nov 18, 2021 at 3:29 AM Eugenio Pérez <epere...@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 <epere...@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 >