Signed-off-by: Sanidhya Kashyap <sanidhya.ii...@gmail.com> --- hmp-commands.hx | 15 +++++++++++++++ hmp.c | 14 ++++++++++++++ hmp.h | 1 + qapi-schema.json | 12 ++++++++++++ qmp-commands.hx | 21 +++++++++++++++++++++ savevm.c | 13 +++++++++++++ 6 files changed, 76 insertions(+)
diff --git a/hmp-commands.hx b/hmp-commands.hx index 1a28e63..f74b935 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1808,6 +1808,21 @@ STEXI dumps and reads the device state's data from the memory for testing purpose ETEXI + { + .name = "test_vmstates_set_period", + .args_type = "period:i", + .params = "period", + .help = "set the sleep interval for vmstates testing process\n\t\t\t" + "period: the new sleep interval value to replace the existing", + .mhandler.cmd = hmp_test_vmstates_set_period, + }, + +STEXI +@item test_vmstates_set_period @var{period} +@findex test_vmstates_set_period +Set the period to @var{period} (int) for vmstate testing process. +ETEXI + STEXI @end table ETEXI diff --git a/hmp.c b/hmp.c index 5d66975..d1f3045 100644 --- a/hmp.c +++ b/hmp.c @@ -1785,3 +1785,17 @@ void hmp_info_test_vmstates(Monitor *mon, const QDict *qdict) qapi_free_VMStateLogStateInfo(log_info); } + +void hmp_test_vmstates_set_period(Monitor *mon, const QDict *qdict) +{ + int64_t period = qdict_get_int(qdict, "period"); + Error *err = NULL; + + qmp_test_vmstates_set_period(period, &err); + + if (err) { + monitor_printf(mon, "test-vmstates-set-period: %s\n", + error_get_pretty(err)); + error_free(err); + } +} diff --git a/hmp.h b/hmp.h index 881964a..32221e3 100644 --- a/hmp.h +++ b/hmp.h @@ -97,6 +97,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_period(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 b7408df..cff9b0f 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3565,3 +3565,15 @@ # Since 2.2 ## { 'command': 'query-test-vmstates', 'returns': 'VMStateLogStateInfo' } + +## +# @test-vmstates-set-period +# +# sets the sleep interval between iterations of the vmstate testing process +# +# @period: the updated sleep interval value (in milliseconds) +# +# Since 2.2 +## +{ 'command' : 'test-vmstates-set-period', + 'data' : { 'period': 'int' } } diff --git a/qmp-commands.hx b/qmp-commands.hx index 84f8fc8..bde4fc9 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -3859,3 +3859,24 @@ Example: "devices": [ { 'device': 'hpet', 'version': 2 }, { 'device': 'mc146818rtc', 'version': 3 } ] } } EQMP + { + .name = "test-vmstates-set-period", + .args_type = "period:i", + .mhandler.cmd_new = qmp_marshal_input_test_vmstates_set_period, + }, + +SQMP +test-vmstates-set-period +------------------------ + +Update the sleep interval for the remaining iterations + +Arguments: + +- "period": the updated sleep interval between iterations (json-int) + +Example: + +-> { "execute": "test-vmstates-set-period", "arguments": { "period": 1024 } } +<- { "return": {} } +EQMP diff --git a/savevm.c b/savevm.c index 2709035..6ef69a1 100644 --- a/savevm.c +++ b/savevm.c @@ -1440,6 +1440,19 @@ VMStateLogStateInfo *qmp_query_test_vmstates(Error **errp) return log_info; } +void qmp_test_vmstates_set_period(int64_t period, Error **errp) +{ + VMStateLogState *v = test_vmstates_get_current_state(); + if (period < TEST_VMSTATE_MIN_INTERVAL_MS || + period > TEST_VMSTATE_MAX_INTERVAL_MS) { + error_setg(errp, "sleep interval (period) value must be " + "in the defined range [%d, %d](ms)\n", + TEST_VMSTATE_MIN_INTERVAL_MS, TEST_VMSTATE_MAX_INTERVAL_MS); + return; + } + v->period = period; +} + /* * ---------------------------------------------------------------------------- */ -- 1.9.3