[PATCH v3 0/5] scsi: persistent reservation live migration

Stefan Hajnoczi posted 5 patches 1 week, 1 day ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260129212035.219676-1-stefanha@redhat.com
Maintainers: Pierrick Bouvier <pierrick.bouvier@linaro.org>, Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Yanan Wang <wangyanan55@huawei.com>, Zhao Liu <zhao1.liu@intel.com>, Paolo Bonzini <pbonzini@redhat.com>, Fam Zheng <fam@euphon.net>
docs/system/device-emulation.rst        |   1 +
docs/system/devices/scsi/index.rst      |  10 +
docs/system/devices/scsi/migrate-pr.rst |  54 +++++
include/hw/scsi/scsi.h                  |  15 +-
include/scsi/constants.h                |  21 ++
hw/core/machine.c                       |   4 +-
hw/scsi/scsi-bus.c                      |   3 +
hw/scsi/scsi-disk.c                     |  90 +++++++-
hw/scsi/scsi-generic.c                  | 291 +++++++++++++++++++++++-
hw/scsi/trace-events                    |   2 +
10 files changed, 476 insertions(+), 15 deletions(-)
create mode 100644 docs/system/devices/scsi/index.rst
create mode 100644 docs/system/devices/scsi/migrate-pr.rst
[PATCH v3 0/5] scsi: persistent reservation live migration
Posted by Stefan Hajnoczi 1 week, 1 day ago
v3:
- Use warn_report_err() instead of suppressing errors [Daniel Berrangé]
- Wrap lines exceeding 80 characters

v2:
- Add user documentation [Paolo]
- Send PREEMPT on the source if migration fails. This rollback operation
  ensures the source regains access to the LUN even if migration fails after
  the destination issues its own PREEMPT.

Live migration does not work for SCSI Persistent Reservations acquired on
scsi-block devices. This patch series migrates the reservation key and
reservation type so that the destination QEMU can take over the persistent
reservation with the PREEMPT service action upon live migration.

The approach involves snooping PERSISTENT RESERVE OUT replies and tracking the
scsi-block device's current reservation key and reservation type. In most cases
this involves no additional SCSI commands. This approach isn't perfect: if
another machine modifies the reservation on the physical LUN, then QEMU's state
becomes stale. Persistent reservations are inherently cooperative, so this is
acceptable as long as real applications don't run into problems.

I am also working on a test suite called pr-tests that runs sg_persist(8)
commands across multiple machines in order to exercise various scenarios:
https://gitlab.com/stefanha/pr-tests

Stefan Hajnoczi (5):
  scsi: generalize scsi_SG_IO_FROM_DEV() to scsi_SG_IO()
  scsi: add error reporting to scsi_SG_IO()
  scsi: track SCSI reservation state for live migration
  scsi: save/load SCSI reservation state
  docs: add SCSI migrate-pr documentation

 docs/system/device-emulation.rst        |   1 +
 docs/system/devices/scsi/index.rst      |  10 +
 docs/system/devices/scsi/migrate-pr.rst |  54 +++++
 include/hw/scsi/scsi.h                  |  15 +-
 include/scsi/constants.h                |  21 ++
 hw/core/machine.c                       |   4 +-
 hw/scsi/scsi-bus.c                      |   3 +
 hw/scsi/scsi-disk.c                     |  90 +++++++-
 hw/scsi/scsi-generic.c                  | 291 +++++++++++++++++++++++-
 hw/scsi/trace-events                    |   2 +
 10 files changed, 476 insertions(+), 15 deletions(-)
 create mode 100644 docs/system/devices/scsi/index.rst
 create mode 100644 docs/system/devices/scsi/migrate-pr.rst

-- 
2.52.0


Re: [PATCH v3 0/5] scsi: persistent reservation live migration
Posted by Stefan Hajnoczi 2 days, 15 hours ago
On Thu, Jan 29, 2026 at 04:20:30PM -0500, Stefan Hajnoczi wrote:
> v3:
> - Use warn_report_err() instead of suppressing errors [Daniel Berrangé]
> - Wrap lines exceeding 80 characters

CCing Daniel Berrangé (sorry, I forgot!)

> 
> v2:
> - Add user documentation [Paolo]
> - Send PREEMPT on the source if migration fails. This rollback operation
>   ensures the source regains access to the LUN even if migration fails after
>   the destination issues its own PREEMPT.
> 
> Live migration does not work for SCSI Persistent Reservations acquired on
> scsi-block devices. This patch series migrates the reservation key and
> reservation type so that the destination QEMU can take over the persistent
> reservation with the PREEMPT service action upon live migration.
> 
> The approach involves snooping PERSISTENT RESERVE OUT replies and tracking the
> scsi-block device's current reservation key and reservation type. In most cases
> this involves no additional SCSI commands. This approach isn't perfect: if
> another machine modifies the reservation on the physical LUN, then QEMU's state
> becomes stale. Persistent reservations are inherently cooperative, so this is
> acceptable as long as real applications don't run into problems.
> 
> I am also working on a test suite called pr-tests that runs sg_persist(8)
> commands across multiple machines in order to exercise various scenarios:
> https://gitlab.com/stefanha/pr-tests
> 
> Stefan Hajnoczi (5):
>   scsi: generalize scsi_SG_IO_FROM_DEV() to scsi_SG_IO()
>   scsi: add error reporting to scsi_SG_IO()
>   scsi: track SCSI reservation state for live migration
>   scsi: save/load SCSI reservation state
>   docs: add SCSI migrate-pr documentation
> 
>  docs/system/device-emulation.rst        |   1 +
>  docs/system/devices/scsi/index.rst      |  10 +
>  docs/system/devices/scsi/migrate-pr.rst |  54 +++++
>  include/hw/scsi/scsi.h                  |  15 +-
>  include/scsi/constants.h                |  21 ++
>  hw/core/machine.c                       |   4 +-
>  hw/scsi/scsi-bus.c                      |   3 +
>  hw/scsi/scsi-disk.c                     |  90 +++++++-
>  hw/scsi/scsi-generic.c                  | 291 +++++++++++++++++++++++-
>  hw/scsi/trace-events                    |   2 +
>  10 files changed, 476 insertions(+), 15 deletions(-)
>  create mode 100644 docs/system/devices/scsi/index.rst
>  create mode 100644 docs/system/devices/scsi/migrate-pr.rst
> 
> -- 
> 2.52.0
>