[PATCH 0/3] vhost: clean up device reset

Stefan Hajnoczi posted 3 patches 7 months, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20230927192737.528280-1-stefanha@redhat.com
Maintainers: Raphael Norwitz <raphael.norwitz@nutanix.com>, "Michael S. Tsirkin" <mst@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Fam Zheng <fam@euphon.net>
There is a newer version of this series
include/hw/virtio/vhost.h |  3 +++
hw/scsi/vhost-user-scsi.c | 20 --------------------
hw/virtio/vhost-backend.c |  6 ------
hw/virtio/vhost-user.c    | 13 +++++++++----
hw/virtio/vhost.c         |  9 +++++++++
hw/virtio/virtio.c        |  4 ++++
6 files changed, 25 insertions(+), 30 deletions(-)
[PATCH 0/3] vhost: clean up device reset
Posted by Stefan Hajnoczi 7 months, 1 week ago
Stateful vhost devices may need to free resources or clear device state upon
device reset. The vhost-user protocol has a VHOST_USER_RESET_DEVICE message for
this and vDPA has SET_STATUS 0, but only QEMU's vhost-user-scsi device actually
implements this today.

This patch series performs device reset across all device types. When
virtio_reset() is called, the associated vhost_dev's ->vhost_reset_device() is
called. vhost-user-scsi's one-off implementation is obsoleted and removed.

This patch affects behavior as follows:
- vhost-kernel: no change in behavior. No ioctl calls are made.
- vhost-user: back-ends that negotiate
  VHOST_USER_PROTOCOL_F_RESET_DEVICE now receive a
  VHOST_USER_DEVICE_RESET message upon device reset. Otherwise there is
  no change in behavior. DPDK, SPDK, libvhost-user, and the
  vhost-user-backend crate do not negotiate
  VHOST_USER_PROTOCOL_F_RESET_DEVICE automatically.
- vhost-vdpa: an extra SET_STATUS 0 call is made during device reset.

I have tested this series with vhost-net (kernel), vhost-user-blk, and
vhost-user-fs (both Rust and legacy C).

Stefan Hajnoczi (3):
  vhost-user: do not send RESET_OWNER on device reset
  vhost-backend: remove vhost_kernel_reset_device()
  virtio: call ->vhost_reset_device() during reset

 include/hw/virtio/vhost.h |  3 +++
 hw/scsi/vhost-user-scsi.c | 20 --------------------
 hw/virtio/vhost-backend.c |  6 ------
 hw/virtio/vhost-user.c    | 13 +++++++++----
 hw/virtio/vhost.c         |  9 +++++++++
 hw/virtio/virtio.c        |  4 ++++
 6 files changed, 25 insertions(+), 30 deletions(-)

-- 
2.41.0
Re: [PATCH 0/3] vhost: clean up device reset
Posted by Michael S. Tsirkin 7 months ago
On Wed, Sep 27, 2023 at 03:27:34PM -0400, Stefan Hajnoczi wrote:
> Stateful vhost devices may need to free resources or clear device state upon
> device reset. The vhost-user protocol has a VHOST_USER_RESET_DEVICE message for
> this and vDPA has SET_STATUS 0, but only QEMU's vhost-user-scsi device actually
> implements this today.
> 
> This patch series performs device reset across all device types. When
> virtio_reset() is called, the associated vhost_dev's ->vhost_reset_device() is
> called. vhost-user-scsi's one-off implementation is obsoleted and removed.
> 
> This patch affects behavior as follows:
> - vhost-kernel: no change in behavior. No ioctl calls are made.
> - vhost-user: back-ends that negotiate
>   VHOST_USER_PROTOCOL_F_RESET_DEVICE now receive a
>   VHOST_USER_DEVICE_RESET message upon device reset. Otherwise there is
>   no change in behavior. DPDK, SPDK, libvhost-user, and the
>   vhost-user-backend crate do not negotiate
>   VHOST_USER_PROTOCOL_F_RESET_DEVICE automatically.
> - vhost-vdpa: an extra SET_STATUS 0 call is made during device reset.
> 
> I have tested this series with vhost-net (kernel), vhost-user-blk, and
> vhost-user-fs (both Rust and legacy C).
> 
> Stefan Hajnoczi (3):
>   vhost-user: do not send RESET_OWNER on device reset
>   vhost-backend: remove vhost_kernel_reset_device()
>   virtio: call ->vhost_reset_device() during reset

Build failure:
https://gitlab.com/mstredhat/qemu/-/jobs/5215049540


>  include/hw/virtio/vhost.h |  3 +++
>  hw/scsi/vhost-user-scsi.c | 20 --------------------
>  hw/virtio/vhost-backend.c |  6 ------
>  hw/virtio/vhost-user.c    | 13 +++++++++----
>  hw/virtio/vhost.c         |  9 +++++++++
>  hw/virtio/virtio.c        |  4 ++++
>  6 files changed, 25 insertions(+), 30 deletions(-)
> 
> -- 
> 2.41.0
Re: [PATCH 0/3] vhost: clean up device reset
Posted by Stefan Hajnoczi 7 months ago
On Tue, 3 Oct 2023 at 17:01, Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Wed, Sep 27, 2023 at 03:27:34PM -0400, Stefan Hajnoczi wrote:
> > Stateful vhost devices may need to free resources or clear device state upon
> > device reset. The vhost-user protocol has a VHOST_USER_RESET_DEVICE message for
> > this and vDPA has SET_STATUS 0, but only QEMU's vhost-user-scsi device actually
> > implements this today.
> >
> > This patch series performs device reset across all device types. When
> > virtio_reset() is called, the associated vhost_dev's ->vhost_reset_device() is
> > called. vhost-user-scsi's one-off implementation is obsoleted and removed.
> >
> > This patch affects behavior as follows:
> > - vhost-kernel: no change in behavior. No ioctl calls are made.
> > - vhost-user: back-ends that negotiate
> >   VHOST_USER_PROTOCOL_F_RESET_DEVICE now receive a
> >   VHOST_USER_DEVICE_RESET message upon device reset. Otherwise there is
> >   no change in behavior. DPDK, SPDK, libvhost-user, and the
> >   vhost-user-backend crate do not negotiate
> >   VHOST_USER_PROTOCOL_F_RESET_DEVICE automatically.
> > - vhost-vdpa: an extra SET_STATUS 0 call is made during device reset.
> >
> > I have tested this series with vhost-net (kernel), vhost-user-blk, and
> > vhost-user-fs (both Rust and legacy C).
> >
> > Stefan Hajnoczi (3):
> >   vhost-user: do not send RESET_OWNER on device reset
> >   vhost-backend: remove vhost_kernel_reset_device()
> >   virtio: call ->vhost_reset_device() during reset
>
> Build failure:
> https://gitlab.com/mstredhat/qemu/-/jobs/5215049540

Sorry about that, will fix.

Stefan

> >  include/hw/virtio/vhost.h |  3 +++
> >  hw/scsi/vhost-user-scsi.c | 20 --------------------
> >  hw/virtio/vhost-backend.c |  6 ------
> >  hw/virtio/vhost-user.c    | 13 +++++++++----
> >  hw/virtio/vhost.c         |  9 +++++++++
> >  hw/virtio/virtio.c        |  4 ++++
> >  6 files changed, 25 insertions(+), 30 deletions(-)
> >
> > --
> > 2.41.0
>
>
Re: [PATCH 0/3] vhost: clean up device reset
Posted by Eugenio Perez Martin 7 months, 1 week ago
On Wed, Sep 27, 2023 at 9:27 PM Stefan Hajnoczi <stefanha@redhat.com> wrote:
>
> Stateful vhost devices may need to free resources or clear device state upon
> device reset. The vhost-user protocol has a VHOST_USER_RESET_DEVICE message for
> this and vDPA has SET_STATUS 0, but only QEMU's vhost-user-scsi device actually
> implements this today.
>
> This patch series performs device reset across all device types. When
> virtio_reset() is called, the associated vhost_dev's ->vhost_reset_device() is
> called. vhost-user-scsi's one-off implementation is obsoleted and removed.
>
> This patch affects behavior as follows:
> - vhost-kernel: no change in behavior. No ioctl calls are made.
> - vhost-user: back-ends that negotiate
>   VHOST_USER_PROTOCOL_F_RESET_DEVICE now receive a
>   VHOST_USER_DEVICE_RESET message upon device reset. Otherwise there is
>   no change in behavior. DPDK, SPDK, libvhost-user, and the
>   vhost-user-backend crate do not negotiate
>   VHOST_USER_PROTOCOL_F_RESET_DEVICE automatically.
> - vhost-vdpa: an extra SET_STATUS 0 call is made during device reset.
>
> I have tested this series with vhost-net (kernel), vhost-user-blk, and
> vhost-user-fs (both Rust and legacy C).
>

Acked-by: Eugenio Pérez <eperezma@redhat.com>

> Stefan Hajnoczi (3):
>   vhost-user: do not send RESET_OWNER on device reset
>   vhost-backend: remove vhost_kernel_reset_device()
>   virtio: call ->vhost_reset_device() during reset
>
>  include/hw/virtio/vhost.h |  3 +++
>  hw/scsi/vhost-user-scsi.c | 20 --------------------
>  hw/virtio/vhost-backend.c |  6 ------
>  hw/virtio/vhost-user.c    | 13 +++++++++----
>  hw/virtio/vhost.c         |  9 +++++++++
>  hw/virtio/virtio.c        |  4 ++++
>  6 files changed, 25 insertions(+), 30 deletions(-)
>
> --
> 2.41.0
>
Re: [PATCH 0/3] vhost: clean up device reset
Posted by Lei Yang 7 months ago
QE tested a regression testing on this series with vhost-vdpa device,
everything is working fine.

Tested-by: Lei Yang <Leiyang@redhat.com>

On Thu, Sep 28, 2023 at 6:40 PM Eugenio Perez Martin
<eperezma@redhat.com> wrote:
>
> On Wed, Sep 27, 2023 at 9:27 PM Stefan Hajnoczi <stefanha@redhat.com> wrote:
> >
> > Stateful vhost devices may need to free resources or clear device state upon
> > device reset. The vhost-user protocol has a VHOST_USER_RESET_DEVICE message for
> > this and vDPA has SET_STATUS 0, but only QEMU's vhost-user-scsi device actually
> > implements this today.
> >
> > This patch series performs device reset across all device types. When
> > virtio_reset() is called, the associated vhost_dev's ->vhost_reset_device() is
> > called. vhost-user-scsi's one-off implementation is obsoleted and removed.
> >
> > This patch affects behavior as follows:
> > - vhost-kernel: no change in behavior. No ioctl calls are made.
> > - vhost-user: back-ends that negotiate
> >   VHOST_USER_PROTOCOL_F_RESET_DEVICE now receive a
> >   VHOST_USER_DEVICE_RESET message upon device reset. Otherwise there is
> >   no change in behavior. DPDK, SPDK, libvhost-user, and the
> >   vhost-user-backend crate do not negotiate
> >   VHOST_USER_PROTOCOL_F_RESET_DEVICE automatically.
> > - vhost-vdpa: an extra SET_STATUS 0 call is made during device reset.
> >
> > I have tested this series with vhost-net (kernel), vhost-user-blk, and
> > vhost-user-fs (both Rust and legacy C).
> >
>
> Acked-by: Eugenio Pérez <eperezma@redhat.com>
>
> > Stefan Hajnoczi (3):
> >   vhost-user: do not send RESET_OWNER on device reset
> >   vhost-backend: remove vhost_kernel_reset_device()
> >   virtio: call ->vhost_reset_device() during reset
> >
> >  include/hw/virtio/vhost.h |  3 +++
> >  hw/scsi/vhost-user-scsi.c | 20 --------------------
> >  hw/virtio/vhost-backend.c |  6 ------
> >  hw/virtio/vhost-user.c    | 13 +++++++++----
> >  hw/virtio/vhost.c         |  9 +++++++++
> >  hw/virtio/virtio.c        |  4 ++++
> >  6 files changed, 25 insertions(+), 30 deletions(-)
> >
> > --
> > 2.41.0
> >
>
>