Introduce a helper to end a migration stream.
Signed-off-by: Peter Xu <peterx@redhat.com>
---
migration/savevm.h | 1 +
migration/colo.c | 2 +-
migration/savevm.c | 12 +++++++++---
3 files changed, 11 insertions(+), 4 deletions(-)
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);
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);
}
--
2.50.1