From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59430) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZyaWU-0002l7-OY for qemu-devel@nongnu.org; Tue, 17 Nov 2015 02:17:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZyaWN-0008IV-IS for qemu-devel@nongnu.org; Tue, 17 Nov 2015 02:17:50 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:28818) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZyaWN-0008Hz-Cf for qemu-devel@nongnu.org; Tue, 17 Nov 2015 02:17:43 -0500 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NXY003IY6XE7V60@mailout2.w1.samsung.com> for qemu-devel@nongnu.org; Tue, 17 Nov 2015 07:17:38 +0000 (GMT) From: Pavel Fedin Date: Tue, 17 Nov 2015 10:17:37 +0300 Message-id: <00f401d12108$09faee70$1df0cb50$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit Content-language: ru Subject: [Qemu-devel] [PATCH v2] vhost: Fix aborting if KVM does not support eventfds List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: 'Christian Borntraeger' , "'Michael S. Tsirkin'" If you happen to have a stock kernel of old version, like 3.x, and you attempt to enable vhost by setting vhost=on, qemu aborts with error: kvm_mem_ioeventfd_add: error adding ioeventfd: Function not implemented This patch adds capability check, so that vhost gets disabled instead. A warning is displayed, explaining the reason: 2015-11-13T08:43:51.146802Z qemu-system-aarch64: KVM does not support eventfd binding 2015-11-13T08:43:51.146915Z qemu-system-aarch64: unable to start vhost net: 38: falling back on userspace virtio This problem can be observed with libvirt, which checks for /dev/vhost-net availability and just inserts "vhost=on" automatically in this case. Signed-off-by: Pavel Fedin --- v1 => v2: - Removed "MMIO" from warning message, because it applies not only to MMIO - Add note about warning to the commit message --- hw/virtio/vhost.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 1794f0d..50b8171 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -24,6 +24,7 @@ #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h" #include "migration/migration.h" +#include "sysemu/kvm.h" static struct vhost_log *vhost_log; static struct vhost_log *vhost_log_shm; @@ -1083,6 +1084,11 @@ int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev) r = -ENOSYS; goto fail; } + if (!kvm_eventfds_enabled()) { + error_report("KVM does not support eventfd binding"); + r = -ENOSYS; + goto fail; + } for (i = 0; i < hdev->nvqs; ++i) { r = k->set_host_notifier(qbus->parent, hdev->vq_index + i, true); -- 1.9.5.msysgit.0