From patchwork Wed Jul 25 12:14:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Dovgalyuk X-Patchwork-Id: 10543945 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 720C3157A for ; Wed, 25 Jul 2018 12:25:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C620200E7 for ; Wed, 25 Jul 2018 12:25:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F06729D83; Wed, 25 Jul 2018 12:25:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B1AC0200E7 for ; Wed, 25 Jul 2018 12:25:06 +0000 (UTC) Received: from localhost ([::1]:49201 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fiIqn-00018Z-T0 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Jul 2018 08:25:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fiIg6-000150-Hb for qemu-devel@nongnu.org; Wed, 25 Jul 2018 08:14:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fiIg3-0002he-HF for qemu-devel@nongnu.org; Wed, 25 Jul 2018 08:14:02 -0400 Received: from mail.ispras.ru ([83.149.199.45]:36482) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fiIg3-0002gX-38 for qemu-devel@nongnu.org; Wed, 25 Jul 2018 08:13:59 -0400 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id 271EC54006B; Wed, 25 Jul 2018 15:13:58 +0300 (MSK) From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Wed, 25 Jul 2018 15:14:00 +0300 Message-ID: <20180725121400.12867.82957.stgit@pasha-VirtualBox> In-Reply-To: <20180725121311.12867.21729.stgit@pasha-VirtualBox> References: <20180725121311.12867.21729.stgit@pasha-VirtualBox> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 83.149.199.45 Subject: [Qemu-devel] [PATCH v5 08/24] replay: introduce info hmp/qmp command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, war2jordan@live.com, pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, quintela@redhat.com, ciro.santilli@gmail.com, jasowang@redhat.com, crosthwaite.peter@gmail.com, zuban32s@gmail.com, armbru@redhat.com, maria.klimushenkova@ispras.ru, mst@redhat.com, kraxel@redhat.com, boost.lists@gmail.com, thomas.dullien@googlemail.com, dovgaluk@ispras.ru, mreitz@redhat.com, alex.bennee@linaro.org, dgilbert@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch introduces 'info replay' monitor command and corresponding qmp request. These commands request the current record/replay mode, replay log file name, and the execution step (number or recorded/replayed instructions). Signed-off-by: Pavel Dovgalyuk --- v2: - renamed info_replay qmp into query-replay (suggested by Eric Blake) --- hmp-commands-info.hx | 14 ++++++++++++++ hmp.h | 1 + qapi/misc.json | 35 +++++++++++++++++++++++++++++++++++ replay/Makefile.objs | 3 ++- replay/replay-debugging.c | 41 +++++++++++++++++++++++++++++++++++++++++ replay/replay-internal.h | 2 ++ replay/replay.c | 3 +-- 7 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 replay/replay-debugging.c diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 70639f6..1b24714 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -896,6 +896,20 @@ STEXI Show SEV information. ETEXI + { + .name = "replay", + .args_type = "", + .params = "", + .help = "show parameters of the record/replay", + .cmd = hmp_info_replay, + }, + +STEXI +@item info replay +@findex info replay +Display the current record/replay mode and the currently executing step. +ETEXI + STEXI @end table ETEXI diff --git a/hmp.h b/hmp.h index 33354f1..9d12c63 100644 --- a/hmp.h +++ b/hmp.h @@ -147,5 +147,6 @@ void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict); void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict); void hmp_info_memory_size_summary(Monitor *mon, const QDict *qdict); void hmp_info_sev(Monitor *mon, const QDict *qdict); +void hmp_info_replay(Monitor *mon, const QDict *qdict); #endif diff --git a/qapi/misc.json b/qapi/misc.json index d450cfe..e246ce3 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -3100,6 +3100,41 @@ 'data': [ 'none', 'record', 'play' ] } ## +# @ReplayInfo: +# +# Status of the record/replay mode. +# +# @mode: current mode. +# +# @filename: name of the record/replay log file. +# +# @step: current step number. +# +# Since: 3.1 +# +## +{ 'struct': 'ReplayInfo', + 'data': { 'mode': 'ReplayMode', '*filename': 'str', 'step': 'int' } } + +## +# @query-replay: +# +# Retrieves the status of the execution record/replay. +# +# Returns: structure with the properties of the record/replay. +# +# Since: 3.1 +# +# Example: +# +# -> { "execute": "query-replay" } +# <- { "return": { "mode": "play", "filename": "log.rr", "step": 220414 } } +# +## +{ 'command': 'query-replay', + 'returns': 'ReplayInfo' } + +## # @xen-load-devices-state: # # Load the state of all devices from file. The RAM and the block devices diff --git a/replay/Makefile.objs b/replay/Makefile.objs index cee6539..6694e3e 100644 --- a/replay/Makefile.objs +++ b/replay/Makefile.objs @@ -6,4 +6,5 @@ common-obj-y += replay-input.o common-obj-y += replay-char.o common-obj-y += replay-snapshot.o common-obj-y += replay-net.o -common-obj-y += replay-audio.o \ No newline at end of file +common-obj-y += replay-audio.o +common-obj-y += replay-debugging.o diff --git a/replay/replay-debugging.c b/replay/replay-debugging.c new file mode 100644 index 0000000..03e7db8 --- /dev/null +++ b/replay/replay-debugging.c @@ -0,0 +1,41 @@ +/* + * replay-debugging.c + * + * Copyright (c) 2010-2018 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/osdep.h" +#include "qapi/error.h" +#include "sysemu/replay.h" +#include "replay-internal.h" +#include "hmp.h" +#include "monitor/monitor.h" +#include "qapi/qapi-commands-misc.h" + +void hmp_info_replay(Monitor *mon, const QDict *qdict) +{ + if (replay_mode == REPLAY_MODE_NONE) { + monitor_printf(mon, "No record/replay\n"); + } else { + monitor_printf(mon, "%s execution '%s': current step = %"PRId64"\n", + replay_mode == REPLAY_MODE_RECORD ? "Recording" : "Replaying", + replay_filename, replay_get_current_step()); + } +} + +ReplayInfo *qmp_query_replay(Error **errp) +{ + ReplayInfo *retval = g_new0(ReplayInfo, 1); + retval->mode = replay_mode; + if (replay_filename) { + retval->filename = g_strdup(replay_filename); + retval->has_filename = true; + } + retval->step = replay_get_current_step(); + return retval; +} diff --git a/replay/replay-internal.h b/replay/replay-internal.h index ac4b27b..ef82b5e 100644 --- a/replay/replay-internal.h +++ b/replay/replay-internal.h @@ -91,6 +91,8 @@ extern ReplayState replay_state; /* File for replay writing */ extern FILE *replay_file; +/*! Name of replay file */ +extern char *replay_filename; void replay_put_byte(uint8_t byte); void replay_put_event(uint8_t event); diff --git a/replay/replay.c b/replay/replay.c index 58a986f..8b70d7d 100644 --- a/replay/replay.c +++ b/replay/replay.c @@ -29,8 +29,7 @@ ReplayMode replay_mode = REPLAY_MODE_NONE; char *replay_snapshot; -/* Name of replay file */ -static char *replay_filename; +char *replay_filename; ReplayState replay_state; static GSList *replay_blockers;