From a0ddc0b359375b2418213966dfbdbfab593ecc6f Mon Sep 17 00:00:00 2001 From: Wen Congyang Date: Mon, 14 Dec 2015 15:08:13 +0800 Subject: [PATCH] tools/libxl: introduction of libxl__qmp_restore to load qemu state In normal migration, the qemu state is passed to qemu as a parameter. With COLO, secondary vm is running. So we will do the following steps at every checkpoint: 1. suspend both primary vm and secondary vm 2. sync the state 3. resume both primary vm and secondary vm Primary will send qemu's state in step2, and secondary's qemu should read it and restore the state before it is resumed. We can not pass the state to qemu as a parameter because secondary QEMU is already started at this point, so we introduce libxl__qmp_restore() to do it. Signed-off-by: Yang Hongyang Signed-off-by: Wen Congyang Signed-off-by: Changlong Xie Cc: Anthony Perard Reviewed-by: Konrad Rzeszutek Wilk Acked-by: Ian Jackson --- tools/libxl/libxl_internal.h | 2 ++ tools/libxl/libxl_qmp.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 345a764d7e..fc3426a8eb 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1765,6 +1765,8 @@ _hidden int libxl__qmp_stop(libxl__gc *gc, int domid); _hidden int libxl__qmp_resume(libxl__gc *gc, int domid); /* Save current QEMU state into fd. */ _hidden int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename); +/* Load current QEMU state from file. */ +_hidden int libxl__qmp_restore(libxl__gc *gc, int domid, const char *filename); /* Set dirty bitmap logging status */ _hidden int libxl__qmp_set_global_dirty_log(libxl__gc *gc, int domid, bool enable); _hidden int libxl__qmp_insert_cdrom(libxl__gc *gc, int domid, const libxl_device_disk *disk); diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index c45702e60b..c0bdfcb83a 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -906,6 +906,16 @@ int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename) NULL, NULL); } +int libxl__qmp_restore(libxl__gc *gc, int domid, const char *state_file) +{ + libxl__json_object *args = NULL; + + qmp_parameters_add_string(gc, &args, "filename", state_file); + + return qmp_run_command(gc, domid, "xen-load-devices-state", args, + NULL, NULL); +} + static int qmp_change(libxl__gc *gc, libxl__qmp_handler *qmp, char *device, char *target, char *arg) { -- 2.30.2