Skip to content

Commit

Permalink
migration: Add the configuration vmstate to the json writer
Browse files Browse the repository at this point in the history
Make the migration json writer part of MigrationState struct, allowing
the 'configuration' object be serialized to json.

This will facilitate the parsing of the 'configuration' object in the
next patch that fixes analyze-migration.py for arm.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-ID: <20231009184326.15777-2-farosas@suse.de>
  • Loading branch information
lorddoskias authored and Juan Quintela committed Oct 16, 2023
1 parent 827225b commit b9c644e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions migration/migration.c
Original file line number Diff line number Diff line change
Expand Up @@ -1442,6 +1442,7 @@ int migrate_init(MigrationState *s, Error **errp)
error_free(s->error);
s->error = NULL;
s->hostname = NULL;
s->vmdesc = NULL;

migrate_set_state(&s->state, MIGRATION_STATUS_NONE, MIGRATION_STATUS_SETUP);

Expand Down
20 changes: 16 additions & 4 deletions migration/savevm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1217,13 +1217,27 @@ void qemu_savevm_non_migratable_list(strList **reasons)

void qemu_savevm_state_header(QEMUFile *f)
{
MigrationState *s = migrate_get_current();

s->vmdesc = json_writer_new(false);

trace_savevm_state_header();
qemu_put_be32(f, QEMU_VM_FILE_MAGIC);
qemu_put_be32(f, QEMU_VM_FILE_VERSION);

if (migrate_get_current()->send_configuration) {
if (s->send_configuration) {
qemu_put_byte(f, QEMU_VM_CONFIGURATION);
vmstate_save_state(f, &vmstate_configuration, &savevm_state, 0);

/*
* This starts the main json object and is paired with the
* json_writer_end_object in
* qemu_savevm_state_complete_precopy_non_iterable
*/
json_writer_start_object(s->vmdesc, NULL);

json_writer_start_object(s->vmdesc, "configuration");
vmstate_save_state(f, &vmstate_configuration, &savevm_state, s->vmdesc);
json_writer_end_object(s->vmdesc);
}
}

Expand Down Expand Up @@ -1272,8 +1286,6 @@ void qemu_savevm_state_setup(QEMUFile *f)
Error *local_err = NULL;
int ret;

ms->vmdesc = json_writer_new(false);
json_writer_start_object(ms->vmdesc, NULL);
json_writer_int64(ms->vmdesc, "page_size", qemu_target_page_size());
json_writer_start_array(ms->vmdesc, "devices");

Expand Down

0 comments on commit b9c644e

Please sign in to comment.