You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
qemu/hw/scsi
Stefano Garzarella 4daa5054c5 vhost: enable vrings in vhost_dev_start() for vhost-user devices
Commit 02b61f38d3 ("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] https://github.com/rust-vmm/vhost/blob/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>
2 years ago
..
Kconfig build: move vhost-scsi configuration to Kconfig 3 years ago
emulation.c scsi-generic: avoid invalid access to struct when emulating block limits 6 years ago
esp-pci.c pci: Let pci_dma_rw() take MemTxAttrs argument 3 years ago
esp.c Fix several typos in documentation (found by codespell) 2 years ago
lsi53c895a.c scsi: Use device_cold_reset() and bus_cold_reset() 2 years ago
megasas.c scsi: Use device_cold_reset() and bus_cold_reset() 2 years ago
meson.build meson: convert hw/scsi 4 years ago
mfi.h Fix 'writeable' typos 2 years ago
mpi.h hw: Add support for LSI SAS1068 (mptsas) device 9 years ago
mptconfig.c nomaintainer: Fix Lesser GPL version number 4 years ago
mptendian.c nomaintainer: Fix Lesser GPL version number 4 years ago
mptsas.c scsi: Use device_cold_reset() and bus_cold_reset() 2 years ago
mptsas.h mptsas: Remove unused MPTSASState 'pending' field (CVE-2021-3392) 4 years ago
scsi-bus.c virtio-scsi: Send "REPORTED LUNS CHANGED" sense data upon disk hotplug events 2 years ago
scsi-disk.c scsi-disk: support setting CD-ROM block size via device options 2 years ago
scsi-generic.c scsi: Add buf_len parameter to scsi_req_new() 2 years ago
spapr_vscsi.c scsi: Use device_cold_reset() and bus_cold_reset() 2 years ago
srp.h
trace-events scsi-disk: allow MODE SELECT block descriptor to set the block size 2 years ago
trace.h trace: switch position of headers to what Meson requires 4 years ago
vhost-scsi-common.c vhost: enable vrings in vhost_dev_start() for vhost-user devices 2 years ago
vhost-scsi.c vhost: mask VIRTIO_F_RING_RESET for vhost and vhost-user devices 2 years ago
vhost-user-scsi.c vhost: mask VIRTIO_F_RING_RESET for vhost and vhost-user devices 2 years ago
viosrp.h hw/scsi/spapr_vscsi: Do not mix SRP IU size with DMA buffer size 5 years ago
virtio-scsi-dataplane.c virtio-scsi: fix race in virtio_scsi_dataplane_start() 2 years ago
virtio-scsi.c scsi: Use device_cold_reset() and bus_cold_reset() 2 years ago
vmw_pvscsi.c hw/scsi/vmw_pvscsi.c: Use device_cold_reset() to reset SCSI devices 2 years ago
vmw_pvscsi.h