From: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
To: qemu-devel@nongnu.org
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 v7 20/21] replay: command line options
Date: Mon, 12 Jan 2015 15:01:40 +0300 [thread overview]
Message-ID: <20150112120139.3504.47989.stgit@PASHA-ISP> (raw)
In-Reply-To: <20150112115944.3504.66763.stgit@PASHA-ISP>
This patch introduces command line options for enabling recording or replaying
virtual machine behavior. "-record" option starts recording of the execution
and saves it into the log, specified with "fname" parameter. "-replay" option
is intended for replaying previously saved log.
Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
---
cpus.c | 3 +-
qemu-options.hx | 27 +++++++++++++++++++
vl.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 106 insertions(+), 3 deletions(-)
diff --git a/cpus.c b/cpus.c
index 907a4bb..3442af2 100644
--- a/cpus.c
+++ b/cpus.c
@@ -912,9 +912,10 @@ static void qemu_wait_io_event_common(CPUState *cpu)
static void qemu_tcg_wait_io_event(void)
{
CPUState *cpu;
+ GMainContext *context = g_main_context_default();
while (all_cpu_threads_idle()) {
- /* Start accounting real time to the virtual clock if the CPUs
+ /* Start accounting real time to the virtual clock if the CPUs
are idle. */
qemu_clock_warp(QEMU_CLOCK_VIRTUAL);
qemu_cond_wait(tcg_halt_cond, &qemu_global_mutex);
diff --git a/qemu-options.hx b/qemu-options.hx
index 10b9568..9d28bbb 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -3395,6 +3395,33 @@ Dump json-encoded vmstate information for current machine type to file
in @var{file}
ETEXI
+DEF("record", HAS_ARG, QEMU_OPTION_record,
+ "-record fname=<filename>[,suffix=<suffix>,snapshot=<on/off>]\n"
+ " writes replay file for latter replaying\n",
+ QEMU_ARCH_ALL)
+STEXI
+@item -record fname=@var{file}[,suffix=@var{suffix},snapshot=@var{snapshot}]
+Writes compact execution trace into @var{file}.
+Changes for disk images are written
+into separate files with @var{suffix} added. If no @var{suffix} is
+specified, "replay_qcow" is used as suffix.
+If @var{snapshot} parameter is set as off, then original disk image will be
+modified. Default value is on.
+ETEXI
+
+DEF("replay", HAS_ARG, QEMU_OPTION_replay,
+ "-replay fname=<filename>[,suffix=<suffix>,snapshot=<on/off>]\n"
+ " plays saved replay file\n", QEMU_ARCH_ALL)
+STEXI
+@item -replay fname=@var{filename}[,suffix=@var{suffix},snapshot=@var{snapshot}]
+Plays compact execution trace from @var{filename}.
+Changes for disk images and VM states are read
+from separate files with @var{suffix} added. If no @var{suffix} is
+specified, "replay_qcow" is used as suffix.
+If @var{snapshot} parameter is set as off, then original disk image will be
+modified. Default value is on.
+ETEXI
+
HXCOMM This is the last statement. Insert new options before this line!
STEXI
@end table
diff --git a/vl.c b/vl.c
index 8b1b793..b996908 100644
--- a/vl.c
+++ b/vl.c
@@ -496,6 +496,42 @@ static QemuOptsList qemu_semihosting_config_opts = {
},
};
+static QemuOptsList qemu_record_opts = {
+ .name = "record",
+ .head = QTAILQ_HEAD_INITIALIZER(qemu_record_opts.head),
+ .desc = {
+ {
+ .name = "fname",
+ .type = QEMU_OPT_STRING,
+ },{
+ .name = "suffix",
+ .type = QEMU_OPT_STRING,
+ },{
+ .name = "snapshot",
+ .type = QEMU_OPT_BOOL,
+ },
+ { /* end of list */ }
+ },
+};
+
+static QemuOptsList qemu_replay_opts = {
+ .name = "replay",
+ .head = QTAILQ_HEAD_INITIALIZER(qemu_replay_opts.head),
+ .desc = {
+ {
+ .name = "fname",
+ .type = QEMU_OPT_STRING,
+ },{
+ .name = "suffix",
+ .type = QEMU_OPT_STRING,
+ },{
+ .name = "snapshot",
+ .type = QEMU_OPT_BOOL,
+ },
+ { /* end of list */ }
+ },
+};
+
/**
* Get machine options
*
@@ -2665,7 +2701,9 @@ out:
int main(int argc, char **argv, char **envp)
{
int i;
- int snapshot, linux_boot;
+ int snapshot, linux_boot, replay_snapshot;
+ int not_compatible_replay_param = 0;
+ const char *icount_option = NULL;
const char *initrd_filename;
const char *kernel_filename, *kernel_cmdline;
const char *boot_order;
@@ -2739,6 +2777,8 @@ int main(int argc, char **argv, char **envp)
qemu_add_opts(&qemu_numa_opts);
qemu_add_opts(&qemu_icount_opts);
qemu_add_opts(&qemu_semihosting_config_opts);
+ qemu_add_opts(&qemu_replay_opts);
+ qemu_add_opts(&qemu_record_opts);
runstate_init();
@@ -2752,6 +2792,7 @@ int main(int argc, char **argv, char **envp)
cpu_model = NULL;
ram_size = default_ram_size;
snapshot = 0;
+ replay_snapshot = 1;
cyls = heads = secs = 0;
translation = BIOS_ATA_TRANSLATION_AUTO;
@@ -2869,6 +2910,7 @@ int main(int argc, char **argv, char **envp)
break;
case QEMU_OPTION_pflash:
drive_add(IF_PFLASH, -1, optarg, PFLASH_OPTS);
+ not_compatible_replay_param++;
break;
case QEMU_OPTION_snapshot:
snapshot = 1;
@@ -3025,6 +3067,7 @@ int main(int argc, char **argv, char **envp)
#endif
case QEMU_OPTION_bt:
add_device_config(DEV_BT, optarg);
+ not_compatible_replay_param++;
break;
case QEMU_OPTION_audio_help:
AUD_help ();
@@ -3243,6 +3286,7 @@ int main(int argc, char **argv, char **envp)
if (!opts) {
exit(1);
}
+ not_compatible_replay_param++;
break;
case QEMU_OPTION_fsdev:
olist = qemu_find_opts("fsdev");
@@ -3371,6 +3415,7 @@ int main(int argc, char **argv, char **envp)
if (strncmp(optarg, "mon:", 4) == 0) {
default_monitor = 0;
}
+ not_compatible_replay_param++;
break;
case QEMU_OPTION_debugcon:
add_device_config(DEV_DEBUGCON, optarg);
@@ -3491,6 +3536,7 @@ int main(int argc, char **argv, char **envp)
if (!qemu_opts_parse(qemu_find_opts("smp-opts"), optarg, 1)) {
exit(1);
}
+ not_compatible_replay_param++;
break;
case QEMU_OPTION_vnc:
#ifdef CONFIG_VNC
@@ -3765,6 +3811,24 @@ int main(int argc, char **argv, char **envp)
exit(1);
}
break;
+ case QEMU_OPTION_record:
+ opts = qemu_opts_parse(qemu_find_opts("record"), optarg, 0);
+ if (!opts) {
+ fprintf(stderr, "Invalid record options: %s\n", optarg);
+ exit(1);
+ }
+ replay_configure(opts, REPLAY_MODE_RECORD);
+ replay_snapshot = qemu_opt_get_bool(opts, "snapshot", 1);
+ break;
+ case QEMU_OPTION_replay:
+ opts = qemu_opts_parse(qemu_find_opts("replay"), optarg, 0);
+ if (!opts) {
+ fprintf(stderr, "Invalid replay options: %s\n", optarg);
+ exit(1);
+ }
+ replay_configure(opts, REPLAY_MODE_PLAY);
+ replay_snapshot = qemu_opt_get_bool(opts, "snapshot", 1);
+ break;
default:
os_parse_cmd_args(popt->index, optarg);
}
@@ -3779,6 +3843,12 @@ int main(int argc, char **argv, char **envp)
exit(1);
}
+ if (not_compatible_replay_param && (replay_mode != REPLAY_MODE_NONE)) {
+ fprintf(stderr, "options -smp, -pflash, -chardev, -bt, -parallel "
+ "are not compatible with record/replay\n");
+ exit(1);
+ }
+
if (qemu_opts_foreach(qemu_find_opts("sandbox"), parse_sandbox, NULL, 0)) {
exit(1);
}
@@ -4132,6 +4202,11 @@ int main(int argc, char **argv, char **envp)
qemu_opts_del(icount_opts);
}
+ if (replay_mode != REPLAY_MODE_NONE && !use_icount) {
+ fprintf(stderr, "Please enable icount to use record/replay\n");
+ exit(1);
+ }
+
/* clean up network at qemu process termination */
atexit(&net_cleanup);
@@ -4168,7 +4243,7 @@ int main(int argc, char **argv, char **envp)
}
/* open the virtual block devices */
- if (snapshot)
+ if (snapshot || (replay_mode != REPLAY_MODE_NONE && replay_snapshot))
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) {
next prev parent reply other threads:[~2015-01-12 12:01 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-12 11:59 [Qemu-devel] [RFC PATCH v7 00/21] Deterministic replay core Pavel Dovgalyuk
2015-01-12 11:59 ` [Qemu-devel] [RFC PATCH v7 01/21] i386: partial revert of interrupt poll fix Pavel Dovgalyuk
2015-01-12 11:59 ` [Qemu-devel] [RFC PATCH v7 02/21] replay: global variables and function stubs Pavel Dovgalyuk
2015-01-12 12:19 ` Paolo Bonzini
2015-01-12 12:21 ` Pavel Dovgaluk
2015-01-12 12:25 ` Paolo Bonzini
2015-01-20 17:07 ` Eric Blake
2015-01-12 12:00 ` [Qemu-devel] [RFC PATCH v7 03/21] sysemu: system functions for replay Pavel Dovgalyuk
2015-01-12 12:00 ` [Qemu-devel] [RFC PATCH v7 04/21] replay: internal functions for replay log Pavel Dovgalyuk
2015-01-12 12:49 ` Paolo Bonzini
2015-01-12 12:52 ` Pavel Dovgaluk
2015-01-12 12:00 ` [Qemu-devel] [RFC PATCH v7 05/21] replay: introduce icount event Pavel Dovgalyuk
2015-01-12 12:00 ` [Qemu-devel] [RFC PATCH v7 06/21] cpu-exec: allow temporary disabling icount Pavel Dovgalyuk
2015-01-12 12:00 ` [Qemu-devel] [RFC PATCH v7 07/21] cpu: replay instructions sequence Pavel Dovgalyuk
2015-01-12 12:00 ` [Qemu-devel] [RFC PATCH v7 08/21] replay: interrupts and exceptions Pavel Dovgalyuk
2015-01-12 12:34 ` Paolo Bonzini
2015-01-12 12:40 ` Pavel Dovgaluk
2015-01-12 12:54 ` Paolo Bonzini
2015-01-14 9:07 ` Pavel Dovgaluk
[not found] ` <3141.42739302969$1421226482@news.gmane.org>
2015-01-14 9:49 ` Paolo Bonzini
2015-01-14 10:06 ` Pavel Dovgaluk
[not found] ` <48665.1020743468$1421230035@news.gmane.org>
2015-01-14 10:21 ` Paolo Bonzini
2015-01-12 12:00 ` [Qemu-devel] [RFC PATCH v7 09/21] replay: asynchronous events infrastructure Pavel Dovgalyuk
2015-01-12 12:20 ` Paolo Bonzini
2015-01-12 12:00 ` [Qemu-devel] [RFC PATCH v7 10/21] cpus: make icount warp deterministic in replay mode Pavel Dovgalyuk
2015-01-12 12:01 ` Paolo Bonzini
2015-01-12 12:00 ` [Qemu-devel] [RFC PATCH v7 11/21] timer: fix usage of clock functions Pavel Dovgalyuk
2015-01-12 12:03 ` Paolo Bonzini
2015-01-12 12:00 ` [Qemu-devel] [RFC PATCH v7 12/21] replay: recording and replaying clock ticks Pavel Dovgalyuk
2015-01-12 12:14 ` Paolo Bonzini
2015-01-12 12:43 ` Pavel Dovgaluk
2015-01-12 12:45 ` Paolo Bonzini
2015-01-13 9:21 ` Pavel Dovgaluk
2015-01-13 9:38 ` Paolo Bonzini
2015-01-16 8:03 ` Pavel Dovgaluk
2015-01-19 11:51 ` Paolo Bonzini
2015-01-19 12:03 ` Pavel Dovgaluk
2015-01-19 12:15 ` Paolo Bonzini
2015-01-19 12:43 ` Pavel Dovgaluk
2015-01-19 12:57 ` Paolo Bonzini
2015-01-19 13:01 ` Pavel Dovgaluk
2015-01-19 13:02 ` Paolo Bonzini
2015-01-19 13:10 ` Pavel Dovgaluk
2015-01-19 13:12 ` Paolo Bonzini
2015-01-20 6:24 ` Pavel Dovgaluk
2015-01-12 12:01 ` [Qemu-devel] [RFC PATCH v7 13/21] replay: recording and replaying different timers Pavel Dovgalyuk
2015-01-12 12:08 ` Paolo Bonzini
2015-01-12 12:01 ` [Qemu-devel] [RFC PATCH v7 14/21] replay: shutdown event Pavel Dovgalyuk
2015-01-12 12:05 ` Paolo Bonzini
2015-01-12 12:01 ` [Qemu-devel] [RFC PATCH v7 15/21] replay: checkpoints Pavel Dovgalyuk
2015-01-12 12:13 ` Paolo Bonzini
2015-01-13 9:07 ` Pavel Dovgaluk
2015-01-13 9:15 ` Pavel Dovgaluk
2015-01-13 9:40 ` Paolo Bonzini
2015-01-13 14:26 ` Pavel Dovgaluk
[not found] ` <37329.9191626304$1421159249@news.gmane.org>
2015-01-13 14:52 ` Paolo Bonzini
2015-01-13 14:53 ` Paolo Bonzini
2015-01-22 8:50 ` Pavel Dovgaluk
2015-01-12 12:01 ` [Qemu-devel] [RFC PATCH v7 16/21] replay: bottom halves Pavel Dovgalyuk
2015-01-12 12:16 ` Paolo Bonzini
2015-01-12 12:01 ` [Qemu-devel] [RFC PATCH v7 17/21] replay: replay aio requests Pavel Dovgalyuk
2015-01-12 12:01 ` [Qemu-devel] [RFC PATCH v7 18/21] replay: thread pool Pavel Dovgalyuk
2015-01-12 12:01 ` [Qemu-devel] [RFC PATCH v7 19/21] replay: initialization and deinitialization Pavel Dovgalyuk
2015-01-12 12:01 ` Pavel Dovgalyuk [this message]
2015-01-12 12:21 ` [Qemu-devel] [RFC PATCH v7 20/21] replay: command line options Paolo Bonzini
2015-01-12 12:23 ` Pavel Dovgaluk
2015-01-12 12:26 ` Paolo Bonzini
2015-01-12 12:01 ` [Qemu-devel] [RFC PATCH v7 21/21] replay: recording of the user input Pavel Dovgalyuk
2015-01-12 12:25 ` Paolo Bonzini
2015-01-16 7:23 ` Pavel Dovgaluk
[not found] ` <43535.7048445896$1421393030@news.gmane.org>
2015-01-19 11:53 ` Paolo Bonzini
2015-01-12 12:39 ` [Qemu-devel] [RFC PATCH v7 00/21] Deterministic replay core Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150112120139.3504.47989.stgit@PASHA-ISP \
--to=pavel.dovgaluk@ispras.ru \
--cc=afaerber@suse.de \
--cc=alex.bennee@linaro.org \
--cc=batuzovk@ispras.ru \
--cc=fred.konrad@greensocs.com \
--cc=maria.klimushenkova@ispras.ru \
--cc=mark.burton@greensocs.com \
--cc=pbonzini@redhat.com \
--cc=peter.crosthwaite@xilinx.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=real@ispras.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).