[PATCH v2 0/2] virtio: Always reset vhost devices

Hanna Czenczek posted 2 patches 1 month, 2 weeks ago
include/hw/virtio/virtio.h  |  1 +
hw/display/vhost-user-gpu.c |  2 +-
hw/net/virtio-net.c         | 19 +++++++++++++++++--
hw/virtio/virtio-crypto.c   | 18 +++++++++++++++---
hw/virtio/virtio.c          |  8 ++++++--
5 files changed, 40 insertions(+), 8 deletions(-)
[PATCH v2 0/2] virtio: Always reset vhost devices
Posted by Hanna Czenczek 1 month, 2 weeks ago
Hi,

As explained in patch 2 (the main one) of this series, we currently
don’t issue the RESET_DEVICE command to vhost back-ends, even though we
fully intend to do so.

The problem is that sending this command is gated behind a vhost_started
check, but at that point (during the device reset process), the device
is actually stopped, and so vhost_started is false.  We still want to
send RESET_DEVICE there, so patch 2 removes the vhost_started condition.

This means that we need to be able to call VirtioDeviceClass.get_vhost()
when vhost_started is false.  For most .get_vhost() implementations,
that’s perfectly fine; but three of them (crypto, gpu, net) dereference
some pointers, so if any of them is NULL, we have to explicitly return
NULL in those implementations.  That’s what patch 1 is for.


This time, I’ve run `make check` with ubsan; I can confirm that v1
generated errors for vhost-net, but with patch 1 added, it’s clean.
I’ve also run the CI pipeline:
https://gitlab.com/hreitz/qemu/-/pipelines/1384524949
Specifically, clang-system passed:
https://gitlab.com/hreitz/qemu/-/jobs/7406688234
The only failure is msys2-64bit, which timed out (re-tried repeatedly),
but judging from https://gitlab.com/qemu-project/qemu/-/pipelines, I
think that’s expected.


v2: Added patch 1, left patch 2 unchanged.


Hanna Czenczek (2):
  virtio: Allow .get_vhost() without vhost_started
  virtio: Always reset vhost devices

 include/hw/virtio/virtio.h  |  1 +
 hw/display/vhost-user-gpu.c |  2 +-
 hw/net/virtio-net.c         | 19 +++++++++++++++++--
 hw/virtio/virtio-crypto.c   | 18 +++++++++++++++---
 hw/virtio/virtio.c          |  8 ++++++--
 5 files changed, 40 insertions(+), 8 deletions(-)

-- 
2.45.2