Once qemu_tcg_configure is turned into a QOM property setter, it will not
be able to set a default value for mttcg_enabled.  Setting the default will
move to the TCG init_machine method, which currently runs after "-icount"
is processed.

However, it is harmless to do configure_icount for all accelerators; we will
just fail later if a non-TCG accelerator being selected.  So do that.

Signed-off-by: Paolo Bonzini <pbonz...@redhat.com>
---
 vl.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/vl.c b/vl.c
index fc9e70f..dbc99d7 100644
--- a/vl.c
+++ b/vl.c
@@ -2829,11 +2829,7 @@ static void user_register_global_props(void)
 
 static int do_configure_icount(void *opaque, QemuOpts *opts, Error **errp)
 {
-    if (tcg_enabled()) {
-        configure_icount(opts, errp);
-    } else {
-        error_setg(errp, "-icount is not allowed with hardware 
virtualization");
-    }
+    configure_icount(opts, errp);
     return 0;
 }
 
@@ -2854,6 +2850,9 @@ static void configure_accelerators(const char *progname)
     bool init_failed = false;
     AccelClass *acc = NULL;
 
+    qemu_opts_foreach(qemu_find_opts("icount"),
+                      do_configure_icount, NULL, &error_fatal);
+
     accel = qemu_opt_get(qemu_get_machine_opts(), "accel");
     if (accel == NULL) {
         /* Select the default accelerator */
@@ -2901,11 +2900,13 @@ static void configure_accelerators(const char *progname)
         error_report("Back to %s accelerator", acc->name);
     }
 
-    qemu_opts_foreach(qemu_find_opts("icount"),
-                      do_configure_icount, NULL, &error_fatal);
-
     qemu_opts_foreach(qemu_find_opts("accel"),
                       do_configure_accelerator, NULL, &error_fatal);
+
+    if (!tcg_enabled() && use_icount) {
+        error_report("-icount is not allowed with hardware virtualization");
+        exit(1);
+    }
 }
 
 int main(int argc, char **argv, char **envp)
-- 
1.8.3.1



Reply via email to