]> git.ipfire.org Git - thirdparty/qemu.git/commit
vhost: fix vhost_dev_enable_notifiers() error case
authorLaurent Vivier <lvivier@redhat.com>
Fri, 2 Jun 2023 16:27:35 +0000 (18:27 +0200)
committerMichael Tokarev <mjt@tls.msk.ru>
Fri, 30 Jun 2023 06:13:00 +0000 (09:13 +0300)
commitce6331222dd74abb8ca9832e0cf011ecb9af7408
treeac3da640d712b1e7d1f6d0a5276cc2f6f2478e83
parent246b0cf1acc1efa9e4171bad72efdf0507cbe73e
vhost: fix vhost_dev_enable_notifiers() error case

in vhost_dev_enable_notifiers(), if virtio_bus_set_host_notifier(true)
fails, we call vhost_dev_disable_notifiers() that executes
virtio_bus_set_host_notifier(false) on all queues, even on queues that
have failed to be initialized.

This triggers a core dump in memory_region_del_eventfd():

 virtio_bus_set_host_notifier: unable to init event notifier: Too many open files (-24)
 vhost VQ 1 notifier binding failed: 24
 .../softmmu/memory.c:2611: memory_region_del_eventfd: Assertion `i != mr->ioeventfd_nb' failed.

Fix the problem by providing to vhost_dev_disable_notifiers() the
number of queues to disable.

Fixes: 8771589b6f81 ("vhost: simplify vhost_dev_enable_notifiers")
Cc: longpeng2@huawei.com
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Message-Id: <20230602162735.3670785-1-lvivier@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
(cherry picked from commit 92099aa4e9a3bb6856c290afaf41c76f9e3dd9fd)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
hw/virtio/vhost.c