[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 14/17] vfio/migration: Reset device if setting recover state f
From: |
Avihai Horon |
Subject: |
[PATCH v3 14/17] vfio/migration: Reset device if setting recover state fails |
Date: |
Thu, 3 Nov 2022 18:16:17 +0200 |
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 | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
index f8c3228314..e8068b9147 100644
--- a/hw/vfio/migration.c
+++ b/hw/vfio/migration.c
@@ -92,8 +92,18 @@ static int vfio_migration_set_state(VFIODevice *vbasedev,
mig_state->device_state = recover_state;
if (ioctl(vbasedev->fd, VFIO_DEVICE_FEATURE, feature)) {
- hw_error("%s: Failed setting device in recover state, err: %s",
- vbasedev->name, strerror(errno));
+ error_report(
+ "%s: Failed setting device in recover state, err: %s.
Resetting device",
+ vbasedev->name, strerror(errno));
+
+ if (ioctl(vbasedev->fd, VFIO_DEVICE_RESET)) {
+ hw_error("%s: Failed resetting device, err: %s",
vbasedev->name,
+ strerror(errno));
+ }
+
+ migration->device_state = VFIO_DEVICE_STATE_RUNNING;
+
+ return -1;
}
migration->device_state = recover_state;
--
2.21.3
- Re: [PATCH v3 01/17] migration: Remove res_compatible parameter, (continued)
[PATCH v3 10/17] vfio/migration: Move migration v1 logic to vfio_migration_init(), Avihai Horon, 2022/11/03
[PATCH v3 08/17] migration/qemu-file: Add qemu_file_get_to_fd(), Avihai Horon, 2022/11/03
[PATCH v3 13/17] vfio/migration: Remove VFIO migration protocol v1, Avihai Horon, 2022/11/03
[PATCH v3 14/17] vfio/migration: Reset device if setting recover state fails,
Avihai Horon <=
[PATCH v3 17/17] vfio/migration: Query device data size in vfio_save_pending(), Avihai Horon, 2022/11/03
[PATCH v3 15/17] vfio: Alphabetize migration section of VFIO trace-events file, Avihai Horon, 2022/11/03
[PATCH v3 02/17] migration: No save_live_pending() method uses the QEMUFile parameter, Avihai Horon, 2022/11/03
[PATCH v3 16/17] docs/devel: Align vfio-migration docs to VFIO migration v2, Avihai Horon, 2022/11/03
[PATCH v3 09/17] vfio/common: Change vfio_devices_all_running_and_saving() logic to equivalent one, Avihai Horon, 2022/11/03