qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 7/7] scenario engine: add a Qemu option to start it


From: Victor CLEMENT
Subject: [Qemu-devel] [PATCH 7/7] scenario engine: add a Qemu option to start it
Date: Fri, 11 Sep 2015 14:50:30 +0200

Add an option to Qemu in order to start the scenario engine at the end
of Qemu initialization.

Signed-off-by: Victor CLEMENT <address@hidden>
---
 qemu-options.hx | 12 ++++++++++++
 vl.c            | 45 ++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/qemu-options.hx b/qemu-options.hx
index 77f5853..d157c2e 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -3436,6 +3436,18 @@ The @code{-no-user-config} option makes QEMU not load 
any of the user-provided
 config files on @var{sysconfdir}, but won't make it skip the QEMU-provided 
config
 files from @var{datadir}.
 ETEXI
+DEF("scenario", HAS_ARG, QEMU_OPTION_scenario,
+    "-scenario [file=<file>]\n"
+    "                enable scenario engine\n",
+    QEMU_ARCH_ALL)
+STEXI
address@hidden -scenario address@hidden
address@hidden -scenario
+
+Enable scenario engine.
+
+This option is only available if QEMU has been compiled with scenario engine.
+ETEXI
 DEF("trace", HAS_ARG, QEMU_OPTION_trace,
     "-trace [events=<file>][,file=<file>]\n"
     "                specify tracing options\n",
diff --git a/vl.c b/vl.c
index 0adbbd6..4fc6953 100644
--- a/vl.c
+++ b/vl.c
@@ -108,6 +108,8 @@ int main(int argc, char **argv)
 
 #include "slirp/libslirp.h"
 
+#include "scenario/scenario.h"
+
 #include "trace.h"
 #include "trace/control.h"
 #include "qemu/queue.h"
@@ -283,6 +285,22 @@ static QemuOptsList qemu_trace_opts = {
     },
 };
 
+static QemuOptsList qemu_scenario_opts = {
+    .name = "scenario",
+    .implied_opt_name = "file",
+    .head = QTAILQ_HEAD_INITIALIZER(qemu_scenario_opts.head),
+    .desc = {
+        {
+            .name = "file",
+            .type = QEMU_OPT_STRING,
+        },{
+            .name = "param",
+            .type = QEMU_OPT_STRING,
+        },
+        { /* end of list */ }
+    },
+};
+
 static QemuOptsList qemu_option_rom_opts = {
     .name = "option-rom",
     .implied_opt_name = "romfile",
@@ -2971,6 +2989,10 @@ int main(int argc, char **argv, char **envp)
         .realloc = realloc_and_trace,
         .free = free_and_trace,
     };
+#ifdef CONFIG_SCENARIO
+    bool use_scenario_engine = false;
+    const char *simulation_file = NULL;
+#endif
     const char *trace_events = NULL;
     const char *trace_file = NULL;
     ram_addr_t maxram_size;
@@ -3002,6 +3024,7 @@ int main(int argc, char **argv, char **envp)
     qemu_add_opts(&qemu_global_opts);
     qemu_add_opts(&qemu_mon_opts);
     qemu_add_opts(&qemu_trace_opts);
+    qemu_add_opts(&qemu_scenario_opts);
     qemu_add_opts(&qemu_option_rom_opts);
     qemu_add_opts(&qemu_machine_opts);
     qemu_add_opts(&qemu_mem_opts);
@@ -3902,6 +3925,22 @@ int main(int argc, char **argv, char **envp)
                 trace_file = qemu_opt_get(opts, "file");
                 break;
             }
+            case QEMU_OPTION_scenario:
+            {
+#ifdef CONFIG_SCENARIO
+                opts = qemu_opts_parse_noisily(qemu_find_opts("scenario"),
+                        optarg, false);
+                if (!opts) {
+                    exit(1);
+                }
+                use_scenario_engine = true;
+                simulation_file = qemu_opt_get(opts, "file");
+#else
+                fprintf(stderr, "Scenario engine is disabled\n");
+                exit(1);
+#endif
+                break;
+            }
             case QEMU_OPTION_readconfig:
                 {
                     int ret = qemu_read_config_file(optarg);
@@ -4649,7 +4688,11 @@ int main(int argc, char **argv, char **envp)
             exit(1);
         }
     }
-
+#ifdef CONFIG_SCENARIO
+    if (use_scenario_engine) {
+        init_scenario_engine(simulation_file);
+    }
+#endif
     main_loop();
     bdrv_close_all();
     pause_all_vcpus();
-- 
2.5.1




reply via email to

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