migration: Introduce qemu_savevm_state_end()

Introduce a helper to end a migration stream.

Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Tested-by: Lukas Straub <lukasstraub2@web.de>
Link: https://lore.kernel.org/qemu-devel/20260127185254.3954634-15-peterx@redhat.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
This commit is contained in:
Peter Xu
2026-01-27 13:52:44 -05:00
committed by Fabiano Rosas
parent 7e188607fa
commit c3bc01feb8
3 changed files with 11 additions and 4 deletions

View File

@@ -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,

View File

@@ -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);
}

View File

@@ -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);