[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 1/4] icount: Add 'align' and 'icount' options
From: |
Sebastian Tanase |
Subject: |
[Qemu-devel] [RFC PATCH 1/4] icount: Add 'align' and 'icount' options |
Date: |
Tue, 27 May 2014 16:54:45 +0200 |
The align option is used for activating the align algorithm
in order to synchronise the host clock and the guest clock.
Therefore we slightly modified the existing icount option.
Thus, the new way to specify an icount is
'-icount [icount=][N|auto][,align]'
Signed-off-by: Sebastian Tanase <address@hidden>
Tested-by: Camille Bégué <address@hidden>
---
include/qemu-common.h | 1 +
qemu-options.hx | 16 +++++++++++++---
vl.c | 26 +++++++++++++++++++++++++-
3 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/include/qemu-common.h b/include/qemu-common.h
index 66ceceb..aa65058 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -107,6 +107,7 @@ static inline char *realpath(const char *path, char
*resolved_path)
/* icount */
void configure_icount(const char *option);
extern int use_icount;
+extern int icount_align_option;
#include "qemu/osdep.h"
#include "qemu/bswap.h"
diff --git a/qemu-options.hx b/qemu-options.hx
index c2c0823..0de30e0 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2898,11 +2898,11 @@ re-inject them.
ETEXI
DEF("icount", HAS_ARG, QEMU_OPTION_icount, \
- "-icount [N|auto]\n" \
+ "-icount [icount=N|auto][,align=on|off]\n" \
" enable virtual instruction counter with 2^N clock ticks
per\n" \
- " instruction\n", QEMU_ARCH_ALL)
+ " instruction and enable aligning the host and virtual
clocks\n", QEMU_ARCH_ALL)
STEXI
address@hidden -icount address@hidden|auto]
address@hidden -icount address@hidden|auto][,align=on|off]
@findex -icount
Enable virtual instruction counter. The virtual cpu will execute one
instruction every address@hidden ns of virtual time. If @code{auto} is
specified
@@ -2913,6 +2913,16 @@ Note that while this option can give deterministic
behavior, it does not
provide cycle accurate emulation. Modern CPUs contain superscalar out of
order cores with complex cache hierarchies. The number of instructions
executed often has little or no correlation with actual performance.
+
address@hidden will activate the delay algorithm which will try to
+to synchronise the host clock and the virtual clock. The goal is to
+have a guest running at the real frequency imposed by
+icount. Currently this option does not work with @code{auto}.
+You must provide a value for @option{icount} other than @code{auto}
+for the align option to be taken into account.
+Note: The sync algorithm will work on those icounts on which
+the guest clock runs ahead of the host clock. Typically this happens
+when the icount value is high (how high depends on the host machine).
ETEXI
DEF("watchdog", HAS_ARG, QEMU_OPTION_watchdog, \
diff --git a/vl.c b/vl.c
index 709d8cd..aec4dbf 100644
--- a/vl.c
+++ b/vl.c
@@ -182,6 +182,7 @@ uint8_t *boot_splash_filedata;
size_t boot_splash_filedata_size;
uint8_t qemu_extra_params_fw[2];
+int icount_align_option;
typedef struct FWBootEntry FWBootEntry;
struct FWBootEntry {
@@ -524,6 +525,21 @@ static QemuOptsList qemu_mem_opts = {
},
};
+static QemuOptsList qemu_icount_opts = {
+ .name = "icount",
+ .head = QTAILQ_HEAD_INITIALIZER(qemu_icount_opts.head),
+ .desc = {
+ {
+ .name = "icount",
+ .type = QEMU_OPT_STRING,
+ }, {
+ .name = "align",
+ .type = QEMU_OPT_BOOL,
+ },
+ { /* end of list */ }
+ },
+};
+
/**
* Get machine options
*
@@ -3021,6 +3037,7 @@ int main(int argc, char **argv, char **envp)
qemu_add_opts(&qemu_realtime_opts);
qemu_add_opts(&qemu_msg_opts);
qemu_add_opts(&qemu_name_opts);
+ qemu_add_opts(&qemu_icount_opts);
runstate_init();
@@ -3831,7 +3848,14 @@ int main(int argc, char **argv, char **envp)
}
break;
case QEMU_OPTION_icount:
- icount_option = optarg;
+ opts = qemu_opts_parse(qemu_find_opts("icount"), optarg, 0);
+ if (!opts) {
+ exit(1);
+ }
+ icount_option = qemu_opt_get(opts, "icount");
+ if (icount_option) {
+ icount_align_option = qemu_opt_get_bool(opts, "align", 0);
+ }
break;
case QEMU_OPTION_incoming:
incoming = optarg;
--
2.0.0.rc2