[PATCH v6 0/6] vhost-user-blk: allow toggling inflight-migration at runtime

Alexandr Moshkov <[email protected]> Mon, 3 Aug 2026 12:28:47 +0500
Newsgroups dev.linux.lists.virtio-fs,org.nongnu.qemu-devel
Message-ID <[email protected]>
v5 -> v6:
- block changing inflight-migration property while VM is not running
- remove checking runstate in vhost_user_blk_stop() since it's not necessary
- updated cover letter: changed subject and description to focus on
  runtime toggling of inflight-migration rather than cross-version
  migration compatibility

v4 -> v5:
- introduce protocol feature VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN
  to guard the new message, instead of reusing the existing
  VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INLIFGHT. Update docs.
- improved commit messages.

v3 -> v4:
- add new protocol message GET_VRING_BASE_SKIP_DRAIN instead of parameter to GET_VRING_BASE message. This new message can be send instead of GET_VRING_BASE, allowing back-end to suspend inflight I/O immediately instead of waiting and completing them.
- rebase to newer master

v2 -> v3:
- fix complile problems
- add assert check in do_vhost_virtio_stop
- make inflight-migration property mutable

v1 -> v2:
- reorganize commits: make refactor commits first, then core semantic change
- add additional pre_save check for inflight migration possibility

---

This is v6 of the series previously sent as:
"[PATCH v5 0/6] vhost-user-blk: add compatibility with older qemu versions"

This series allows the inflight-migration property of vhost-user-blk to
be toggled at runtime via qom-set without restarting the VM or
reconnecting to the back-end.

Currently, the inflight migration behaviour is controlled by
VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT, which is negotiated once
at connection time. Once negotiated, the back-end always uses suspend
semantics on GET_VRING_BASE -- there is no way for the front-end to
request normal drain behaviour on a per-call basis. This makes it
impossible to disable inflight-migration at runtime.

To solve this, the series introduces a new protocol message
VHOST_USER_GET_VRING_BASE_SKIP_DRAIN (id=45) guarded by a new protocol
feature VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN. The message
instructs the back-end to suspend in-flight I/O immediately rather than
draining it. This gives the front-end explicit per-call control:
GET_VRING_BASE for normal drain, GET_VRING_BASE_SKIP_DRAIN when
inflight-migration is enabled.

In vhost-user-blk, GET_VRING_BASE_SKIP_DRAIN is sent whenever
inflight-migration is on. The inflight-migration
property can only be changed while the VM is running, so its value at
stop time reliably reflects the user's intent.

Alexandr Moshkov (6):
  vhost-user: add skip_drain param to do_vhost_virtqueue_stop
  vhost-user: add GET_VRING_BASE_SKIP_DRAIN message
  vhost-user: use skip_drain with GET_VRING_BASE_SKIP_DRAIN message
  vhost-user-blk: make inflight-migration prop mutable on running vm
  vhost-user-blk: move inflight_needed higher
  vhost-user-blk: use GET_VRING_BASE_SKIP_DRAIN when inflight-migration
    is on

 backends/cryptodev-vhost.c        |  2 +-
 backends/vhost-user.c             |  2 +-
 docs/interop/vhost-user.rst       | 88 +++++++++++++++++++------------
 hw/block/vhost-user-blk.c         | 60 ++++++++++++++++++---
 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-user.c            | 47 ++++++++++++++---
 hw/virtio/vhost-vsock-common.c    |  2 +-
 hw/virtio/vhost.c                 | 34 ++++++++----
 include/hw/virtio/vhost-backend.h |  1 +
 include/hw/virtio/vhost-user.h    |  2 +-
 include/hw/virtio/vhost.h         |  7 ++-
 16 files changed, 189 insertions(+), 75 deletions(-)

-- 
2.34.1