From patchwork Mon Nov 7 17:23:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Franciosi X-Patchwork-Id: 692006 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tCK717252z9t2C for ; Tue, 8 Nov 2016 04:24:13 +1100 (AEDT) Received: from localhost ([::1]:55492 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c3neT-0002B3-Fv for incoming@patchwork.ozlabs.org; Mon, 07 Nov 2016 12:24:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43727) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c3ndZ-0001Xc-L1 for qemu-devel@nongnu.org; Mon, 07 Nov 2016 12:23:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c3ndV-0006Mk-23 for qemu-devel@nongnu.org; Mon, 07 Nov 2016 12:23:13 -0500 Received: from 206-15-90-246.static.twtelecom.net ([206.15.90.246]:14036 helo=felipe-franciosi.localdomain) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c3ndU-0006M5-SR for qemu-devel@nongnu.org; Mon, 07 Nov 2016 12:23:08 -0500 Received: by felipe-franciosi.localdomain (Postfix, from userid 500) id 2A08E1001A7; Mon, 7 Nov 2016 09:23:07 -0800 (PST) From: Felipe Franciosi To: Paolo Bonzini , Stefan Hajnoczi , "Michael S. Tsirkin" Date: Mon, 7 Nov 2016 09:23:05 -0800 Message-Id: <1478539385-11249-1-git-send-email-felipe@nutanix.com> X-Mailer: git-send-email 1.9.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 206.15.90.246 Subject: [Qemu-devel] [PATCH] vhost-scsi: Update 'ioeventfd_started' with host notifiers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "qemu-devel@nongnu.org" , Felipe Franciosi Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Following the recent refactor of virtio notfiers [1], more specifically the patch 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. Since vhost-scsi uses the legacy interface, this value is not updated. 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 module 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 --- hw/scsi/vhost-scsi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 5b26946..1c6e6d4 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -95,6 +95,7 @@ static int vhost_scsi_start(VHostSCSI *s) if (ret < 0) { return ret; } + VIRTIO_BUS(qbus)->ioeventfd_started = true; s->dev.acked_features = vdev->guest_features; ret = vhost_dev_start(&s->dev, vdev); @@ -152,6 +153,7 @@ static void vhost_scsi_stop(VHostSCSI *s) vhost_scsi_clear_endpoint(s); vhost_dev_stop(&s->dev, vdev); vhost_dev_disable_notifiers(&s->dev, vdev); + VIRTIO_BUS(qbus)->ioeventfd_started = false; } static uint64_t vhost_scsi_get_features(VirtIODevice *vdev,