qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 2/3] icount: add rt parameter to the -icount option


From: Victor CLEMENT
Subject: [Qemu-devel] [PATCH 2/3] icount: add rt parameter to the -icount option to toogle icount_no_rt mode
Date: Wed, 27 May 2015 13:52:02 +0200

The 'rt' parameter sets the icount_no_rt mode, which is not enabled by
default. To enable it, add the 'nort' parameter (or 'rt=off') to the
qemu -icount option.

Signed-off-by: Victor CLEMENT <address@hidden>
---
 cpus.c          | 15 +++++++++++++--
 qemu-options.hx | 12 ++++++++++--
 vl.c            |  3 +++
 3 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/cpus.c b/cpus.c
index 012d14b..eac3e19 100644
--- a/cpus.c
+++ b/cpus.c
@@ -520,9 +520,18 @@ void configure_icount(QemuOpts *opts, Error **errp)
         }
         return;
     }
+
+    icount_no_rt = !qemu_opt_get_bool(opts, "rt", true);
+    if (!icount_no_rt) {
+        icount_warp_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL_RT,
+                                         icount_warp_rt, NULL);
+    }
+
     icount_align_option = qemu_opt_get_bool(opts, "align", false);
-    icount_warp_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL_RT,
-                                     icount_warp_rt, NULL);
+
+    if (icount_align_option && icount_no_rt) {
+        error_setg(errp, "align and nort options are incompatible");
+    }
     if (strcmp(option, "auto") != 0) {
         errno = 0;
         icount_time_shift = strtol(option, &rem_str, 0);
@@ -533,6 +542,8 @@ void configure_icount(QemuOpts *opts, Error **errp)
         return;
     } else if (icount_align_option) {
         error_setg(errp, "shift=auto and align=on are incompatible");
+    } else if (icount_no_rt) {
+        error_setg(errp, "shift=auto and nort are incompatible");
     }
 
     use_icount = 2;
diff --git a/qemu-options.hx b/qemu-options.hx
index ec356f6..531bed7 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -3086,9 +3086,10 @@ 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][,nort]\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)
+    "                instruction, enable aligning the host and virtual 
clocks\n" \
+    "                or disable real time cpu sleeping\n", QEMU_ARCH_ALL)
 STEXI
 @item -icount address@hidden|auto]
 @findex -icount
@@ -3097,6 +3098,13 @@ instruction every address@hidden ns of virtual time.  If 
@code{auto} is specified
 then the virtual cpu speed will be automatically adjusted to keep virtual
 time within a few seconds of real time.
 
+When the virtual cpu is sleeping, the virtual time will advance at default
+speed unless @option{nort} is specified.
+With @option{nort}, the virtual time will jump to the next timer deadline
+instantly whenever the virtual cpu goes to sleep mode and will not advance
+if no timer is enabled. This behavior give deterministic execution times from
+the guest point of view.
+
 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
diff --git a/vl.c b/vl.c
index 15bccc4..0c377e8 100644
--- a/vl.c
+++ b/vl.c
@@ -470,6 +470,9 @@ static QemuOptsList qemu_icount_opts = {
         }, {
             .name = "align",
             .type = QEMU_OPT_BOOL,
+        }, {
+            .name = "rt",
+            .type = QEMU_OPT_BOOL,
         },
         { /* end of list */ }
     },
-- 
2.3.7




reply via email to

[Prev in Thread] Current Thread [Next in Thread]