On Wed, 16 Nov 2016 19:05:49 +0100
Paolo Bonzini <pbonz...@redhat.com> wrote:

> 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.
> 
> When vhost is stopped and started, however, there is 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 reintroduces (hopefully in a cleaner way) the concept
> that was present with ioeventfd_disabled before the refactoring.
> When ioeventfd_grabbed>0, ioeventfd_started tracks whether ioeventfd
> should be enabled or not, but ioeventfd is actually not started at
> all until vhost releases the host notifiers.
> 
> [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
> 
> Reported-by: Felipe Franciosi <fel...@nutanix.com>
> Reported-by: Christian Borntraeger <borntrae...@de.ibm.com>
> Reported-by: Alex Williamson <alex.william...@redhat.com>
> Fixes: ed08a2a0b ("virtio: use virtio_bus_set_host_notifier to start/stop 
> ioeventfd")
> Signed-off-by: Paolo Bonzini <pbonz...@redhat.com>
> Message-Id: <20161111192855.26350-1-pbonz...@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonz...@redhat.com>
> ---
>         v1->v2: more comments [Cornelia]
> 
>  hw/virtio/vhost.c              | 14 +++++-----
>  hw/virtio/virtio-bus.c         | 58 
> ++++++++++++++++++++++++++++++++++--------
>  hw/virtio/virtio.c             | 16 ++++++++++++
>  include/hw/virtio/virtio-bus.h | 14 ++++++++++
>  include/hw/virtio/virtio.h     |  2 ++
>  5 files changed, 86 insertions(+), 18 deletions(-)

Reviewed-by: Cornelia Huck <cornelia.h...@de.ibm.com>


Reply via email to