This patch introduces the mechanism to update the sleep interval - sinterval.
Signed-off-by: Sanidhya Kashyap <sanidhya.ii...@gmail.com> --- hmp-commands.hx | 15 +++++++++++++++ hmp.c | 14 ++++++++++++++ hmp.h | 1 + qapi-schema.json | 10 ++++++++++ qmp-commands.hx | 22 ++++++++++++++++++++++ savevm.c | 13 +++++++++++++ 6 files changed, 75 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index c492f3f..efe4354 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1803,6 +1803,21 @@ STEXI dumps and reads the device state's data from the memory for testing purpose ETEXI + { + .name = "test-vmstates-set-sinterval", + .args_type = "sinterval:i", + .params = "sinterval", + .help = "set the sleep interval for vmstates testing process\n\t\t\t" + "sinterval: the new sleep interval value to replace the existing", + .mhandler.cmd = hmp_test_vmstates_set_sinterval, + }, + +STEXI +@item test_vmstates-set-sinterval @var{sinterval} +@findex test-vmstates-set-sinterval +Set the sinterval to @var{sinterval} (int) for vmstate testing process. +ETEXI + STEXI @end table ETEXI diff --git a/hmp.c b/hmp.c index 38ec5b3..7378727 100644 --- a/hmp.c +++ b/hmp.c @@ -1728,3 +1728,17 @@ void hmp_test_vmstates(Monitor *mon, const QDict *qdict) error_free(err); } } + +void hmp_test_vmstates_set_sinterval(Monitor *mon, const QDict *qdict) +{ + int64_t sleep_interval = qdict_get_int(qdict, "sinterval"); + Error *err = NULL; + + qmp_test_vmstates_set_sinterval(sleep_interval, &err); + + if (err) { + monitor_printf(mon, "test-vmstates-set-frequency: %s\n", + error_get_pretty(err)); + error_free(err); + } +} diff --git a/hmp.h b/hmp.h index 9f00997..737dae2 100644 --- a/hmp.h +++ b/hmp.h @@ -95,6 +95,7 @@ void hmp_object_add(Monitor *mon, const QDict *qdict); void hmp_object_del(Monitor *mon, const QDict *qdict); void hmp_info_memdev(Monitor *mon, const QDict *qdict); void hmp_test_vmstates(Monitor *mon, const QDict *qdict); +void hmp_test_vmstates_set_sinterval(Monitor *mon, const QDict *qdict); void object_add_completion(ReadLineState *rs, int nb_args, const char *str); void object_del_completion(ReadLineState *rs, int nb_args, const char *str); void device_add_completion(ReadLineState *rs, int nb_args, const char *str); diff --git a/qapi-schema.json b/qapi-schema.json index 92acf91..2eb8bc4 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3492,3 +3492,13 @@ { 'command': 'test-vmstates', 'data': {'*times' : 'int', '*sinterval' : 'int' } } + +## @test-vmstates-set-sinterval +# +# sets the sleep interval between iterations of the vmstate testing process +# @sinterval: the updated sleep interval value +# +# Since 2.1 +## +{ 'command' : 'test-vmstates-set-sinterval', + 'data' : { 'sinterval': 'int' } } diff --git a/qmp-commands.hx b/qmp-commands.hx index ccddabb..2c25dde 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -3783,3 +3783,25 @@ Example: "sinterval": 100 } } <- { "return": {} } EQMP + + { + .name = "test-vmstates-set-sinterval", + .args_type = "sinterval:i", + .mhandler.cmd_new = qmp_marshal_input_test_vmstates_set_sinterval, + }, + +SQMP +test-vmstates-set-sinterval +-------------------- + +Update the sleep interval for the remaining iterations + +Arguments: + +- "sinterval": the updated sleep interval between iterations (json-int) + +Example: + +-> { "execute": "test-vmstates-set-sinterval", "arguments": { "sinterval": 1024 } } +<- { "return": {} } +EQMP diff --git a/savevm.c b/savevm.c index 3713a56..8a81355 100644 --- a/savevm.c +++ b/savevm.c @@ -1285,6 +1285,19 @@ void qmp_test_vmstates(bool has_times, int64_t times, timer_mod(v->timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME)); } +void qmp_test_vmstates_set_sinterval(int64_t sinterval, Error **errp) +{ + VMStateLogState *v = vmstate_current_state(); + if (sinterval < TEST_VMSTATE_MIN_INTERVAL_MS || + sinterval > TEST_VMSTATE_MAX_INTERVAL_MS) { + error_setg(errp, "sleep interval value must be " + "in the defined range [%d, %d](ms)\n", + TEST_VMSTATE_MIN_INTERVAL_MS, TEST_VMSTATE_MAX_INTERVAL_MS); + return; + } + v->sleep_interval = sinterval; +} + void qmp_xen_save_devices_state(const char *filename, Error **errp) { QEMUFile *f; -- 1.9.3