This patch has been updated to provide the following information: * Added a new return value in the form of devices' info that provides the device name as well as the version number. * provides the hmp interface - info test_vmstates and qmp interface - query-test-vmstates to obtain the information about the running vmstate testing process.
Signed-off-by: Sanidhya Kashyap <sanidhya.ii...@gmail.com> --- hmp-commands.hx | 4 +++- hmp.c | 31 +++++++++++++++++++++++++++++++ hmp.h | 1 + monitor.c | 7 +++++++ qapi-schema.json | 37 +++++++++++++++++++++++++++++++++++++ qmp-commands.hx | 28 ++++++++++++++++++++++++++++ savevm.c | 29 +++++++++++++++++++++++++++++ 7 files changed, 136 insertions(+), 1 deletion(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index e16e1ac..1a28e63 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1770,6 +1770,8 @@ show migration status show current migration capabilities @item info migrate_cache_size show current migration XBZRLE cache size +@item info test_vmstates +show current vmstates testing process info @item info balloon show balloon information @item info qtree @@ -1799,13 +1801,13 @@ ETEXI "period: (optional) sleep interval in milliseconds between each iteration", .mhandler.cmd = hmp_test_vmstates, }, + STEXI @item test_vmstates @findex test_vmstates dumps and reads the device state's data from the memory for testing purpose ETEXI - STEXI @end table ETEXI diff --git a/hmp.c b/hmp.c index ca7664e..5d66975 100644 --- a/hmp.c +++ b/hmp.c @@ -1754,3 +1754,34 @@ void hmp_test_vmstates(Monitor *mon, const QDict *qdict) error_free(err); } } + +void hmp_info_test_vmstates(Monitor *mon, const QDict *qdict) +{ + VMStateLogStateInfo *log_info = qmp_query_test_vmstates(NULL); + QemuDeviceList *device_list = log_info->devices; + Error *err = NULL; + + if (log_info) { + monitor_printf(mon, "current-iteration: %"PRId64 "\n" + "iterations: %"PRId64 "\n" + "period: %"PRId64 "\n", log_info->current_iteration, + log_info->iterations, log_info->period); + if (device_list) { + monitor_printf(mon, "devices:\n"); + while (device_list) { + monitor_printf(mon, "device_name: %s, ", + device_list->value->device_name); + monitor_printf(mon, "version: %ld\n", + device_list->value->version); + device_list = device_list->next; + } + } + } + + if (err) { + monitor_printf(mon, "test-vmstates: %s\n", error_get_pretty(err)); + error_free(err); + } + + qapi_free_VMStateLogStateInfo(log_info); +} diff --git a/hmp.h b/hmp.h index 56fb865..881964a 100644 --- a/hmp.h +++ b/hmp.h @@ -39,6 +39,7 @@ void hmp_info_pci(Monitor *mon, const QDict *qdict); void hmp_info_block_jobs(Monitor *mon, const QDict *qdict); void hmp_info_tpm(Monitor *mon, const QDict *qdict); void hmp_info_devices(Monitor *mon, const QDict *qdict); +void hmp_info_test_vmstates(Monitor *mon, const QDict *qdict); void hmp_quit(Monitor *mon, const QDict *qdict); void hmp_stop(Monitor *mon, const QDict *qdict); void hmp_system_reset(Monitor *mon, const QDict *qdict); diff --git a/monitor.c b/monitor.c index 2431686..66a4d1f 100644 --- a/monitor.c +++ b/monitor.c @@ -2925,6 +2925,13 @@ static mon_cmd_t info_cmds[] = { .mhandler.cmd = hmp_info_devices, }, { + .name = "test_vmstates", + .args_type = "", + .params = "", + .help = "show the current vmstates testing information", + .mhandler.cmd = hmp_info_test_vmstates, + }, + { .name = NULL, }, }; diff --git a/qapi-schema.json b/qapi-schema.json index 4c810d7..b7408df 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3528,3 +3528,40 @@ 'data': {'*iterations': 'int', '*period': 'int', '*devices': [ 'QemuDevice' ] } } + +## +# @VMStateLogStateInfo +# +# VMState testing information +# Tells about the current iteration, the total iterations +# that have been provided and the sleep interval +# +# @current-iteration: shows the current iteration at which +# the test is in. +# +# @iterations: the allocated total iterations for the vmstate +# testing process. +# +# @period: the allowed sleep interval between each iteration +# (in milliseconds). +# +# @devices: returns the list of devices that are being tested +# +# Since 2.2 +## +{ 'type': 'VMStateLogStateInfo', + 'data': { 'current-iteration': 'int', + 'iterations': 'int', + 'period': 'int', + 'devices': [ 'QemuDevice' ] } } + +## +# @query-test-vmstates +# +# Get the current parameters value of the vmstate testing process. +# +# Returns VMStateLogStateInfo structure. +# +# Since 2.2 +## +{ 'command': 'query-test-vmstates', 'returns': 'VMStateLogStateInfo' } diff --git a/qmp-commands.hx b/qmp-commands.hx index ae2bdca..84f8fc8 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -3831,3 +3831,31 @@ Example: "period": 100, } } <- { "return": {} } EQMP + + { + .name = "query-test-vmstates", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_input_query_test_vmstates, + }, + +SQMP +query-test-vmstates +------------------- + +Get the parameters information + +- "current_iteration": the current iteration going on +- "iterations:" the total number of assigned iterations +- "period": the sleep interval between the iteration +- "devices": list of devices that are being tested + +Example: + +-> { "execute": "query-test-vmstates" } +<- { "return": { + "current_iteration": 3, + "iterations": 100, + "period": 100, + "devices": [ { 'device': 'hpet', 'version': 2 }, + { 'device': 'mc146818rtc', 'version': 3 } ] } } +EQMP diff --git a/savevm.c b/savevm.c index cd67c5d..2709035 100644 --- a/savevm.c +++ b/savevm.c @@ -1411,6 +1411,35 @@ void qmp_test_vmstates(bool has_iterations, int64_t iterations, timer_mod(v->timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME)); } +VMStateLogStateInfo *qmp_query_test_vmstates(Error **errp) +{ + VMStateLogState *v = test_vmstates_get_current_state(); + VMStateLogStateInfo *log_info = NULL; + DeviceInfoEntry *de; + + if (!v->active_state) { + return log_info; + } + + log_info = g_malloc0(sizeof(VMStateLogStateInfo)); + + log_info->current_iteration = v->current_iteration; + log_info->iterations = v->iterations; + log_info->period = v->period; + log_info->devices = NULL; + if (QTAILQ_EMPTY(&v->device_list)) { + log_info->devices = qmp_query_devices(NULL); + } else { + QTAILQ_FOREACH(de, &v->device_list, entry) { + log_info->devices = create_device_list(de->device->device_name, + de->device->version, + log_info->devices); + } + } + + return log_info; +} + /* * ---------------------------------------------------------------------------- */ -- 1.9.3