]> git.proxmox.com Git - mirror_qemu.git/commitdiff
migration: Do not call PRECOPY_NOTIFY_SETUP notifiers in case of error
authorCédric Le Goater <clg@redhat.com>
Mon, 4 Mar 2024 12:28:27 +0000 (13:28 +0100)
committerPeter Xu <peterx@redhat.com>
Mon, 11 Mar 2024 18:41:40 +0000 (14:41 -0400)
When commit bd2270608fa0 ("migration/ram.c: add a notifier chain for
precopy") added PRECOPY_NOTIFY_SETUP notifiers at the end of
qemu_savevm_state_setup(), it didn't take into account a possible
error in the loop calling vmstate_save() or .save_setup() handlers.

Check ret value before calling the notifiers.

Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
Link: https://lore.kernel.org/r/20240304122844.1888308-10-clg@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
migration/savevm.c

index e84b26e1c88f74394b721337ebdf590300db4eeb..76b57a9888d0b1ddc71863ed75d5addc506d238b 100644 (file)
@@ -1317,7 +1317,7 @@ void qemu_savevm_state_setup(QEMUFile *f)
     MigrationState *ms = migrate_get_current();
     SaveStateEntry *se;
     Error *local_err = NULL;
-    int ret;
+    int ret = 0;
 
     json_writer_int64(ms->vmdesc, "page_size", qemu_target_page_size());
     json_writer_start_array(ms->vmdesc, "devices");
@@ -1351,6 +1351,10 @@ void qemu_savevm_state_setup(QEMUFile *f)
         }
     }
 
+    if (ret) {
+        return;
+    }
+
     if (precopy_notify(PRECOPY_NOTIFY_SETUP, &local_err)) {
         error_report_err(local_err);
     }