Commit 2e5e075635 for qemu.org
commit 2e5e075635967d3974fc893b9f44af6e418ff858
Author: Stefan Hajnoczi <stefanha@redhat.com>
Date: Tue Oct 13 14:17:47 2026 -0400
hw/scsi-disk: move MIG_EVENT_FAILED into a new function
Move the MIG_EVENT_FAILED logic from scsi_block_migration_notifier()
into its own new scsi_block_migration_failed() function. The next commit
adds logic for handling another event, so doing that in dedicated
functions makes the code easier to read.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Link: https://lore.kernel.org/r/20261013181752.1299456-4-stefanha@redhat.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index deb33ac1dd..3d88e57ede 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -2761,20 +2761,26 @@ static SCSIRequest *scsi_new_request(SCSIDevice *d, uint32_t tag, uint32_t lun,
* fails because the destination may have already preempted and we need to get
* the reservation back.
*/
+static void scsi_block_migration_failed(SCSIDiskState *s)
+{
+ SCSIDevice *d = &s->qdev;
+ Error *local_err = NULL;
+
+ if (!scsi_generic_pr_state_preempt(d, &local_err)) {
+ /* MIG_EVENT_FAILED cannot fail, so just warn */
+ error_prepend(&local_err, "scsi-block migration rollback: ");
+ warn_report_err(local_err);
+ }
+}
+
static int scsi_block_migration_notifier(NotifierWithReturn *notifier,
MigrationEvent *e, Error **errp)
{
- if (e->type == MIG_EVENT_FAILED) {
- SCSIDiskState *s =
- container_of(notifier, SCSIDiskState, migration_notifier);
- SCSIDevice *d = &s->qdev;
- Error *local_err = NULL;
+ SCSIDiskState *s =
+ container_of(notifier, SCSIDiskState, migration_notifier);
- if (!scsi_generic_pr_state_preempt(d, &local_err)) {
- /* MIG_EVENT_FAILED cannot fail, so just warn */
- error_prepend(&local_err, "scsi-block migration rollback: ");
- warn_report_err(local_err);
- }
+ if (e->type == MIG_EVENT_FAILED) {
+ scsi_block_migration_failed(s);
}
return 0;
}