public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/10] vhost-scsi: log write descriptors for live migration (and three bugfix)
@ 2025-03-17 23:55 Dongli Zhang
  2025-03-17 23:55 ` [PATCH v2 01/10] vhost-scsi: protect vq->log_used with vq->mutex Dongli Zhang
                   ` (9 more replies)
  0 siblings, 10 replies; 28+ messages in thread
From: Dongli Zhang @ 2025-03-17 23:55 UTC (permalink / raw)
  To: virtualization, kvm, netdev
  Cc: mst, jasowang, michael.christie, pbonzini, stefanha, eperezma,
	joao.m.martins, joe.jin, si-wei.liu, linux-kernel

The live migration with vhost-scsi has been enabled by QEMU commit
b3e89c941a85 ("vhost-scsi: Allow user to enable migration"), which
thoroughly explains the workflow that QEMU collaborates with vhost-scsi on
the live migration.

Although it logs dirty data for the used ring, it doesn't log any write
descriptor (VRING_DESC_F_WRITE).

In comparison, vhost-net logs write descriptors via vhost_log_write(). The
SPDK (vhost-user-scsi backend) also logs write descriptors via
vhost_log_req_desc().

As a result, there is likely data mismatch between memory and vhost-scsi
disk during the live migration.

1. Suppose there is high workload and high memory usage. Suppose some
systemd userspace pages are swapped out to the swap disk.

2. Upon request from systemd, the kernel reads some pages from the swap
disk to the memory via vhost-scsi.

3. Although those userspace pages' data are updated, they are not marked as
dirty by vhost-scsi (this is the bug). They are not going to migrate to the
target host during memory transfer iterations.

4. Suppose systemd doesn't write to those pages any longer. Those pages
never get the chance to be dirty or migrated any longer.

5. Once the guest VM is resumed on the target host, because of the lack of
those dirty pages' data, the systemd may run into abnormal status, i.e.,
there may be systemd segfault.

Log all write descriptors to fix the issue.

In addition, the patchset also fixes three bugs in vhost-scsi.

Changed since v1:
  - Rebase on top of most recent vhost changes.
  - Don't allocate log buffer during initialization. Allocate during
    VHOST_SET_FEATURES or VHOST_SCSI_SET_ENDPOINT.
  - Add bugfix for vhost_scsi_send_status().

Dongli Zhang (vhost-scsi bugfix):
  vhost-scsi: protect vq->log_used with vq->mutex
  vhost-scsi: Fix vhost_scsi_send_bad_target()
  vhost-scsi: Fix vhost_scsi_send_status()

Dongli Zhang (log descriptor, suggested by Joao Martins):
  vhost: modify vhost_log_write() for broader users
  vhost-scsi: adjust vhost_scsi_get_desc() to log vring descriptors
  vhost-scsi: cache log buffer in I/O queue vhost_scsi_cmd
  vhost-scsi: log I/O queue write descriptors
  vhost-scsi: log control queue write descriptors
  vhost-scsi: log event queue write descriptors
  vhost: add WARNING if log_num is more than limit

 drivers/vhost/net.c   |   2 +-
 drivers/vhost/scsi.c  | 314 ++++++++++++++++++++++++++++++++++++++++-----
 drivers/vhost/vhost.c |  46 +++++--
 drivers/vhost/vhost.h |   2 +-
 4 files changed, 322 insertions(+), 42 deletions(-)


base-commit: 9d8960672d63db4b3b04542f5622748b345c637a
branch: remotes/origin/linux-next
tree: https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git

Thank you very much!

Dongli Zhang


^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2025-03-27 20:27 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-17 23:55 [PATCH v2 00/10] vhost-scsi: log write descriptors for live migration (and three bugfix) Dongli Zhang
2025-03-17 23:55 ` [PATCH v2 01/10] vhost-scsi: protect vq->log_used with vq->mutex Dongli Zhang
2025-03-18  0:47   ` Jason Wang
2025-03-26 22:22   ` Mike Christie
2025-03-17 23:55 ` [PATCH v2 02/10] vhost-scsi: Fix vhost_scsi_send_bad_target() Dongli Zhang
2025-03-18  0:48   ` Jason Wang
2025-03-26 22:25   ` Mike Christie
2025-03-17 23:55 ` [PATCH v2 03/10] vhost-scsi: Fix vhost_scsi_send_status() Dongli Zhang
2025-03-18  0:48   ` Jason Wang
2025-03-19 17:54     ` Dongli Zhang
2025-03-20  1:42       ` Jason Wang
2025-03-26 22:27   ` Mike Christie
2025-03-17 23:55 ` [PATCH v2 04/10] vhost: modify vhost_log_write() for broader users Dongli Zhang
2025-03-18  1:12   ` Jason Wang
2025-03-19 16:38     ` Dongli Zhang
2025-03-20  1:41       ` Jason Wang
2025-03-17 23:55 ` [PATCH v2 05/10] vhost-scsi: adjust vhost_scsi_get_desc() to log vring descriptors Dongli Zhang
2025-03-26 23:21   ` Mike Christie
2025-03-17 23:55 ` [PATCH v2 06/10] vhost-scsi: cache log buffer in I/O queue vhost_scsi_cmd Dongli Zhang
2025-03-18  0:04   ` Dongli Zhang
2025-03-26 23:37     ` Mike Christie
2025-03-27 20:27       ` Dongli Zhang
2025-03-17 23:55 ` [PATCH v2 07/10] vhost-scsi: log I/O queue write descriptors Dongli Zhang
2025-03-17 23:55 ` [PATCH v2 08/10] vhost-scsi: log control " Dongli Zhang
2025-03-17 23:55 ` [PATCH v2 09/10] vhost-scsi: log event " Dongli Zhang
2025-03-26 23:50   ` Mike Christie
2025-03-26 23:51   ` Mike Christie
2025-03-17 23:55 ` [PATCH v2 10/10] vhost: add WARNING if log_num is more than limit Dongli Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox