From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c4rya-0002qm-W1 for qemu-devel@nongnu.org; Thu, 10 Nov 2016 11:13:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c4ryY-0008A9-So for qemu-devel@nongnu.org; Thu, 10 Nov 2016 11:13:20 -0500 Received: from mail.kernel.org ([198.145.29.136]:45344) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c4ryY-00088k-8X for qemu-devel@nongnu.org; Thu, 10 Nov 2016 11:13:18 -0500 Date: Thu, 10 Nov 2016 18:13:13 +0200 From: "Michael S. Tsirkin" Message-ID: <1478794177-29377-18-git-send-email-mst@redhat.com> References: <1478794177-29377-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1478794177-29377-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PULL 17/47] vhost: Update 'ioeventfd_started' with host notifiers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Felipe Franciosi , Christian Borntraeger From: Felipe Franciosi Following the recent refactoring of virtio notifiers [1], more specifically the patch ed08a2a0b ("virtio: use virtio_bus_set_host_notifier to start/stop ioeventfd") that uses virtio_bus_set_host_notifier [2] by default, core virtio code requires 'ioeventfd_started' to be set to true/false when the host notifiers are configured. Because not all vhost devices were update (eg. vhost-scsi) to use the new interface, this value is always set to false. When booting a guest with a vhost-scsi backend controller, SeaBIOS will initially configure the device which sets all notifiers. The guest will continue to boot fine until the kernel virtio-scsi driver reinitialises the device causing a stop followed by another start. Since ioeventfd_started was never set to true, the 'stop' operation triggered by virtio_bus_set_host_notifier() will not result in a call to virtio_pci_ioeventfd_assign(assign=false). This leaves the memory regions with stale notifiers and results on the next start triggering the following assertion: kvm_mem_ioeventfd_add: error adding ioeventfd: File exists Aborted This patch updates ioeventfd_started whenever the notifiers are set or cleared, fixing this issue. Signed-off-by: Felipe Franciosi [1] http://lists.nongnu.org/archive/html/qemu-devel/2016-10/msg07748.html [2] http://lists.nongnu.org/archive/html/qemu-devel/2016-10/msg07760.html Fixes: ed08a2a0b ("virtio: use virtio_bus_set_host_notifier to start/stop ioeventfd") Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Tested-by: Christian Borntraeger --- hw/virtio/vhost.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 131f164..1290963 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1205,6 +1205,7 @@ int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev) goto fail_vq; } } + VIRTIO_BUS(qbus)->ioeventfd_started = true; return 0; fail_vq: @@ -1239,6 +1240,7 @@ void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev) } assert (r >= 0); } + VIRTIO_BUS(qbus)->ioeventfd_started = false; virtio_device_start_ioeventfd(vdev); } -- MST