mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
savevm: Live migration handlers register the struct directly
Notice that the live migration users never unregister, so no problem about freeing the ops structure. Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
parent
22ea40f4ff
commit
7908c78d3e
6 changed files with 26 additions and 23 deletions
|
@ -298,7 +298,7 @@ static void migration_end(void)
|
|||
|
||||
#define MAX_WAIT 50 /* ms, half buffered_file limit */
|
||||
|
||||
int ram_save_live(QEMUFile *f, int stage, void *opaque)
|
||||
static int ram_save_live(QEMUFile *f, int stage, void *opaque)
|
||||
{
|
||||
ram_addr_t addr;
|
||||
uint64_t bytes_transferred_last;
|
||||
|
@ -437,7 +437,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int ram_load(QEMUFile *f, void *opaque, int version_id)
|
||||
static int ram_load(QEMUFile *f, void *opaque, int version_id)
|
||||
{
|
||||
ram_addr_t addr;
|
||||
int flags, ret = 0;
|
||||
|
@ -534,6 +534,11 @@ done:
|
|||
return ret;
|
||||
}
|
||||
|
||||
SaveVMHandlers savevm_ram_handlers = {
|
||||
.save_live_state = ram_save_live,
|
||||
.load_state = ram_load,
|
||||
};
|
||||
|
||||
#ifdef HAS_AUDIO
|
||||
struct soundhw {
|
||||
const char *name;
|
||||
|
|
|
@ -709,11 +709,17 @@ static void block_set_params(const MigrationParams *params, void *opaque)
|
|||
block_mig_state.blk_enable |= params->shared;
|
||||
}
|
||||
|
||||
SaveVMHandlers savevm_block_handlers = {
|
||||
.set_params = block_set_params,
|
||||
.save_live_state = block_save_live,
|
||||
.load_state = block_load,
|
||||
};
|
||||
|
||||
void blk_mig_init(void)
|
||||
{
|
||||
QSIMPLEQ_INIT(&block_mig_state.bmds_list);
|
||||
QSIMPLEQ_INIT(&block_mig_state.blk_list);
|
||||
|
||||
register_savevm_live(NULL, "block", 0, 1, block_set_params,
|
||||
block_save_live, NULL, block_load, &block_mig_state);
|
||||
register_savevm_live(NULL, "block", 0, 1, &savevm_block_handlers,
|
||||
&block_mig_state);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "qemu-common.h"
|
||||
#include "notify.h"
|
||||
#include "error.h"
|
||||
#include "vmstate.h"
|
||||
|
||||
struct MigrationParams {
|
||||
bool blk;
|
||||
|
@ -81,8 +82,7 @@ uint64_t ram_bytes_remaining(void);
|
|||
uint64_t ram_bytes_transferred(void);
|
||||
uint64_t ram_bytes_total(void);
|
||||
|
||||
int ram_save_live(QEMUFile *f, int stage, void *opaque);
|
||||
int ram_load(QEMUFile *f, void *opaque, int version_id);
|
||||
extern SaveVMHandlers savevm_ram_handlers;
|
||||
|
||||
/**
|
||||
* @migrate_add_blocker - prevent migration from proceeding
|
||||
|
|
18
savevm.c
18
savevm.c
|
@ -1223,10 +1223,7 @@ int register_savevm_live(DeviceState *dev,
|
|||
const char *idstr,
|
||||
int instance_id,
|
||||
int version_id,
|
||||
SaveSetParamsHandler *set_params,
|
||||
SaveLiveStateHandler *save_live_state,
|
||||
SaveStateHandler *save_state,
|
||||
LoadStateHandler *load_state,
|
||||
SaveVMHandlers *ops,
|
||||
void *opaque)
|
||||
{
|
||||
SaveStateEntry *se;
|
||||
|
@ -1234,16 +1231,12 @@ int register_savevm_live(DeviceState *dev,
|
|||
se = g_malloc0(sizeof(SaveStateEntry));
|
||||
se->version_id = version_id;
|
||||
se->section_id = global_section_id++;
|
||||
se->ops = g_malloc0(sizeof(SaveVMHandlers));
|
||||
se->ops->set_params = set_params;
|
||||
se->ops->save_live_state = save_live_state;
|
||||
se->ops->save_state = save_state;
|
||||
se->ops->load_state = load_state;
|
||||
se->ops = ops;
|
||||
se->opaque = opaque;
|
||||
se->vmsd = NULL;
|
||||
se->no_migrate = 0;
|
||||
/* if this is a live_savem then set is_ram */
|
||||
if (save_live_state != NULL) {
|
||||
if (ops->save_live_state != NULL) {
|
||||
se->is_ram = 1;
|
||||
}
|
||||
|
||||
|
@ -1282,8 +1275,11 @@ int register_savevm(DeviceState *dev,
|
|||
LoadStateHandler *load_state,
|
||||
void *opaque)
|
||||
{
|
||||
SaveVMHandlers *ops = g_malloc0(sizeof(SaveVMHandlers));
|
||||
ops->save_state = save_state;
|
||||
ops->load_state = load_state;
|
||||
return register_savevm_live(dev, idstr, instance_id, version_id,
|
||||
NULL, NULL, save_state, load_state, opaque);
|
||||
ops, opaque);
|
||||
}
|
||||
|
||||
void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque)
|
||||
|
|
3
vl.c
3
vl.c
|
@ -3437,8 +3437,7 @@ int main(int argc, char **argv, char **envp)
|
|||
default_drive(default_sdcard, snapshot, machine->use_scsi,
|
||||
IF_SD, 0, SD_OPTS);
|
||||
|
||||
register_savevm_live(NULL, "ram", 0, 4, NULL, ram_save_live, NULL,
|
||||
ram_load, NULL);
|
||||
register_savevm_live(NULL, "ram", 0, 4, &savevm_ram_handlers, NULL);
|
||||
|
||||
if (nb_numa_nodes > 0) {
|
||||
int i;
|
||||
|
|
|
@ -50,10 +50,7 @@ int register_savevm_live(DeviceState *dev,
|
|||
const char *idstr,
|
||||
int instance_id,
|
||||
int version_id,
|
||||
SaveSetParamsHandler *set_params,
|
||||
SaveLiveStateHandler *save_live_state,
|
||||
SaveStateHandler *save_state,
|
||||
LoadStateHandler *load_state,
|
||||
SaveVMHandlers *ops,
|
||||
void *opaque);
|
||||
|
||||
void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque);
|
||||
|
|
Loading…
Reference in a new issue