vhost_net: fix assertion triggered by batch of host notifiers processing
authorzuoboqun <zuoboqun@baidu.com>
Fri, 15 Nov 2024 08:03:12 +0000 (16:03 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 26 Nov 2024 21:35:51 +0000 (16:35 -0500)
commit16f6804c460109e8b126cc710a0072f9f83bd230
tree6080d7e57063f72a32d407fea7ebe0950157d3db
parent34754a3a627e1937be7f3daaa0c5e73d91c7d9b5
vhost_net: fix assertion triggered by batch of host notifiers processing

When the backend of vhost_net restarts during the vm is running, vhost_net
is stopped and started. The virtio_device_grab_ioeventfd() fucntion in
vhost_net_enable_notifiers() will result in a call to
virtio_bus_set_host_notifier()(assign=false).

And now virtio_device_grab_ioeventfd() is batched in a single transaction
with virtio_bus_set_host_notifier()(assign=true).

This triggers the following assertion:

kvm_mem_ioeventfd_del: error deleting ioeventfd: Bad file descriptor

This patch moves virtio_device_grab_ioeventfd() out of the batch to fix
this problem.

To be noted that the for loop to release ioeventfd should start from i+1,
not i, because the i-th ioeventfd has already been released in
vhost_dev_disable_notifiers_nvqs().

Fixes: 6166799f6 ("vhost_net: configure all host notifiers in a single MR transaction")
Signed-off-by: Zuo Boqun <zuoboqun@baidu.com>
Reported-by: Gao Shiyuan <gaoshiyuan@baidu.com>
Message-Id: <20241115080312.3184-1-zuoboqun@baidu.com>
Acked-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw/net/vhost_net.c