Skip to contentSkip to conversation

VFIO update 2021-06-18

GIT PULL Applied Alex Williamson 2 participants 5 messages Jun 18, 2021 – Jun 20, 2021

lore
Share & tools
lore
#0 lore raw

The following changes since commit 3ccf6cd0e3e1dfd663814640b3b18b55715d7a75:

Merge remote-tracking branch 'remotes/kraxel/tags/audio-20210617-pull-request' into staging (2021-06-18 09:54:42 +0100)

are available in the Git repository at:

git://github.com/awilliam/qemu-vfio.git tags/vfio-update-20210618.0

for you to fetch changes up to d742d064c1f541ac8ad6541e248a97f2dc502721:

vfio/migration: Correct device state from vmstate change for savevm case (2021-06-18 09:10:35 -0600)

----------------------------------------------------------------
VFIO update 2021-06-18

* VFIO migration documentation (Tarun Gupta)

* Fix SaveVMHandler de-registration (Kunkun Jiang)

* Fix vmstate change transition (Kirti Wankhede)

----------------------------------------------------------------
Kirti Wankhede (1):
vfio/migration: Correct device state from vmstate change for savevm case

Kunkun Jiang (1):
vfio: Fix unregister SaveVMHandler in vfio_migration_finalize

Tarun Gupta (1):
docs/devel: Add VFIO device migration documentation

 MAINTAINERS                   |   1 +
 docs/devel/index.rst          |   1 +
 docs/devel/vfio-migration.rst | 150 ++++++++++++++++++++++++++++++++++++++++++
 hw/vfio/migration.c           |  12 +++-
 4 files changed, 163 insertions(+), 1 deletion(-)
 create mode 100644 docs/devel/vfio-migration.rst
#1 lore raw

[PULL 2/3] vfio: Fix unregister SaveVMHandler in vfio_migration_finalize

From: Kunkun Jiang <[email protected]>

In the vfio_migration_init(), the SaveVMHandler is registered for VFIO device. But it lacks the operation of 'unregister'. It will lead to 'Segmentation fault (core dumped)' in qemu_savevm_state_setup(), if performing live migration after a VFIO device is hot deleted.

Fixes 7c2f5f75f94 (vfio: Register SaveVMHandlers for VFIO device)

Message-Id: <[email protected]> Reviewed by: Kirti Wankhede <[email protected]>

---
 hw/vfio/migration.c |    1 +
 1 file changed, 1 insertion(+)
hw/vfio/migration.c +1 -0
index 201642d75e6b..ef397ebe6c09 100644
@@ -892,6 +892,7 @@ void vfio_migration_finalize(VFIODevice *vbasedev)
 
         remove_migration_state_change_notifier(&migration->migration_state);
         qemu_del_vm_change_state_handler(migration->vm_state);
+        unregister_savevm(VMSTATE_IF(vbasedev->dev), "vfio", vbasedev);
         vfio_migration_exit(vbasedev);
     }
 
#2 lore raw

[PULL 3/3] vfio/migration: Correct device state from vmstate change for savevm case

In reply to Alex Williamson

From: Kirti Wankhede <[email protected]>

Set _SAVING flag for device state from vmstate change handler when it gets called from savevm.

Currently State transition savevm/suspend is seen as:

    _RUNNING -> _STOP -> Stop-and-copy -> _STOP

State transition savevm/suspend should be:

    _RUNNING -> Stop-and-copy -> _STOP

State transition from _RUNNING to _STOP occurs from vfio_vmstate_change() where when vmstate changes from running to !running, _RUNNING flag is reset but at the same time when vfio_vmstate_change() is called for RUN_STATE_SAVE_VM, _SAVING bit should be set.

Reported by: Yishai Hadas <[email protected]>

Message-Id: <[email protected]>

---
 hw/vfio/migration.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
hw/vfio/migration.c +10 -1
index ef397ebe6c09..82f654afb64a 100644
@@ -724,7 +724,16 @@ static void vfio_vmstate_change(void *opaque, bool running, RunState state)
          * _RUNNING bit
          */
         mask = ~VFIO_DEVICE_STATE_RUNNING;
-        value = 0;
+
+        /*
+         * When VM state transition to stop for savevm command, device should
+         * start saving data.
+         */
+        if (state == RUN_STATE_SAVE_VM) {
+            value = VFIO_DEVICE_STATE_SAVING;
+        } else {
+            value = 0;
+        }
     }
 
     ret = vfio_migration_set_state(vbasedev, mask, value);
#3 lore raw

[PULL 1/3] docs/devel: Add VFIO device migration documentation

In reply to Alex Williamson

From: Tarun Gupta <[email protected]>

Document interfaces used for VFIO device migration. Added flow of state changes during live migration with VFIO device.

Message-Id: <[email protected]>

---
 MAINTAINERS                   |    1 
 docs/devel/index.rst          |    1 
 docs/devel/vfio-migration.rst |  150 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 152 insertions(+)
 create mode 100644 docs/devel/vfio-migration.rst
MAINTAINERS +1 -0
index 4842cc26e5ce..f7e12ea2488d 100644
@@ -1817,6 +1817,7 @@ S: Supported
 F: hw/vfio/*
 F: include/hw/vfio/
 F: docs/igd-assign.txt
+F: docs/devel/vfio-migration.rst
 
 vfio-ccw
 M: Cornelia Huck <[email protected]>
docs/devel/index.rst +1 -0
index 791925dcda54..977c3893bdaf 100644
@@ -44,3 +44,4 @@ Contents:
    block-coroutine-wrapper
    multi-process
    ebpf_rss
+   vfio-migration
docs/devel/vfio-migration.rst new file +150 -0

150 lines not on this page · raw message

#4 lore raw
In reply to Alex Williamson
Quoted 16 lines · Alex Williamson

The following changes since commit 3ccf6cd0e3e1dfd663814640b3b18b55715d7a75:

Merge remote-tracking branch 'remotes/kraxel/tags/audio-20210617-pull-request' into staging (2021-06-18 09:54:42 +0100)

are available in the Git repository at:

git://github.com/awilliam/qemu-vfio.git tags/vfio-update-20210618.0

for you to fetch changes up to d742d064c1f541ac8ad6541e248a97f2dc502721:

vfio/migration: Correct device state from vmstate change for savevm case (2021-06-18 09:10:35 -0600)

----------------------------------------------------------------
VFIO update 2021-06-18

Quoted 7 lines

* VFIO migration documentation (Tarun Gupta)

* Fix SaveVMHandler de-registration (Kunkun Jiang)

* Fix vmstate change transition (Kirti Wankhede)

----------------------------------------------------------------

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/6.1
for any user-visible changes.

-- PMM