vhost-vsock: set vhostfd to non-blocking mode
commit384c2561bddfa00cd3eaf9edbc1af6c7c120511f
authorStefano Garzarella <sgarzare@redhat.com>
Thu, 29 Oct 2020 14:48:49 +0000 (29 15:48 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Fri, 30 Oct 2020 08:29:13 +0000 (30 04:29 -0400)
tree6fcafd9ac0c4202e1d5877072f1f8b6bdf631465
parent9aa47edd4ee69fa0628c5f9adb52d5050a5bce6a
vhost-vsock: set vhostfd to non-blocking mode

vhost IOTLB API uses read()/write() to exchange iotlb messages with
the kernel module.
The QEMU implementation expects a non-blocking fd, indeed commit
c471ad0e9b ("vhost_net: device IOTLB support") set it for vhost-net.

Without this patch, if we enable iommu for the vhost-vsock device,
QEMU can hang when exchanging IOTLB messages.

As commit 894022e616 ("net: check if the file descriptor is valid
before using it") did for tap, let's use qemu_try_set_nonblock()
when fd is provided by the user.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Message-Id: <20201029144849.70958-1-sgarzare@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw/virtio/vhost-vsock.c