From patchwork Thu Jul 17 11:06:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Dovgalyuk X-Patchwork-Id: 371142 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3879514008F for ; Thu, 17 Jul 2014 23:44:14 +1000 (EST) Received: from localhost ([::1]:44354 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7lym-0005Vt-B5 for incoming@patchwork.ozlabs.org; Thu, 17 Jul 2014 09:44:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7jW1-0004dU-4W for qemu-devel@nongnu.org; Thu, 17 Jul 2014 07:06:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X7jVu-0005ZL-Co for qemu-devel@nongnu.org; Thu, 17 Jul 2014 07:06:21 -0400 Received: from mail.ispras.ru ([83.149.199.45]:47658) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7jVu-0005ZC-0P for qemu-devel@nongnu.org; Thu, 17 Jul 2014 07:06:14 -0400 Received: from [10.10.150.172] (unknown [80.250.189.177]) by mail.ispras.ru (Postfix) with ESMTPSA id 4CB0B540157; Thu, 17 Jul 2014 15:06:13 +0400 (MSK) To: qemu-devel@nongnu.org From: Pavel Dovgalyuk Date: Thu, 17 Jul 2014 15:06:16 +0400 Message-ID: <20140717110616.8352.95699.stgit@PASHA-ISP> In-Reply-To: <20140717110153.8352.80175.stgit@PASHA-ISP> References: <20140717110153.8352.80175.stgit@PASHA-ISP> User-Agent: StGit/0.16 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.45 X-Mailman-Approved-At: Thu, 17 Jul 2014 09:36:32 -0400 Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com, mark.burton@greensocs.com, real@ispras.ru, batuzovk@ispras.ru, pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, fred.konrad@greensocs.com Subject: [Qemu-devel] [RFC PATCH v2 46/49] replay: replay_info command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This patch adds support for replay_info monitor command. This command returns the information about replay execution (replay mode and current step). Signed-off-by: Pavel Dovgalyuk --- hmp-commands.hx | 13 +++++++++++++ monitor.c | 17 +++++++++++++++++ qapi-schema.json | 27 +++++++++++++++++++++++++++ qmp-commands.hx | 14 ++++++++++++++ replay/Makefile.objs | 1 + replay/replay-qmp.c | 29 +++++++++++++++++++++++++++++ replay/replay.c | 25 +++++++++++++++++++++++++ replay/replay.h | 4 ++++ 8 files changed, 130 insertions(+), 0 deletions(-) create mode 100755 replay/replay-qmp.c diff --git a/hmp-commands.hx b/hmp-commands.hx index d0943b1..19174f1 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1788,6 +1788,19 @@ STEXI show available trace events and their state ETEXI + { + .name = "replay_info", + .args_type = "", + .params = "", + .help = "show replay info", + .mhandler.cmd = do_replay_info, + }, + +STEXI +@item replay_info +Shows information about replay process. +ETEXI + STEXI @end table ETEXI diff --git a/monitor.c b/monitor.c index 5bc70a6..f336b91 100644 --- a/monitor.c +++ b/monitor.c @@ -73,6 +73,7 @@ #include "block/qapi.h" #include "qapi/qmp-event.h" #include "qapi-event.h" +#include "replay/replay.h" /* for pic/irq_info */ #if defined(TARGET_SPARC) @@ -1173,6 +1174,22 @@ static void do_watchdog_action(Monitor *mon, const QDict *qdict) } } +static void do_replay_info(Monitor *mon, const QDict *qdict) +{ + switch (replay_mode) { + case REPLAY_NONE: + monitor_printf(mon, "Replay is not enabled\n"); + break; + default: + monitor_printf(mon, "Replay mode: %s ", replay_get_mode_name()); + if (replay_mode == REPLAY_PLAY) { + monitor_printf(mon, "(%s)", replay_get_play_submode_name()); + } + monitor_printf(mon, "\n\tcurrent step: %" PRId64 "\n", replay_get_current_step()); + break; + } +} + static void monitor_printc(Monitor *mon, int c) { monitor_printf(mon, "'"); diff --git a/qapi-schema.json b/qapi-schema.json index fee541a..c45f795 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3491,3 +3491,30 @@ # Since: 2.1 ## { 'command': 'rtc-reset-reinjection' } + +## +# @ReplayInfo: +# +# Information about replay process +# +# @mode: replay mode (none, play, record) +# +# @submode: play submode +# +# @step: current step of record or play +# +# Since: 2.2 +## +{ 'type': 'ReplayInfo', + 'data': {'mode': 'str', 'submode': 'str', 'step': 'uint64'} } + +## +# @replay_info +# +# Query the status of replay engine +# +# Returns: @ReplayInfo reflecting the status +# +# Since: 2.2 +## +{ 'command': 'replay_info', 'returns': 'ReplayInfo' } diff --git a/qmp-commands.hx b/qmp-commands.hx index 4be4765..d475633 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -3755,3 +3755,17 @@ Example: <- { "return": {} } EQMP + + { + .name = "replay_info", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_input_replay_info, + }, + +SQMP +replay_info +----------- + +Shows information about replay process. + +EQMP diff --git a/replay/Makefile.objs b/replay/Makefile.objs index f2e3bdc..1bc9621 100755 --- a/replay/Makefile.objs +++ b/replay/Makefile.objs @@ -7,3 +7,4 @@ obj-y += replay-net.o obj-y += replay-audio.o obj-y += replay-char.o obj-y += replay-usb.o +obj-y += replay-qmp.o diff --git a/replay/replay-qmp.c b/replay/replay-qmp.c new file mode 100755 index 0000000..966bd4d --- /dev/null +++ b/replay/replay-qmp.c @@ -0,0 +1,29 @@ +/* + * replay-qmp.c + * + * Copyright (c) 2010-2014 Institute for System Programming + * of the Russian Academy of Sciences. + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu-common.h" +#include "sysemu/sysemu.h" +#include "qmp-commands.h" +#include "qapi/qmp/qobject.h" +#include "qapi/qmp-input-visitor.h" +#include "replay/replay.h" +#include "replay/replay-internal.h" + +ReplayInfo *qmp_replay_info(Error **errp) +{ + ReplayInfo *info = g_malloc0(sizeof(*info)); + + info->mode = g_strdup(replay_get_mode_name()); + info->submode = g_strdup(replay_get_play_submode_name()); + info->step = replay_get_current_step(); + + return info; +} diff --git a/replay/replay.c b/replay/replay.c index a89ba91..f711c26 100755 --- a/replay/replay.c +++ b/replay/replay.c @@ -638,3 +638,28 @@ void replay_data_buffer(unsigned char *data, size_t size) replay_put_array(data, size); } } + +const char *replay_get_mode_name(void) +{ + switch (replay_mode) { + case REPLAY_NONE: + return "none"; + case REPLAY_PLAY: + return "replay"; + case REPLAY_SAVE: + return "record"; + default: + return "unknown"; + } +} + +const char *replay_get_play_submode_name(void) +{ + switch (play_submode) { + case REPLAY_PLAY_NORMAL: + return "normal"; + case REPLAY_PLAY_UNKNOWN: + default: + return "unknown"; + } +} diff --git a/replay/replay.h b/replay/replay.h index aa15803..ee0460f 100755 --- a/replay/replay.h +++ b/replay/replay.h @@ -52,6 +52,10 @@ extern int replay_icount; /*! Returns replay play submode */ int replay_get_play_submode(void); +/*! Returns current mode name */ +const char *replay_get_mode_name(void); +/*! Returns replay-play submode name */ +const char *replay_get_play_submode_name(void); /* Replay process control functions */