[PATCH] vfio-user: block migration

Oguzhan KAYNAK posted 1 patch 8 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20261127165922.66105-1-kaynak.oguzhan0@gmail.com
Maintainers: John Levon <john.levon@nutanix.com>, Thanos Makatos <thanos.makatos@nutanix.com>, "Cédric Le Goater" <clg@redhat.com>
hw/vfio-user/pci.c | 9 +++++++++
1 file changed, 9 insertions(+)
[PATCH] vfio-user: block migration
Posted by Oguzhan KAYNAK 8 hours ago
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
Cc: qemu-stable@nongnu.org
Signed-off-by: Oguzhan KAYNAK <kaynak.oguzhan0@gmail.com>
---
Discussed in:
https://lore.kernel.org/qemu-devel/awjCxgCwvDR0vViz@lent/

 hw/vfio-user/pci.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/hw/vfio-user/pci.c b/hw/vfio-user/pci.c
index e3749cdd39..d3ae2c150a 100644
--- a/hw/vfio-user/pci.c
+++ b/hw/vfio-user/pci.c
@@ -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);
 }
-- 
2.34.1