mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
vhost: enable vrings in vhost_dev_start() for vhost-user devices
Commit02b61f38d3
("hw/virtio: incorporate backend features in features") properly negotiates VHOST_USER_F_PROTOCOL_FEATURES with the vhost-user backend, but we forgot to enable vrings as specified in docs/interop/vhost-user.rst: If ``VHOST_USER_F_PROTOCOL_FEATURES`` has not been negotiated, the ring starts directly in the enabled state. If ``VHOST_USER_F_PROTOCOL_FEATURES`` has been negotiated, the ring is initialized in a disabled state and is enabled by ``VHOST_USER_SET_VRING_ENABLE`` with parameter 1. Some vhost-user front-ends already did this by calling vhost_ops.vhost_set_vring_enable() directly: - backends/cryptodev-vhost.c - hw/net/virtio-net.c - hw/virtio/vhost-user-gpio.c But most didn't do that, so we would leave the vrings disabled and some backends would not work. We observed this issue with the rust version of virtiofsd [1], which uses the event loop [2] provided by the vhost-user-backend crate where requests are not processed if vring is not enabled. Let's fix this issue by enabling the vrings in vhost_dev_start() for vhost-user front-ends that don't already do this directly. Same thing also in vhost_dev_stop() where we disable vrings. [1] https://gitlab.com/virtio-fs/virtiofsd [2]240fc2966/crates/vhost-user-backend/src/event_loop.rs (L217)
Fixes:02b61f38d3
("hw/virtio: incorporate backend features in features") Reported-by: German Maglione <gmaglione@redhat.com> Tested-by: German Maglione <gmaglione@redhat.com> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Acked-by: Raphael Norwitz <raphael.norwitz@nutanix.com> Message-Id: <20221123131630.52020-1-sgarzare@redhat.com> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20221130112439.2527228-3-alex.bennee@linaro.org> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
523e40022f
commit
4daa5054c5
13 changed files with 67 additions and 31 deletions
|
@ -184,24 +184,26 @@ static inline bool vhost_dev_is_started(struct vhost_dev *hdev)
|
|||
* vhost_dev_start() - start the vhost device
|
||||
* @hdev: common vhost_dev structure
|
||||
* @vdev: the VirtIODevice structure
|
||||
* @vrings: true to have vrings enabled in this call
|
||||
*
|
||||
* Starts the vhost device. From this point VirtIO feature negotiation
|
||||
* can start and the device can start processing VirtIO transactions.
|
||||
*
|
||||
* Return: 0 on success, < 0 on error.
|
||||
*/
|
||||
int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev);
|
||||
int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings);
|
||||
|
||||
/**
|
||||
* vhost_dev_stop() - stop the vhost device
|
||||
* @hdev: common vhost_dev structure
|
||||
* @vdev: the VirtIODevice structure
|
||||
* @vrings: true to have vrings disabled in this call
|
||||
*
|
||||
* Stop the vhost device. After the device is stopped the notifiers
|
||||
* can be disabled (@vhost_dev_disable_notifiers) and the device can
|
||||
* be torn down (@vhost_dev_cleanup).
|
||||
*/
|
||||
void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev);
|
||||
void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings);
|
||||
|
||||
/**
|
||||
* DOC: vhost device configuration handling
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue