public inbox for virtio-fs@lists.linux.dev
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Alexandr Moshkov <dtalexundeer@yandex-team.ru>
Cc: qemu-devel@nongnu.org, "Raphael Norwitz" <rnorwitz@nvidia.com>,
	virtio-fs@lists.linux.dev, "Milan Zamazal" <mzamazal@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"zhenwei pi" <zhenwei.pi@linux.dev>,
	"Gonglei (Arei)" <arei.gonglei@huawei.com>,
	"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
	"Kevin Wolf" <kwolf@redhat.com>,
	"Hanna Reitz" <hreitz@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Stefano Garzarella" <sgarzare@redhat.com>,
	"Fam Zheng" <fam@euphon.net>,
	qemu-block@nongnu.org
Subject: Re: [PATCH 2/4] vhost-user: add skip_drain param to GET_VRING_BASE
Date: Mon, 2 Mar 2026 07:34:06 +0800	[thread overview]
Message-ID: <20260301233406.GA8465@fedora> (raw)
In-Reply-To: <20260224075055.863068-3-dtalexundeer@yandex-team.ru>

[-- Attachment #1: Type: text/plain, Size: 14028 bytes --]

On Tue, Feb 24, 2026 at 12:50:53PM +0500, Alexandr Moshkov wrote:
> In case of migration of QEMU from the new version (where the
> inllight-migration parameter is present), to the old one (where it is
> absent) there is no way to disable this feature on the backend during
> runtime.
> 
> This commit slightly changes the semantics of the protocol feature
> VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT. Enabling this feature
> adds a new parameter for GET_VRING_BASE, which allows to control the
> drain in-flight requests on the backend.
> Thus, QEMU will be able to turn this feature on GET_VRING_BASE off and
> on anytime.
> 
> Signed-off-by: Alexandr Moshkov <dtalexundeer@yandex-team.ru>
> ---
>  backends/cryptodev-vhost.c     |  2 +-
>  backends/vhost-user.c          |  2 +-
>  docs/interop/vhost-user.rst    |  3 ++-
>  hw/block/vhost-user-blk.c      |  2 +-
>  hw/net/vhost_net.c             |  9 +++++----
>  hw/scsi/vhost-scsi-common.c    |  2 +-
>  hw/virtio/vdpa-dev.c           |  2 +-
>  hw/virtio/vhost-user-base.c    |  2 +-
>  hw/virtio/vhost-user-fs.c      |  2 +-
>  hw/virtio/vhost-user-scmi.c    |  2 +-
>  hw/virtio/vhost-vsock-common.c |  2 +-
>  hw/virtio/vhost.c              | 24 +++++++++++++++---------
>  include/hw/virtio/vhost.h      |  7 +++++--
>  13 files changed, 36 insertions(+), 25 deletions(-)
> 
> diff --git a/backends/cryptodev-vhost.c b/backends/cryptodev-vhost.c
> index 943680a23a..7a457380d0 100644
> --- a/backends/cryptodev-vhost.c
> +++ b/backends/cryptodev-vhost.c
> @@ -110,7 +110,7 @@ static void
>  cryptodev_vhost_stop_one(CryptoDevBackendVhost *crypto,
>                                   VirtIODevice *dev)
>  {
> -    vhost_dev_stop(&crypto->dev, dev, false);
> +    vhost_dev_stop(&crypto->dev, dev, false, false);
>      vhost_dev_disable_notifiers(&crypto->dev, dev);
>  }
>  
> diff --git a/backends/vhost-user.c b/backends/vhost-user.c
> index 42845329e7..10be713ebd 100644
> --- a/backends/vhost-user.c
> +++ b/backends/vhost-user.c
> @@ -108,7 +108,7 @@ vhost_user_backend_stop(VhostUserBackend *b)
>          return 0;
>      }
>  
> -    ret = vhost_dev_stop(&b->dev, b->vdev, true);
> +    ret = vhost_dev_stop(&b->dev, b->vdev, true, false);
>  
>      if (k->set_guest_notifiers &&
>          k->set_guest_notifiers(qbus->parent, b->dev.nvqs, false) < 0) {
> diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst
> index bfa75ff9a3..5b944322b4 100644
> --- a/docs/interop/vhost-user.rst
> +++ b/docs/interop/vhost-user.rst
> @@ -1262,7 +1262,8 @@ Front-end message types
>    specified vring before stopping it.
>  
>    If the ``VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT`` protocol
> -  feature has been negotiated, the back-end may suspend in-flight I/O
> +  feature has been negotiated, using request payload's *num* field,
> +  when num is set to 1, QEMU can tell the back-end to suspend in-flight I/O

This changes the behavior of an existing feature bit. How can the
front-end detect that the back-end supports this new behavior?

>    requests and record them as described in :ref:`Inflight I/O tracking
>    <inflight_io_tracking>` instead of completing them before stopping the vring.
>    How to suspend an in-flight request depends on the implementation of the back-end
> diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
> index c151e83677..7f2067d6cf 100644
> --- a/hw/block/vhost-user-blk.c
> +++ b/hw/block/vhost-user-blk.c
> @@ -225,7 +225,7 @@ static int vhost_user_blk_stop(VirtIODevice *vdev)
>                   qemu_force_shutdown_requested();
>  
>      ret = force_stop ? vhost_dev_force_stop(&s->dev, vdev, true) :
> -                       vhost_dev_stop(&s->dev, vdev, true);
> +                       vhost_dev_stop(&s->dev, vdev, true, false);
>  
>      if (k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false) < 0) {
>          error_report("vhost guest notifier cleanup failed: %d", ret);
> diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
> index a8ee18a912..604f19e03a 100644
> --- a/hw/net/vhost_net.c
> +++ b/hw/net/vhost_net.c
> @@ -384,7 +384,7 @@ fail:
>      if (net->nc->info->poll) {
>          net->nc->info->poll(net->nc, true);
>      }
> -    vhost_dev_stop(&net->dev, dev, false);
> +    vhost_dev_stop(&net->dev, dev, false, false);
>  fail_start:
>      return r;
>  }
> @@ -403,7 +403,7 @@ static void vhost_net_stop_one(struct vhost_net *net,
>      if (net->nc->info->poll) {
>          net->nc->info->poll(net->nc, true);
>      }
> -    vhost_dev_stop(&net->dev, dev, false);
> +    vhost_dev_stop(&net->dev, dev, false, false);
>      if (net->nc->info->stop) {
>          net->nc->info->stop(net->nc);
>      }
> @@ -641,7 +641,8 @@ void vhost_net_virtqueue_reset(VirtIODevice *vdev, NetClientState *nc,
>      vhost_virtqueue_stop(&net->dev,
>                           vdev,
>                           net->dev.vqs + idx,
> -                         net->dev.vq_index + idx);
> +                         net->dev.vq_index + idx,
> +                         false);
>  }
>  
>  int vhost_net_virtqueue_restart(VirtIODevice *vdev, NetClientState *nc,
> @@ -691,7 +692,7 @@ err_start:
>          assert(ret >= 0);
>      }
>  
> -    vhost_dev_stop(&net->dev, vdev, false);
> +    vhost_dev_stop(&net->dev, vdev, false, false);
>  
>      return r;
>  }
> diff --git a/hw/scsi/vhost-scsi-common.c b/hw/scsi/vhost-scsi-common.c
> index 0bb4305de6..41c1e45aac 100644
> --- a/hw/scsi/vhost-scsi-common.c
> +++ b/hw/scsi/vhost-scsi-common.c
> @@ -108,7 +108,7 @@ int vhost_scsi_common_stop(VHostSCSICommon *vsc)
>      VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
>      int ret = 0;
>  
> -    ret = vhost_dev_stop(&vsc->dev, vdev, true);
> +    ret = vhost_dev_stop(&vsc->dev, vdev, true, false);
>  
>      if (k->set_guest_notifiers) {
>          int r = k->set_guest_notifiers(qbus->parent, vsc->dev.nvqs, false);
> diff --git a/hw/virtio/vdpa-dev.c b/hw/virtio/vdpa-dev.c
> index 4532d63653..7279f18442 100644
> --- a/hw/virtio/vdpa-dev.c
> +++ b/hw/virtio/vdpa-dev.c
> @@ -301,7 +301,7 @@ static void vhost_vdpa_device_stop(VirtIODevice *vdev)
>          return;
>      }
>  
> -    vhost_dev_stop(&s->dev, vdev, false);
> +    vhost_dev_stop(&s->dev, vdev, false, false);
>  
>      ret = k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false);
>      if (ret < 0) {
> diff --git a/hw/virtio/vhost-user-base.c b/hw/virtio/vhost-user-base.c
> index 01ab9ca56b..9d3875a04b 100644
> --- a/hw/virtio/vhost-user-base.c
> +++ b/hw/virtio/vhost-user-base.c
> @@ -77,7 +77,7 @@ static int vub_stop(VirtIODevice *vdev)
>          return 0;
>      }
>  
> -    ret = vhost_dev_stop(&vub->vhost_dev, vdev, true);
> +    ret = vhost_dev_stop(&vub->vhost_dev, vdev, true, false);
>  
>      if (k->set_guest_notifiers(qbus->parent, vub->vhost_dev.nvqs, false) < 0) {
>          error_report("vhost guest notifier cleanup failed: %d", ret);
> diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c
> index ad6fcacf06..2f6f6df67f 100644
> --- a/hw/virtio/vhost-user-fs.c
> +++ b/hw/virtio/vhost-user-fs.c
> @@ -111,7 +111,7 @@ static int vuf_stop(VirtIODevice *vdev)
>          return 0;
>      }
>  
> -    ret = vhost_dev_stop(&fs->vhost_dev, vdev, true);
> +    ret = vhost_dev_stop(&fs->vhost_dev, vdev, true, false);
>  
>      if (k->set_guest_notifiers(qbus->parent, fs->vhost_dev.nvqs, false) < 0) {
>          error_report("vhost guest notifier cleanup failed: %d", ret);
> diff --git a/hw/virtio/vhost-user-scmi.c b/hw/virtio/vhost-user-scmi.c
> index f9264c4374..dbde342a6e 100644
> --- a/hw/virtio/vhost-user-scmi.c
> +++ b/hw/virtio/vhost-user-scmi.c
> @@ -101,7 +101,7 @@ static int vu_scmi_stop(VirtIODevice *vdev)
>          return 0;
>      }
>  
> -    ret = vhost_dev_stop(vhost_dev, vdev, true);
> +    ret = vhost_dev_stop(vhost_dev, vdev, true, false);
>  
>      if (k->set_guest_notifiers(qbus->parent, vhost_dev->nvqs, false) < 0) {
>          error_report("vhost guest notifier cleanup failed: %d", ret);
> diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c
> index b33def900a..3d086ed825 100644
> --- a/hw/virtio/vhost-vsock-common.c
> +++ b/hw/virtio/vhost-vsock-common.c
> @@ -106,7 +106,7 @@ int vhost_vsock_common_stop(VirtIODevice *vdev)
>          return 0;
>      }
>  
> -    ret = vhost_dev_stop(&vvc->vhost_dev, vdev, true);
> +    ret = vhost_dev_stop(&vvc->vhost_dev, vdev, true, false);
>  
>      if (k->set_guest_notifiers(qbus->parent, vvc->vhost_dev.nvqs, false) < 0) {
>          error_report("vhost guest notifier cleanup failed: %d", ret);
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index b4cdb7762f..c04bb53159 100644
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -1387,11 +1387,13 @@ fail_alloc_desc:
>  static int do_vhost_virtqueue_stop(struct vhost_dev *dev,
>                                     struct VirtIODevice *vdev,
>                                     struct vhost_virtqueue *vq,
> -                                   unsigned idx, bool force)
> +                                   unsigned idx, bool force,
> +                                   bool skip_drain)
>  {
>      int vhost_vq_index = dev->vhost_ops->vhost_get_vq_index(dev, idx);
>      struct vhost_vring_state state = {
>          .index = vhost_vq_index,
> +        .num = skip_drain,
>      };
>      int r = 0;
>  
> @@ -1439,9 +1441,10 @@ static int do_vhost_virtqueue_stop(struct vhost_dev *dev,
>  int vhost_virtqueue_stop(struct vhost_dev *dev,
>                           struct VirtIODevice *vdev,
>                           struct vhost_virtqueue *vq,
> -                         unsigned idx)
> +                         unsigned idx,
> +                         bool skip_drain)
>  {
> -    return do_vhost_virtqueue_stop(dev, vdev, vq, idx, false);
> +    return do_vhost_virtqueue_stop(dev, vdev, vq, idx, false, skip_drain);
>  }
>  
>  static int vhost_virtqueue_set_busyloop_timeout(struct vhost_dev *dev,
> @@ -2220,7 +2223,8 @@ fail_vq:
>          vhost_virtqueue_stop(hdev,
>                               vdev,
>                               hdev->vqs + i,
> -                             hdev->vq_index + i);
> +                             hdev->vq_index + i,
> +                             false);
>      }
>  
>  fail_mem:
> @@ -2235,7 +2239,7 @@ fail_features:
>  
>  /* Host notifiers must be enabled at this point. */
>  static int do_vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev,
> -                             bool vrings, bool force)
> +                             bool vrings, bool force, bool skip_drain)
>  {
>      int i;
>      int rc = 0;
> @@ -2262,7 +2266,8 @@ static int do_vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev,
>                                        vdev,
>                                        hdev->vqs + i,
>                                        hdev->vq_index + i,
> -                                      force);
> +                                      force,
> +                                      skip_drain);
>      }
>      if (hdev->vhost_ops->vhost_reset_status) {
>          hdev->vhost_ops->vhost_reset_status(hdev);
> @@ -2282,15 +2287,16 @@ static int do_vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev,
>      return rc;
>  }
>  
> -int vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings)
> +int vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings,
> +                   bool skip_drain)
>  {
> -    return do_vhost_dev_stop(hdev, vdev, vrings, false);
> +    return do_vhost_dev_stop(hdev, vdev, vrings, false, skip_drain);
>  }
>  
>  int vhost_dev_force_stop(struct vhost_dev *hdev, VirtIODevice *vdev,
>                           bool vrings)
>  {
> -    return do_vhost_dev_stop(hdev, vdev, vrings, true);
> +    return do_vhost_dev_stop(hdev, vdev, vrings, true, false);
>  }
>  
>  int vhost_net_set_backend(struct vhost_dev *hdev,
> diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h
> index 89817bd848..3881f6784b 100644
> --- a/include/hw/virtio/vhost.h
> +++ b/include/hw/virtio/vhost.h
> @@ -233,6 +233,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings);
>   * @hdev: common vhost_dev structure
>   * @vdev: the VirtIODevice structure
>   * @vrings: true to have vrings disabled in this call
> + * @skip_drain: true to notice back-end to skip draining all in-flight requests
>   *
>   * Stop the vhost device. After the device is stopped the notifiers
>   * can be disabled (@vhost_dev_disable_notifiers) and the device can
> @@ -240,7 +241,8 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings);
>   *
>   * Return: 0 on success, != 0 on error when stopping dev.
>   */
> -int vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings);
> +int vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings,
> +                   bool skip_drain);
>  
>  /**
>   * vhost_dev_force_stop() - force stop the vhost device
> @@ -398,7 +400,8 @@ int vhost_device_iotlb_miss(struct vhost_dev *dev, uint64_t iova, int write);
>  int vhost_virtqueue_start(struct vhost_dev *dev, struct VirtIODevice *vdev,
>                            struct vhost_virtqueue *vq, unsigned idx);
>  int vhost_virtqueue_stop(struct vhost_dev *dev, struct VirtIODevice *vdev,
> -                         struct vhost_virtqueue *vq, unsigned idx);
> +                         struct vhost_virtqueue *vq, unsigned idx,
> +                         bool skip_drain);
>  
>  void vhost_dev_reset_inflight(struct vhost_inflight *inflight);
>  void vhost_dev_free_inflight(struct vhost_inflight *inflight);
> -- 
> 2.34.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2026-03-01 23:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-24  7:50 [PATCH 0/4] vhost-user-blk: fix compatibility with older qemu versions Alexandr Moshkov
2026-02-24  7:50 ` [PATCH 1/4] vhost-user.rst: fix typo Alexandr Moshkov
2026-02-25 13:05   ` Stefan Hajnoczi
2026-02-24  7:50 ` [PATCH 2/4] vhost-user: add skip_drain param to GET_VRING_BASE Alexandr Moshkov
2026-03-01 23:34   ` Stefan Hajnoczi [this message]
     [not found]     ` <121fea54-0041-4004-aa4f-3a402da8169e@yandex-team.ru>
2026-03-03  8:45       ` Vladimir Sementsov-Ogievskiy
2026-03-05  9:26   ` Vladimir Sementsov-Ogievskiy
2026-02-24  7:50 ` [PATCH 3/4] vhost-user: remove supports_inflight_migration Alexandr Moshkov
2026-02-24  7:50 ` [PATCH 4/4] vhost-user-blk: make inflight migration throught skip_drain Alexandr Moshkov
2026-03-05  9:45   ` Vladimir Sementsov-Ogievskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260301233406.GA8465@fedora \
    --to=stefanha@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=arei.gonglei@huawei.com \
    --cc=dtalexundeer@yandex-team.ru \
    --cc=fam@euphon.net \
    --cc=hreitz@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mst@redhat.com \
    --cc=mzamazal@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=pierrick.bouvier@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rnorwitz@nvidia.com \
    --cc=sgarzare@redhat.com \
    --cc=virtio-fs@lists.linux.dev \
    --cc=zhenwei.pi@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox