[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 09/11] vfio/migration: Reset device if setting recover state f
From: |
Avihai Horon |
Subject: |
[PATCH v2 09/11] vfio/migration: Reset device if setting recover state fails |
Date: |
Mon, 30 May 2022 20:07:37 +0300 |
If vfio_migration_set_state() fails to set the device in the requested
state it tries to put it in a recover state. If setting the device in
the recover state fails as well, hw_error is triggered and the VM is
aborted.
To improve user experience and avoid VM data loss, reset the device with
VFIO_RESET_DEVICE instead of aborting the VM.
Signed-off-by: Avihai Horon <avihaih@nvidia.com>
---
hw/vfio/migration.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
index 852759e6ca..6c34502611 100644
--- a/hw/vfio/migration.c
+++ b/hw/vfio/migration.c
@@ -89,8 +89,16 @@ static int vfio_migration_set_state(VFIODevice *vbasedev,
/* Try to put the device in some good state */
mig_state->device_state = recover_state;
if (ioctl(vbasedev->fd, VFIO_DEVICE_FEATURE, feature)) {
- hw_error("%s: Device in error state, can't recover",
- vbasedev->name);
+ if (ioctl(vbasedev->fd, VFIO_DEVICE_RESET)) {
+ hw_error("%s: Device in error state, can't recover",
+ vbasedev->name);
+ }
+
+ error_report(
+ "%s: Device was reset due to failure in changing device state
to recover state %s",
+ vbasedev->name, mig_state_to_str(recover_state));
+
+ return -1;
}
error_report("%s: Failed changing device state to %s", vbasedev->name,
--
2.21.3
- [PATCH v2 00/11] vfio/migration: Implement VFIO migration protocol v2, Avihai Horon, 2022/05/30
- [PATCH v2 01/11] vfio/migration: Fix NULL pointer dereference bug, Avihai Horon, 2022/05/30
- [PATCH v2 02/11] vfio/migration: Skip pre-copy if dirty page tracking is not supported, Avihai Horon, 2022/05/30
- [PATCH v2 03/11] migration/qemu-file: Add qemu_file_get_to_fd(), Avihai Horon, 2022/05/30
- [PATCH v2 04/11] vfio/common: Change vfio_devices_all_running_and_saving() logic to equivalent one, Avihai Horon, 2022/05/30
- [PATCH v2 05/11] vfio/migration: Move migration v1 logic to vfio_migration_init(), Avihai Horon, 2022/05/30
- [PATCH v2 06/11] vfio/migration: Rename functions/structs related to v1 protocol, Avihai Horon, 2022/05/30
- [PATCH v2 07/11] vfio/migration: Implement VFIO migration protocol v2, Avihai Horon, 2022/05/30
- [PATCH v2 08/11] vfio/migration: Remove VFIO migration protocol v1, Avihai Horon, 2022/05/30
- [PATCH v2 09/11] vfio/migration: Reset device if setting recover state fails,
Avihai Horon <=
- [PATCH v2 10/11] vfio: Alphabetize migration section of VFIO trace-events file, Avihai Horon, 2022/05/30
- [PATCH v2 11/11] docs/devel: Align vfio-migration docs to VFIO migration v2, Avihai Horon, 2022/05/30