[Qemu-commits] [qemu/qemu] 523e40: tests/qtests: override "force-legacy" for gpio vir...

2022-12-04 Thread Paolo Bonzini via Qemu-commits
  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 523e40022fc9522bb6bc13e4ce9eb4d1613ab5dc
  
https://github.com/qemu/qemu/commit/523e40022fc9522bb6bc13e4ce9eb4d1613ab5dc
  Author: Alex Bennée 
  Date:   2022-12-01 (Thu, 01 Dec 2022)

  Changed paths:
M tests/qtest/libqos/virtio-gpio.c

  Log Message:
  ---
  tests/qtests: override "force-legacy" for gpio virtio-mmio tests

The GPIO device is a VIRTIO_F_VERSION_1 devices but running with a
legacy MMIO interface we miss out that feature bit causing confusion.
For the GPIO test force the mmio bus to support non-legacy so we can
properly test it.

Signed-off-by: Alex Bennée 
Reviewed-by: Michael S. Tsirkin 
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1333
Message-Id: <20221130112439.2527228-2-alex.ben...@linaro.org>
Acked-by: Thomas Huth 
Signed-off-by: Michael S. Tsirkin 


  Commit: 4daa5054c599c8aec70f1264a01341a15921c145
  
https://github.com/qemu/qemu/commit/4daa5054c599c8aec70f1264a01341a15921c145
  Author: Stefano Garzarella 
  Date:   2022-12-01 (Thu, 01 Dec 2022)

  Changed paths:
M backends/cryptodev-vhost.c
M backends/vhost-user.c
M hw/block/vhost-user-blk.c
M hw/net/vhost_net.c
M hw/scsi/vhost-scsi-common.c
M hw/virtio/trace-events
M hw/virtio/vhost-user-fs.c
M hw/virtio/vhost-user-gpio.c
M hw/virtio/vhost-user-i2c.c
M hw/virtio/vhost-user-rng.c
M hw/virtio/vhost-vsock-common.c
M hw/virtio/vhost.c
M include/hw/virtio/vhost.h

  Log Message:
  ---
  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 
Tested-by: German Maglione 
Signed-off-by: Stefano Garzarella 
Acked-by: Raphael Norwitz 
Message-Id: <20221123131630.52020-1-sgarz...@redhat.com>
Signed-off-by: Alex Bennée 
Reviewed-by: Michael S. Tsirkin 
Message-Id: <20221130112439.2527228-3-alex.ben...@linaro.org>
Signed-off-by: Michael S. Tsirkin 


  Commit: 060f4a944072ecf37cece0f16a0609babfb679b8
  
https://github.com/qemu/qemu/commit/060f4a944072ecf37cece0f16a0609babfb679b8
  Author: Alex Bennée 
  Date:   2022-12-01 (Thu, 01 Dec 2022)

  Changed paths:
M hw/virtio/vhost-user-gpio.c
M include/hw/virtio/vhost-user-gpio.h

  Log Message:
  ---
  hw/virtio: add started_vu status field to vhost-user-gpio

As per the fix to vhost-user-blk in f5b22d06fb (vhost: recheck dev
state in the vhost_migration_log routine) we really should track the
connection and starting separately.

Signed-off-by: Alex Bennée 
Reviewed-by: Michael S. Tsirkin 
Message-Id: <20221130112439.2527228-4-alex.ben...@linaro.org>
Signed-off-by: Michael S. Tsirkin 


  Commit: 71e076a07dc195129fe25d90d4b276be3b2f12d8
  
https://github.com/qemu/qemu/commit/71e076a07dc195129fe25d90d4b276be3b2f12d8
  Author: Alex Bennée 
  Date:   2022-12-01 (Thu, 01 Dec 2022)

  Changed paths:
M hw/block/vhost-user-blk.c
M hw/virtio/vhost-user-gpio.c
M hw/virtio/vhost-user.c
M include/hw/virtio/vhost-user.h

  Log Message:
  ---
  hw/virtio: generalise CHR_EVENT_CLOSED handling

..and use for both virtio-user-blk and virtio-user-gpio. This avoids
the circular close by deferring shutdown due to disconnection until a
later point. virtio-user-blk already had this mechanism in place so
generalise it as a vhost-user helper function and use for both blk and
gpio devices.

While we are at it we also fix up vhost-user-gpio to re-establish the
event handler after close down so we can reconnect later.

Signed-off-by: Alex Bennée 
Reviewed-by: Michael S. Tsirkin 

[Qemu-commits] [qemu/qemu] 523e40: tests/qtests: override "force-legacy" for gpio vir...

2022-12-04 Thread Paolo Bonzini via Qemu-commits
  Branch: refs/heads/staging
  Home:   https://github.com/qemu/qemu
  Commit: 523e40022fc9522bb6bc13e4ce9eb4d1613ab5dc
  
https://github.com/qemu/qemu/commit/523e40022fc9522bb6bc13e4ce9eb4d1613ab5dc
  Author: Alex Bennée 
  Date:   2022-12-01 (Thu, 01 Dec 2022)

  Changed paths:
M tests/qtest/libqos/virtio-gpio.c

  Log Message:
  ---
  tests/qtests: override "force-legacy" for gpio virtio-mmio tests

The GPIO device is a VIRTIO_F_VERSION_1 devices but running with a
legacy MMIO interface we miss out that feature bit causing confusion.
For the GPIO test force the mmio bus to support non-legacy so we can
properly test it.

Signed-off-by: Alex Bennée 
Reviewed-by: Michael S. Tsirkin 
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1333
Message-Id: <20221130112439.2527228-2-alex.ben...@linaro.org>
Acked-by: Thomas Huth 
Signed-off-by: Michael S. Tsirkin 


  Commit: 4daa5054c599c8aec70f1264a01341a15921c145
  
https://github.com/qemu/qemu/commit/4daa5054c599c8aec70f1264a01341a15921c145
  Author: Stefano Garzarella 
  Date:   2022-12-01 (Thu, 01 Dec 2022)

  Changed paths:
M backends/cryptodev-vhost.c
M backends/vhost-user.c
M hw/block/vhost-user-blk.c
M hw/net/vhost_net.c
M hw/scsi/vhost-scsi-common.c
M hw/virtio/trace-events
M hw/virtio/vhost-user-fs.c
M hw/virtio/vhost-user-gpio.c
M hw/virtio/vhost-user-i2c.c
M hw/virtio/vhost-user-rng.c
M hw/virtio/vhost-vsock-common.c
M hw/virtio/vhost.c
M include/hw/virtio/vhost.h

  Log Message:
  ---
  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 
Tested-by: German Maglione 
Signed-off-by: Stefano Garzarella 
Acked-by: Raphael Norwitz 
Message-Id: <20221123131630.52020-1-sgarz...@redhat.com>
Signed-off-by: Alex Bennée 
Reviewed-by: Michael S. Tsirkin 
Message-Id: <20221130112439.2527228-3-alex.ben...@linaro.org>
Signed-off-by: Michael S. Tsirkin 


  Commit: 060f4a944072ecf37cece0f16a0609babfb679b8
  
https://github.com/qemu/qemu/commit/060f4a944072ecf37cece0f16a0609babfb679b8
  Author: Alex Bennée 
  Date:   2022-12-01 (Thu, 01 Dec 2022)

  Changed paths:
M hw/virtio/vhost-user-gpio.c
M include/hw/virtio/vhost-user-gpio.h

  Log Message:
  ---
  hw/virtio: add started_vu status field to vhost-user-gpio

As per the fix to vhost-user-blk in f5b22d06fb (vhost: recheck dev
state in the vhost_migration_log routine) we really should track the
connection and starting separately.

Signed-off-by: Alex Bennée 
Reviewed-by: Michael S. Tsirkin 
Message-Id: <20221130112439.2527228-4-alex.ben...@linaro.org>
Signed-off-by: Michael S. Tsirkin 


  Commit: 71e076a07dc195129fe25d90d4b276be3b2f12d8
  
https://github.com/qemu/qemu/commit/71e076a07dc195129fe25d90d4b276be3b2f12d8
  Author: Alex Bennée 
  Date:   2022-12-01 (Thu, 01 Dec 2022)

  Changed paths:
M hw/block/vhost-user-blk.c
M hw/virtio/vhost-user-gpio.c
M hw/virtio/vhost-user.c
M include/hw/virtio/vhost-user.h

  Log Message:
  ---
  hw/virtio: generalise CHR_EVENT_CLOSED handling

..and use for both virtio-user-blk and virtio-user-gpio. This avoids
the circular close by deferring shutdown due to disconnection until a
later point. virtio-user-blk already had this mechanism in place so
generalise it as a vhost-user helper function and use for both blk and
gpio devices.

While we are at it we also fix up vhost-user-gpio to re-establish the
event handler after close down so we can reconnect later.

Signed-off-by: Alex Bennée 
Reviewed-by: Michael S. Tsirkin