This option sets a factor on time spent for QEMU clocks since the
beginning of execution. It can be used to slow or accelerate time for a
guest, without impacting QEMU speed.
It can only be used with tcg.
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
system/rtc.c | 11 +++++++++++
system/vl.c | 9 +++++++++
qemu-options.hx | 7 ++++++-
3 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/system/rtc.c b/system/rtc.c
index 56951288c40..ec063391b5c 100644
--- a/system/rtc.c
+++ b/system/rtc.c
@@ -188,4 +188,15 @@ void configure_rtc(QemuOpts *opts)
exit(1);
}
}
+ value = qemu_opt_get(opts, "speed-factor");
+ if (value) {
+ if (qemu_strtod_finite(value, NULL, &clock_time_dilation)) {
+ error_report("invalid speed-factor factor '%s'", value);
+ exit(1);
+ }
+ if (clock_time_dilation <= 0.0f) {
+ error_report("speed-factor factor must be strictly positive");
+ exit(1);
+ }
+ }
}
diff --git a/system/vl.c b/system/vl.c
index 3b7057e6c66..e1ea79c683c 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -243,6 +243,9 @@ static QemuOptsList qemu_rtc_opts = {
},{
.name = "driftfix",
.type = QEMU_OPT_STRING,
+ },{
+ .name = "speed-factor",
+ .type = QEMU_OPT_STRING,
},
{ /* end of list */ }
},
@@ -2491,6 +2494,12 @@ static void configure_accelerators(const char *progname)
error_report("-icount is not allowed with hardware virtualization");
exit(1);
}
+
+ if (clock_time_dilation != 1.0f && !tcg_enabled()) {
+ error_report("-rtc speed-factor is not allowed with "
+ "hardware virtualization");
+ exit(1);
+ }
}
static void qemu_validate_options(const QDict *machine_opts)
diff --git a/qemu-options.hx b/qemu-options.hx
index 6bcbb8ccea0..9efdbfb3842 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -4887,7 +4887,7 @@ SRST
ERST
DEF("rtc", HAS_ARG, QEMU_OPTION_rtc, \
- "-rtc [base=utc|localtime|<datetime>][,clock=host|rt|vm][,driftfix=none|slew]\n" \
+ "-rtc [base=utc|localtime|<datetime>][,clock=host|rt|vm][,driftfix=none|slew][,speed-factor=value]\n" \
" set the RTC base and clock, enable drift fix for clock ticks (x86 only)\n",
QEMU_ARCH_ALL)
@@ -4916,6 +4916,11 @@ SRST
problems, specifically with Windows' ACPI HAL. This option will try
to figure out how many timer interrupts were not processed by the
Windows guest and will re-inject them.
+
+ It's possible to slow or accelerate time using ``speed-factor``,
+ which is a factor (real number) applied to QEMU clock. A value of 0.1 will
+ slow time by a factor of 10, and a value of 10 will accelerate it with the
+ same factor.
ERST
DEF("icount", HAS_ARG, QEMU_OPTION_icount, \
--
2.47.2