The vhost-user protocol is not really Linux-specific so let's enable vhost-user frontends for any POSIX system.
vhost_net.c uses VHOST_FILE_UNBIND, which is defined in a Linux specific header. The kernel's VHOST_NET_SET_BACKEND documentation asks to pass fd -1 to unbind, so replace the macro with -1 and drop the include, nothing else in the file needs it. Long-term a constant could be introduced and used for it. Co-authored-by: Stefano Garzarella <[email protected]> Signed-off-by: Tim Pambor <[email protected]> --- Changes in v2: - Replaced VHOST_FILE_UNBIND with -1 and dropped the include --- hw/block/Kconfig | 2 +- hw/net/vhost_net.c | 3 +-- meson.build | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/block/Kconfig b/hw/block/Kconfig index 737dbcdb3e..7edcd7a8f6 100644 --- a/hw/block/Kconfig +++ b/hw/block/Kconfig @@ -28,7 +28,7 @@ config VHOST_USER_BLK bool # Only PCI devices are provided for now default y if VIRTIO_PCI - depends on VIRTIO && VHOST_USER && LINUX + depends on VIRTIO && VHOST_USER config SWIM bool diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 6e05c995f1..d0f1014ce1 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -33,7 +33,6 @@ #include "standard-headers/linux/virtio_ring.h" #include "hw/virtio/vhost.h" #include "hw/virtio/virtio-bus.h" -#include "linux-headers/linux/vhost.h" void vhost_net_get_features_ex(struct vhost_net *net, uint64_t *features) { @@ -681,7 +680,7 @@ err_start: error_report("Error when restarting the queue."); if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) { - file.fd = VHOST_FILE_UNBIND; + file.fd = -1; file.index = idx; int ret = vhost_net_set_backend(&net->dev, &file); assert(ret >= 0); diff --git a/meson.build b/meson.build index b67a97ab45..eb296346a8 100644 --- a/meson.build +++ b/meson.build @@ -221,7 +221,6 @@ have_tpm = get_option('tpm') \ # vhost have_vhost_user = get_option('vhost_user') \ - .disable_auto_if(host_os != 'linux') \ .require(host_os != 'windows', error_message: 'vhost-user is not available on Windows').allowed() have_vhost_vdpa = get_option('vhost_vdpa') \ -- 2.55.0
