]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
vfio: Fix unregister SaveVMHandler in vfio_migration_finalize
authorKunkun Jiang <jiangkunkun@huawei.com>
Thu, 27 May 2021 12:31:01 +0000 (20:31 +0800)
committerMichael Roth <michael.roth@amd.com>
Thu, 14 Oct 2021 21:02:34 +0000 (16:02 -0500)
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)
Reported-by: Qixin Gan <ganqixin@huawei.com>
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
Message-Id: <20210527123101.289-1-jiangkunkun@huawei.com>
Reviewed by: Kirti Wankhede <kwankhede@nvidia.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
(cherry picked from commit 22fca190e25b10761925bb1eeadeda07aabf3c26)
Signed-off-by: Michael Roth <michael.roth@amd.com>
hw/vfio/migration.c

index 384576cfc05101aedea2ec150601efd80a57aced..3ed3d595b873525794abdf4c9c96dabcf6f875be 100644 (file)
@@ -893,6 +893,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);
     }