From patchwork Fri Feb 27 13:12:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Dovgalyuk X-Patchwork-Id: 444283 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 0BD871400B6 for ; Sat, 28 Feb 2015 00:26:21 +1100 (AEDT) Received: from localhost ([::1]:35974 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YRKvq-0005R3-WF for incoming@patchwork.ozlabs.org; Fri, 27 Feb 2015 08:26:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54030) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YRKi3-00045U-6m for qemu-devel@nongnu.org; Fri, 27 Feb 2015 08:12:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YRKhx-0005Xt-1R for qemu-devel@nongnu.org; Fri, 27 Feb 2015 08:12:03 -0500 Received: from mail.ispras.ru ([83.149.199.45]:34757) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YRKhw-0005Xk-JN for qemu-devel@nongnu.org; Fri, 27 Feb 2015 08:11:56 -0500 Received: from [10.10.150.93] (unknown [85.142.117.224]) by mail.ispras.ru (Postfix) with ESMTPSA id D78A254006F; Fri, 27 Feb 2015 16:11:55 +0300 (MSK) To: qemu-devel@nongnu.org From: Pavel Dovgalyuk Date: Fri, 27 Feb 2015 16:12:00 +0300 Message-ID: <20150227131200.11912.62387.stgit@PASHA-ISP> In-Reply-To: <20150227130939.11912.50660.stgit@PASHA-ISP> References: <20150227130939.11912.50660.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 Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com, alex.bennee@linaro.org, mark.burton@greensocs.com, real@ispras.ru, batuzovk@ispras.ru, maria.klimushenkova@ispras.ru, pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, afaerber@suse.de, fred.konrad@greensocs.com Subject: [Qemu-devel] [RFC PATCH v10 23/24] replay: command line options 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 introduces command line options for enabling recording or replaying virtual machine behavior. These options are added to icount command line parameter. They include 'rr' which switches between record and replay and 'rrfile' for specifying the filename for replay log. Signed-off-by: Pavel Dovgalyuk --- qemu-options.hx | 8 ++++++-- replay/replay.c | 4 ++++ vl.c | 15 +++++++++++++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/qemu-options.hx b/qemu-options.hx index 85ca3ad..c62661a 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3038,11 +3038,11 @@ re-inject them. ETEXI DEF("icount", HAS_ARG, QEMU_OPTION_icount, \ - "-icount [shift=N|auto][,align=on|off]\n" \ + "-icount [shift=N|auto][,align=on|off][,rr=record|replay,rrfile=]\n" \ " enable virtual instruction counter with 2^N clock ticks per\n" \ " instruction and enable aligning the host and virtual clocks\n", QEMU_ARCH_ALL) STEXI -@item -icount [shift=@var{N}|auto] +@item -icount [shift=@var{N}|auto][,rr=record|replay,rrfile=@var{filename}] @findex -icount Enable virtual instruction counter. The virtual cpu will execute one instruction every 2^@var{N} ns of virtual time. If @code{auto} is specified @@ -3064,6 +3064,10 @@ Currently this option does not work when @option{shift} is @code{auto}. Note: The sync algorithm will work for those shift values for which the guest clock runs ahead of the host clock. Typically this happens when the shift value is high (how high depends on the host machine). + +When @option{rr} option is specified deterministic record/replay is enabled. +Replay log is written into @var{filename} file in record mode and +read from this file in replay mode. ETEXI DEF("watchdog", HAS_ARG, QEMU_OPTION_watchdog, \ diff --git a/replay/replay.c b/replay/replay.c index a5ae58b..b8fdef5 100755 --- a/replay/replay.c +++ b/replay/replay.c @@ -292,6 +292,10 @@ void replay_start(void) error_get_pretty(replay_blockers->data)); exit(1); } + if (!use_icount) { + error_report("Please enable icount to use record/replay"); + exit(1); + } /* Timer for snapshotting will be set up here. */ diff --git a/vl.c b/vl.c index f9c345d..89d6da6 100644 --- a/vl.c +++ b/vl.c @@ -472,6 +472,12 @@ static QemuOptsList qemu_icount_opts = { }, { .name = "align", .type = QEMU_OPT_BOOL, + }, { + .name = "rr", + .type = QEMU_OPT_STRING, + }, { + .name = "rrfile", + .type = QEMU_OPT_STRING, }, { /* end of list */ } }, @@ -2751,6 +2757,7 @@ int main(int argc, char **argv, char **envp) { int i; int snapshot, linux_boot; + const char *icount_option = NULL; const char *initrd_filename; const char *kernel_filename, *kernel_cmdline; const char *boot_order; @@ -3770,6 +3777,8 @@ int main(int argc, char **argv, char **envp) } } + replay_configure(icount_opts); + opts = qemu_get_machine_opts(); optarg = qemu_opt_get(opts, "type"); if (optarg) { @@ -4173,8 +4182,10 @@ int main(int argc, char **argv, char **envp) } /* open the virtual block devices */ - if (snapshot) - qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot, NULL, 0); + if (snapshot || replay_mode != REPLAY_MODE_NONE) { + qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot, + NULL, 0); + } if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func, &machine_class->block_default_type, 1) != 0) { exit(1);