Skip to contentSkip to conversation

vfio-user: block migration

PATCH Applied Oguzhan KAYNAK 2 participants 3 messages Nov 27 – Nov 30

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vfio-user: block migration

vfio-user devices lack a migration blocker, so migration can complete successfully without transferring device state. The destination VM is left with an unconfigured device, for example with its BARs unassigned, and -only-migratable does not reject such a device.

Block migration until vfio-user migration support is implemented. Block all migration modes because vfio-user does not support CPR either.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/5002

---
Discussed in:
https://lore.kernel.org/qemu-devel/awjCxgCwvDR0vViz@lent/

 hw/vfio-user/pci.c | 9 +++++++++
 1 file changed, 9 insertions(+)
hw/vfio-user/pci.c +9 -0
index e3749cdd39..d3ae2c150a 100644
@@ -11,6 +11,7 @@
 #include "qapi/qapi-type-infos-sockets.h"
 #include "qapi-visit-sockets.h"
 #include "qemu/error-report.h"
+#include "migration/blocker.h"
 
 #include "hw/core/qdev-properties.h"
 #include "hw/vfio/pci.h"
@@ -284,6 +285,13 @@ static void vfio_user_pci_realize(PCIDevice *pdev, Error **errp)
         return;
     }
     vbasedev->proxy = proxy;
+
+    error_setg(&vbasedev->migration_blocker,
+               "%s: migration is not supported", vbasedev->name);
+    if (migrate_add_blocker(&vbasedev->migration_blocker, errp) < 0) {
+        goto error;
+    }
+
     vfio_user_set_handler(vbasedev, vfio_user_pci_process_req, vdev);
 
     if (udev->send_queued) {
@@ -358,6 +366,7 @@ out_teardown:
     vfio_pci_teardown_msi(vdev);
     vfio_pci_bars_exit(vdev);
 error:
+    migrate_del_blocker(&vbasedev->migration_blocker);
     error_prepend(errp, VFIO_MSG_PREFIX, vdev->vbasedev.name);
     vfio_pci_put_device(vdev);
 }
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 45 lines · Oguzhan KAYNAK

vfio-user devices lack a migration blocker, so migration can complete successfully without transferring device state. The destination VM is left with an unconfigured device, for example with its BARs unassigned, and -only-migratable does not reject such a device.

Block migration until vfio-user migration support is implemented. Block all migration modes because vfio-user does not support CPR either.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/5002

---
Discussed in:
https://lore.kernel.org/qemu-devel/awjCxgCwvDR0vViz@lent/

  hw/vfio-user/pci.c | 9 +++++++++
  1 file changed, 9 insertions(+)
hw/vfio-user/pci.c +8 -0
index e3749cdd39..d3ae2c150a 100644
@@ -11,6 +11,7 @@
  #include "qapi/qapi-type-infos-sockets.h"
  #include "qapi-visit-sockets.h"
  #include "qemu/error-report.h"
+#include "migration/blocker.h"
 
  #include "hw/core/qdev-properties.h"
  #include "hw/vfio/pci.h"
@@ -284,6 +285,13 @@ static void vfio_user_pci_realize(PCIDevice *pdev, Error **errp)
          return;
      }
      vbasedev->proxy = proxy;
+
+    error_setg(&vbasedev->migration_blocker,
+               "%s: migration is not supported", vbasedev->name);
+    if (migrate_add_blocker(&vbasedev->migration_blocker, errp) < 0) {
+        goto error;
+    }
+
      vfio_user_set_handler(vbasedev, vfio_user_pci_process_req, vdev);
 
      if (udev->send_queued) {

hw/vfio-user/pci.c out_teardown: · line 372

Quoted 7 lines
hw/vfio-user/pci.c +1 -0
@@ -358,6 +366,7 @@ out_teardown:
      vfio_pci_teardown_msi(vdev);
      vfio_pci_bars_exit(vdev);
  error:
+    migrate_del_blocker(&vbasedev->migration_blocker);
      error_prepend(errp, VFIO_MSG_PREFIX, vdev->vbasedev.name);
      vfio_pci_put_device(vdev);
  }

Thanks,

C.

#2 lore raw
In reply to Oguzhan KAYNAK
Quoted 45 lines · Oguzhan KAYNAK

vfio-user devices lack a migration blocker, so migration can complete successfully without transferring device state. The destination VM is left with an unconfigured device, for example with its BARs unassigned, and -only-migratable does not reject such a device.

Block migration until vfio-user migration support is implemented. Block all migration modes because vfio-user does not support CPR either.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/5002

---
Discussed in:
https://lore.kernel.org/qemu-devel/awjCxgCwvDR0vViz@lent/

  hw/vfio-user/pci.c | 9 +++++++++
  1 file changed, 9 insertions(+)
hw/vfio-user/pci.c +8 -0
index e3749cdd39..d3ae2c150a 100644
@@ -11,6 +11,7 @@
  #include "qapi/qapi-type-infos-sockets.h"
  #include "qapi-visit-sockets.h"
  #include "qemu/error-report.h"
+#include "migration/blocker.h"
 
  #include "hw/core/qdev-properties.h"
  #include "hw/vfio/pci.h"
@@ -284,6 +285,13 @@ static void vfio_user_pci_realize(PCIDevice *pdev, Error **errp)
          return;
      }
      vbasedev->proxy = proxy;
+
+    error_setg(&vbasedev->migration_blocker,
+               "%s: migration is not supported", vbasedev->name);
+    if (migrate_add_blocker(&vbasedev->migration_blocker, errp) < 0) {
+        goto error;
+    }
+
      vfio_user_set_handler(vbasedev, vfio_user_pci_process_req, vdev);
 
      if (udev->send_queued) {

hw/vfio-user/pci.c out_teardown: · line 372

Quoted 7 lines
hw/vfio-user/pci.c +1 -0
@@ -358,6 +366,7 @@ out_teardown:
      vfio_pci_teardown_msi(vdev);
      vfio_pci_bars_exit(vdev);
  error:
+    migrate_del_blocker(&vbasedev->migration_blocker);
      error_prepend(errp, VFIO_MSG_PREFIX, vdev->vbasedev.name);
      vfio_pci_put_device(vdev);
  }

Applied to vfio-next.

Thanks,

C.