cpr-save <filename> <mode> Call qmp_cpr_save(). Arguments: filename : save vmstate to filename mode: must be "reboot"
cpr-load <filename> <mode> Call qmp_cpr_load(). Arguments: filename : load vmstate from filename mode: must be "reboot" Signed-off-by: Mark Kanda <mark.ka...@oracle.com> Signed-off-by: Steve Sistare <steven.sist...@oracle.com> --- hmp-commands.hx | 39 +++++++++++++++++++++++++++++++++++++++ include/monitor/hmp.h | 2 ++ monitor/hmp-cmds.c | 27 +++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index 564f1de..9d9f984 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -355,6 +355,45 @@ SRST ERST { + .name = "cpr-save", + .args_type = "filename:s,mode:s", + .params = "filename 'reboot'", + .help = "create a checkpoint of the VM in file", + .cmd = hmp_cpr_save, + }, + +SRST +``cpr-save`` *filename* *mode* + Pause the VCPUs, and create a checkpoint of the virtual machine device state + in *filename*. Unlike snapshot-save, this command completes synchronously, + saves state to an ordinary file, does not save guest block device blocks, + and does not require that guest RAM be saved in the file. The caller must + not modify guest block devices between cpr-save and cpr-load. + + If *mode* is 'reboot', the checkpoint remains valid after a host reboot. + The guest RAM memory-backend should be shared and non-volatile across + reboot, else it will be saved to the file. To resume from the checkpoint, + issue the quit command, reboot the system, start qemu using the same + arguments plus -S, and issue the cpr-load command. +ERST + + { + .name = "cpr-load", + .args_type = "filename:s,mode:s", + .params = "filename 'reboot'", + + .help = "load VM checkpoint from file", + .cmd = hmp_cpr_load, + }, + +SRST +``cpr-load`` *filename* *mode* + Load a virtual machine from the checkpoint file *filename* that was created + earlier by the cpr-save command, and continue the VCPUs. *mode* must match + the mode specified for cpr-save. +ERST + + { .name = "delvm", .args_type = "name:s", .params = "tag", diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index 96d0148..b44588e 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -59,6 +59,8 @@ void hmp_balloon(Monitor *mon, const QDict *qdict); void hmp_loadvm(Monitor *mon, const QDict *qdict); void hmp_savevm(Monitor *mon, const QDict *qdict); void hmp_delvm(Monitor *mon, const QDict *qdict); +void hmp_cpr_save(Monitor *mon, const QDict *qdict); +void hmp_cpr_load(Monitor *mon, const QDict *qdict); void hmp_migrate_cancel(Monitor *mon, const QDict *qdict); void hmp_migrate_continue(Monitor *mon, const QDict *qdict); void hmp_migrate_incoming(Monitor *mon, const QDict *qdict); diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 622c783..bb12589 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -33,6 +33,7 @@ #include "qapi/qapi-commands-block.h" #include "qapi/qapi-commands-char.h" #include "qapi/qapi-commands-control.h" +#include "qapi/qapi-commands-cpr.h" #include "qapi/qapi-commands-machine.h" #include "qapi/qapi-commands-migration.h" #include "qapi/qapi-commands-misc.h" @@ -1122,6 +1123,32 @@ void hmp_announce_self(Monitor *mon, const QDict *qdict) qapi_free_AnnounceParameters(params); } +void hmp_cpr_save(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + const char *filename = qdict_get_try_str(qdict, "filename"); + const char *str = qdict_get_try_str(qdict, "mode"); + CprMode mode = qapi_enum_parse(&CprMode_lookup, str, -1, &err); + + if (mode != -1) { + qmp_cpr_save(filename, mode, &err); + } + hmp_handle_error(mon, err); +} + +void hmp_cpr_load(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + const char *filename = qdict_get_try_str(qdict, "filename"); + const char *str = qdict_get_try_str(qdict, "mode"); + CprMode mode = qapi_enum_parse(&CprMode_lookup, str, -1, &err); + + if (mode != -1) { + qmp_cpr_load(filename, mode, &err); + } + hmp_handle_error(mon, err); +} + void hmp_migrate_cancel(Monitor *mon, const QDict *qdict) { qmp_migrate_cancel(NULL); -- 1.8.3.1