mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-16 06:31:51 -06:00
migration/savevm: Prepare vmdesc json writer in qemu_savevm_state_setup()
... and store it in the migration state. This is a preparation for storing selected vmds's already in qemu_savevm_state_setup(). Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
parent
5e104f24e7
commit
e3bf5e68e2
3 changed files with 18 additions and 6 deletions
|
@ -1933,6 +1933,8 @@ static void migrate_fd_cleanup(MigrationState *s)
|
||||||
|
|
||||||
g_free(s->hostname);
|
g_free(s->hostname);
|
||||||
s->hostname = NULL;
|
s->hostname = NULL;
|
||||||
|
json_writer_free(s->vmdesc);
|
||||||
|
s->vmdesc = NULL;
|
||||||
|
|
||||||
qemu_savevm_state_cleanup();
|
qemu_savevm_state_cleanup();
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "exec/cpu-common.h"
|
#include "exec/cpu-common.h"
|
||||||
#include "hw/qdev-core.h"
|
#include "hw/qdev-core.h"
|
||||||
#include "qapi/qapi-types-migration.h"
|
#include "qapi/qapi-types-migration.h"
|
||||||
|
#include "qapi/qmp/json-writer.h"
|
||||||
#include "qemu/thread.h"
|
#include "qemu/thread.h"
|
||||||
#include "qemu/coroutine_int.h"
|
#include "qemu/coroutine_int.h"
|
||||||
#include "io/channel.h"
|
#include "io/channel.h"
|
||||||
|
@ -366,6 +367,9 @@ struct MigrationState {
|
||||||
* This save hostname when out-going migration starts
|
* This save hostname when out-going migration starts
|
||||||
*/
|
*/
|
||||||
char *hostname;
|
char *hostname;
|
||||||
|
|
||||||
|
/* QEMU_VM_VMDESCRIPTION content filled for all non-iterable devices. */
|
||||||
|
JSONWriter *vmdesc;
|
||||||
};
|
};
|
||||||
|
|
||||||
void migrate_set_state(int *state, int old_state, int new_state);
|
void migrate_set_state(int *state, int old_state, int new_state);
|
||||||
|
|
|
@ -42,7 +42,6 @@
|
||||||
#include "postcopy-ram.h"
|
#include "postcopy-ram.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "qapi/qapi-commands-migration.h"
|
#include "qapi/qapi-commands-migration.h"
|
||||||
#include "qapi/qmp/json-writer.h"
|
|
||||||
#include "qapi/clone-visitor.h"
|
#include "qapi/clone-visitor.h"
|
||||||
#include "qapi/qapi-builtin-visit.h"
|
#include "qapi/qapi-builtin-visit.h"
|
||||||
#include "qapi/qmp/qerror.h"
|
#include "qapi/qmp/qerror.h"
|
||||||
|
@ -1190,10 +1189,16 @@ bool qemu_savevm_state_guest_unplug_pending(void)
|
||||||
|
|
||||||
void qemu_savevm_state_setup(QEMUFile *f)
|
void qemu_savevm_state_setup(QEMUFile *f)
|
||||||
{
|
{
|
||||||
|
MigrationState *ms = migrate_get_current();
|
||||||
SaveStateEntry *se;
|
SaveStateEntry *se;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
int ret;
|
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");
|
||||||
|
|
||||||
trace_savevm_state_setup();
|
trace_savevm_state_setup();
|
||||||
QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
|
QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
|
||||||
if (!se->ops || !se->ops->save_setup) {
|
if (!se->ops || !se->ops->save_setup) {
|
||||||
|
@ -1391,15 +1396,12 @@ int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f,
|
||||||
bool in_postcopy,
|
bool in_postcopy,
|
||||||
bool inactivate_disks)
|
bool inactivate_disks)
|
||||||
{
|
{
|
||||||
g_autoptr(JSONWriter) vmdesc = NULL;
|
MigrationState *ms = migrate_get_current();
|
||||||
|
JSONWriter *vmdesc = ms->vmdesc;
|
||||||
int vmdesc_len;
|
int vmdesc_len;
|
||||||
SaveStateEntry *se;
|
SaveStateEntry *se;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
vmdesc = json_writer_new(false);
|
|
||||||
json_writer_start_object(vmdesc, NULL);
|
|
||||||
json_writer_int64(vmdesc, "page_size", qemu_target_page_size());
|
|
||||||
json_writer_start_array(vmdesc, "devices");
|
|
||||||
QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
|
QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
|
||||||
ret = vmstate_save(f, se, vmdesc);
|
ret = vmstate_save(f, se, vmdesc);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
@ -1434,6 +1436,10 @@ int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f,
|
||||||
qemu_put_buffer(f, (uint8_t *)json_writer_get(vmdesc), vmdesc_len);
|
qemu_put_buffer(f, (uint8_t *)json_writer_get(vmdesc), vmdesc_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Free it now to detect any inconsistencies. */
|
||||||
|
json_writer_free(vmdesc);
|
||||||
|
ms->vmdesc = NULL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue