From: Peter Xu Date: Tue, 27 Jan 2026 18:52:44 +0000 (-0500) Subject: migration: Introduce qemu_savevm_state_end() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c3bc01feb82a3cd870b09e9131ecec1aff22c868;p=thirdparty%2Fqemu.git migration: Introduce qemu_savevm_state_end() Introduce a helper to end a migration stream. Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas Tested-by: Lukas Straub Link: https://lore.kernel.org/qemu-devel/20260127185254.3954634-15-peterx@redhat.com Signed-off-by: Fabiano Rosas --- diff --git a/migration/colo.c b/migration/colo.c index 0b1a58cd8f..db804b25a9 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -470,7 +470,7 @@ static int colo_do_checkpoint_transaction(MigrationState *s, * to be blocked here. */ qemu_savevm_state_complete_precopy_iterable(s->to_dst_file, false); - qemu_put_byte(s->to_dst_file, QEMU_VM_EOF); + qemu_savevm_state_end(s->to_dst_file); /* * We need the size of the VMstate data in Secondary side, diff --git a/migration/savevm.c b/migration/savevm.c index d41e89228d..a787691352 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1065,6 +1065,12 @@ static int vmstate_save(QEMUFile *f, SaveStateEntry *se, JSONWriter *vmdesc, } return 0; } + +void qemu_savevm_state_end(QEMUFile *f) +{ + qemu_put_byte(f, QEMU_VM_EOF); +} + /** * qemu_savevm_command_send: Send a 'QEMU_VM_COMMAND' type element with the * command and associated data. @@ -1555,7 +1561,7 @@ void qemu_savevm_state_complete_postcopy(QEMUFile *f) } } - qemu_put_byte(f, QEMU_VM_EOF); + qemu_savevm_state_end(f); qemu_fflush(f); } @@ -1699,7 +1705,7 @@ int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f, if (!in_postcopy) { /* Postcopy stream will still be going */ - qemu_put_byte(f, QEMU_VM_EOF); + qemu_savevm_state_end(f); if (vmdesc) { json_writer_end_array(vmdesc); @@ -1879,7 +1885,7 @@ int qemu_save_device_state(QEMUFile *f) } } - qemu_put_byte(f, QEMU_VM_EOF); + qemu_savevm_state_end(f); return qemu_file_get_error(f); } diff --git a/migration/savevm.h b/migration/savevm.h index ea01ca63ec..d0596d1d62 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -49,6 +49,7 @@ void qemu_savevm_state_pending_estimate(uint64_t *must_precopy, uint64_t *can_postcopy); int qemu_savevm_state_complete_precopy_iterable(QEMUFile *f, bool in_postcopy); bool qemu_savevm_state_postcopy_prepare(QEMUFile *f, Error **errp); +void qemu_savevm_state_end(QEMUFile *f); void qemu_savevm_send_ping(QEMUFile *f, uint32_t value); void qemu_savevm_send_open_return_path(QEMUFile *f); int qemu_savevm_send_packaged(QEMUFile *f, const uint8_t *buf, size_t len);