mirror of
https://gitlab.com/qemu-project/qemu.git
synced 2026-10-28 14:04:39 +08:00
In fast snapshot load a thread is needed for actively loading in pages along with the fault path so that the guest is not dependent on fault thread indefinitely. Considering the difference from usual network postcopy where major chunk of RAM is already loaded here entire RAM needs to be loaded later. Existance of background pages which are not really accessed by the guest might never be loaded and system will be locked in migration for indefinite time. As there should be no assumption about how guest accesses memory, the load times can be indefinite. Add postcopy_ram_eager_load_thread(), for the eager thread which iterates over all non ignored blocks calling ram_block_load_eager() on each. ram_block_load_eager then iterates to load in all pages using postcopy_mapped_ram_load_page(), with a different channel, which takes care of not loading in pages already loaded by fault thread. On completion the thread schedules postcopy_incoming_complete_bh() to destroy the incoming migration state. Add postcopy_ram_eager_load_setup() to create the thread. Added joining logic in postcopy_incoming_cleanup(). Add tracepoints for entry and exit to eager load thread. When both mapped-ram and postcopy-ram are set, divert from qemu_loadvm_state to run fast snapshot load Initialize postcopy RAM state and register RAM Blocks with userfaultfd via ram_postcopy_incoming_init() and postcopy_ram_incoming_setup() in process_incoming_migration_co(). Fault thread needs to be launched before VM to serve faults for some hardwares emulation that need to read RAM (like vapic devices). Populate bitmaps and offset tables while reading file in qemu_loadvm_state_main. Add function qemu_loadvm_run_fast_snapshot_load() which starts the VM using loadvm_postcopy_handle_run_bh() and launches eager load thread. Skip scheduling process_incoming_migration_bh() in process_incoming_migration_co(), for fast snapshot load as the state cleanup is managed by eager load thread on completion. Signed-off-by: Aadeshveer Singh <aadeshveer07@gmail.com> Reviewed-by: Peter Xu <peterx@redhat.com> Reviewed-by: Juraj Marcin <jmarcin@redhat.com> Signed-off-by: Peter Xu <peterx@redhat.com> Signed-off-by: Fabiano Rosas <farosas@suse.de>
87 lines
3.7 KiB
C
87 lines
3.7 KiB
C
/*
|
|
* QEMU save vm functions
|
|
*
|
|
* Copyright (c) 2003-2008 Fabrice Bellard
|
|
* Copyright (c) 2009-2017 Red Hat Inc
|
|
*
|
|
* Authors:
|
|
* Juan Quintela <quintela@redhat.com>
|
|
*
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
* See the COPYING file in the top-level directory.
|
|
*/
|
|
|
|
#ifndef MIGRATION_SAVEVM_H
|
|
#define MIGRATION_SAVEVM_H
|
|
|
|
#include "migration/register.h"
|
|
|
|
#define QEMU_VM_FILE_MAGIC 0x5145564d
|
|
#define QEMU_VM_FILE_VERSION_COMPAT 0x00000002
|
|
#define QEMU_VM_FILE_VERSION 0x00000003
|
|
|
|
#define QEMU_VM_EOF 0x00
|
|
#define QEMU_VM_SECTION_START 0x01
|
|
#define QEMU_VM_SECTION_PART 0x02
|
|
#define QEMU_VM_SECTION_END 0x03
|
|
#define QEMU_VM_SECTION_FULL 0x04
|
|
#define QEMU_VM_SUBSECTION 0x05
|
|
#define QEMU_VM_VMDESCRIPTION 0x06
|
|
#define QEMU_VM_CONFIGURATION 0x07
|
|
#define QEMU_VM_COMMAND 0x08
|
|
#define QEMU_VM_SECTION_FOOTER 0x7e
|
|
|
|
#define QEMU_VM_PING_PACKAGED_LOADED 0x42
|
|
|
|
bool qemu_savevm_state_blocked(Error **errp);
|
|
void qemu_savevm_non_migratable_list(strList **reasons);
|
|
int qemu_savevm_state_prepare(Error **errp);
|
|
int qemu_savevm_state_do_setup(QEMUFile *f, Error **errp);
|
|
bool qemu_savevm_state_guest_unplug_pending(void);
|
|
int qemu_savevm_state_resume_prepare(MigrationState *s);
|
|
void qemu_savevm_send_header(QEMUFile *f);
|
|
void qemu_savevm_state_header(QEMUFile *f);
|
|
int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy);
|
|
void qemu_savevm_state_cleanup(void);
|
|
void qemu_savevm_state_complete_postcopy(QEMUFile *f);
|
|
bool qemu_savevm_state_complete_precopy(MigrationState *s, Error **errp);
|
|
void qemu_savevm_query_pending_iter(MigrationState *s, MigPendingData *pending,
|
|
bool exact);
|
|
bool qemu_savevm_query_pending_final(MigrationState *s,
|
|
MigPendingData *pending, Error **errp);
|
|
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_state_end_precopy(MigrationState *s, 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);
|
|
void qemu_savevm_send_postcopy_advise(QEMUFile *f);
|
|
void qemu_savevm_send_postcopy_listen(QEMUFile *f);
|
|
void qemu_savevm_send_postcopy_run(QEMUFile *f);
|
|
void qemu_savevm_send_postcopy_resume(QEMUFile *f);
|
|
void qemu_savevm_send_recv_bitmap(QEMUFile *f, char *block_name);
|
|
void qemu_savevm_maybe_send_switchover_start(QEMUFile *f);
|
|
|
|
void qemu_savevm_send_postcopy_ram_discard(QEMUFile *f, const char *name,
|
|
uint16_t len,
|
|
uint64_t *start_list,
|
|
uint64_t *length_list);
|
|
int qemu_save_device_state(QEMUFile *f, Error **errp);
|
|
int qemu_loadvm_state(QEMUFile *f, Error **errp);
|
|
void qemu_loadvm_state_cleanup(MigrationIncomingState *mis);
|
|
void qemu_loadvm_run_fast_snapshot_load(QEMUFile *f,
|
|
MigrationIncomingState *mis);
|
|
int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis,
|
|
Error **errp);
|
|
int qemu_load_device_state(QEMUFile *f, Error **errp);
|
|
int qemu_loadvm_approve_switchover(const char *approver);
|
|
bool qemu_savevm_state_non_iterable(QEMUFile *f, Error **errp);
|
|
int qemu_savevm_state_non_iterable_early(QEMUFile *f,
|
|
JSONWriter *vmdesc,
|
|
Error **errp);
|
|
bool qemu_loadvm_load_state_buffer(const char *idstr, uint32_t instance_id,
|
|
char *buf, size_t len, Error **errp);
|
|
|
|
#endif
|