[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH for-9.1 v5 02/14] vfio: Always report an error in vfio_save_setup
From: |
Cédric Le Goater |
Subject: |
[PATCH for-9.1 v5 02/14] vfio: Always report an error in vfio_save_setup() |
Date: |
Wed, 20 Mar 2024 07:48:58 +0100 |
This will prepare ground for future changes adding an Error** argument
to the save_setup() handler. We need to make sure that on failure,
vfio_save_setup() always sets a new error.
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
hw/vfio/migration.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
index
1149c6b3740f7f7bb8febdedf435be1adb223e59..bf5a29ddc15b0dbc7ae9c44f289539dd0cdddb0d
100644
--- a/hw/vfio/migration.c
+++ b/hw/vfio/migration.c
@@ -381,6 +381,7 @@ static int vfio_save_setup(QEMUFile *f, void *opaque)
VFIODevice *vbasedev = opaque;
VFIOMigration *migration = vbasedev->migration;
uint64_t stop_copy_size = VFIO_MIG_DEFAULT_DATA_BUFFER_SIZE;
+ int ret;
qemu_put_be64(f, VFIO_MIG_FLAG_DEV_SETUP_STATE);
@@ -395,13 +396,13 @@ static int vfio_save_setup(QEMUFile *f, void *opaque)
}
if (vfio_precopy_supported(vbasedev)) {
- int ret;
-
switch (migration->device_state) {
case VFIO_DEVICE_STATE_RUNNING:
ret = vfio_migration_set_state(vbasedev,
VFIO_DEVICE_STATE_PRE_COPY,
VFIO_DEVICE_STATE_RUNNING);
if (ret) {
+ error_report("%s: Failed to set new PRE_COPY state",
+ vbasedev->name);
return ret;
}
@@ -412,6 +413,8 @@ static int vfio_save_setup(QEMUFile *f, void *opaque)
/* vfio_save_complete_precopy() will go to STOP_COPY */
break;
default:
+ error_report("%s: Invalid device state %d", vbasedev->name,
+ migration->device_state);
return -EINVAL;
}
}
@@ -420,7 +423,13 @@ static int vfio_save_setup(QEMUFile *f, void *opaque)
qemu_put_be64(f, VFIO_MIG_FLAG_END_OF_STATE);
- return qemu_file_get_error(f);
+ ret = qemu_file_get_error(f);
+ if (ret < 0) {
+ error_report("%s: save setup failed : %s", vbasedev->name,
+ strerror(-ret));
+ }
+
+ return ret;
}
static void vfio_save_cleanup(void *opaque)
--
2.44.0
- [PATCH for-9.1 v5 00/14] migration: Improve error reporting, Cédric Le Goater, 2024/03/20
- [PATCH for-9.1 v5 02/14] vfio: Always report an error in vfio_save_setup(),
Cédric Le Goater <=
- [PATCH for-9.1 v5 01/14] s390/stattrib: Add Error** argument to set_migrationmode() handler, Cédric Le Goater, 2024/03/20
- [PATCH for-9.1 v5 03/14] migration: Always report an error in block_save_setup(), Cédric Le Goater, 2024/03/20
- [PATCH for-9.1 v5 05/14] migration: Add Error** argument to vmstate_save(), Cédric Le Goater, 2024/03/20
- [PATCH for-9.1 v5 06/14] migration: Add Error** argument to qemu_savevm_state_setup(), Cédric Le Goater, 2024/03/20
- [PATCH for-9.1 v5 04/14] migration: Always report an error in ram_save_setup(), Cédric Le Goater, 2024/03/20
- [PATCH for-9.1 v5 08/14] migration: Add Error** argument to .load_setup() handler, Cédric Le Goater, 2024/03/20
- [PATCH for-9.1 v5 07/14] migration: Add Error** argument to .save_setup() handler, Cédric Le Goater, 2024/03/20