[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 13/30] migration/savevm: Prepare vmdesc json writer in qemu_savevm
From: |
Juan Quintela |
Subject: |
[PULL 13/30] migration/savevm: Prepare vmdesc json writer in qemu_savevm_state_setup() |
Date: |
Tue, 7 Feb 2023 01:56:33 +0100 |
From: David Hildenbrand <david@redhat.com>
... 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>
---
migration/migration.h | 4 ++++
migration/migration.c | 2 ++
migration/savevm.c | 18 ++++++++++++------
3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/migration/migration.h b/migration/migration.h
index ae4ffd3454..66511ce532 100644
--- a/migration/migration.h
+++ b/migration/migration.h
@@ -17,6 +17,7 @@
#include "exec/cpu-common.h"
#include "hw/qdev-core.h"
#include "qapi/qapi-types-migration.h"
+#include "qapi/qmp/json-writer.h"
#include "qemu/thread.h"
#include "qemu/coroutine_int.h"
#include "io/channel.h"
@@ -366,6 +367,9 @@ struct MigrationState {
* This save hostname when out-going migration starts
*/
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);
diff --git a/migration/migration.c b/migration/migration.c
index 6d4cd8083b..c3ad4cd670 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1933,6 +1933,8 @@ static void migrate_fd_cleanup(MigrationState *s)
g_free(s->hostname);
s->hostname = NULL;
+ json_writer_free(s->vmdesc);
+ s->vmdesc = NULL;
qemu_savevm_state_cleanup();
diff --git a/migration/savevm.c b/migration/savevm.c
index 3e3631652e..28f88b5521 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -42,7 +42,6 @@
#include "postcopy-ram.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-migration.h"
-#include "qapi/qmp/json-writer.h"
#include "qapi/clone-visitor.h"
#include "qapi/qapi-builtin-visit.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)
{
+ MigrationState *ms = migrate_get_current();
SaveStateEntry *se;
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");
+
trace_savevm_state_setup();
QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
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 inactivate_disks)
{
- g_autoptr(JSONWriter) vmdesc = NULL;
+ MigrationState *ms = migrate_get_current();
+ JSONWriter *vmdesc = ms->vmdesc;
int vmdesc_len;
SaveStateEntry *se;
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) {
ret = vmstate_save(f, se, vmdesc);
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);
}
+ /* Free it now to detect any inconsistencies. */
+ json_writer_free(vmdesc);
+ ms->vmdesc = NULL;
+
return 0;
}
--
2.39.1
- Re: [PULL 03/30] migration: Split save_live_pending() into state_pending_*, (continued)
- [PULL 02/30] migration: No save_live_pending() method uses the QEMUFile parameter, Juan Quintela, 2023/02/06
- [PULL 05/30] migration: simplify migration_iteration_run(), Juan Quintela, 2023/02/06
- [PULL 04/30] migration: Remove unused threshold_size parameter, Juan Quintela, 2023/02/06
- [PULL 06/30] util/userfaultfd: Add uffd_open(), Juan Quintela, 2023/02/06
- [PULL 07/30] migration/ram: Fix populate_read_range(), Juan Quintela, 2023/02/06
- [PULL 08/30] migration/ram: Fix error handling in ram_write_tracking_start(), Juan Quintela, 2023/02/06
- [PULL 09/30] migration/ram: Don't explicitly unprotect when unregistering uffd-wp, Juan Quintela, 2023/02/06
- [PULL 10/30] migration/ram: Rely on used_length for uffd_change_protection(), Juan Quintela, 2023/02/06
- [PULL 11/30] migration/ram: Optimize ram_write_tracking_start() for RamDiscardManager, Juan Quintela, 2023/02/06
- [PULL 13/30] migration/savevm: Prepare vmdesc json writer in qemu_savevm_state_setup(),
Juan Quintela <=
- [PULL 12/30] migration/savevm: Move more savevm handling into vmstate_save(), Juan Quintela, 2023/02/06
- [PULL 14/30] migration/savevm: Allow immutable device state to be migrated early (i.e., before RAM), Juan Quintela, 2023/02/06
- [PULL 16/30] migration/ram: Factor out check for advised postcopy, Juan Quintela, 2023/02/06
- [PULL 15/30] migration/vmstate: Introduce VMSTATE_WITH_TMP_TEST() and VMSTATE_BITMAP_TEST(), Juan Quintela, 2023/02/06
- [PULL 17/30] virtio-mem: Fail if a memory backend with "prealloc=on" is specified, Juan Quintela, 2023/02/06
- [PULL 18/30] virtio-mem: Migrate immutable properties early, Juan Quintela, 2023/02/06
- [PULL 19/30] virtio-mem: Proper support for preallocation with migration, Juan Quintela, 2023/02/06
- [PULL 20/30] migration: Show downtime during postcopy phase, Juan Quintela, 2023/02/06
- [PULL 21/30] migration/rdma: fix return value for qio_channel_rdma_{readv, writev}, Juan Quintela, 2023/02/06
- [PULL 22/30] migration: Add canary to VMSTATE_END_OF_LIST, Juan Quintela, 2023/02/06