qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Victor CLEMENT <victor.clement@openwide.fr>
To: qemu-devel@nongnu.org
Cc: victor.clement@outlook.com,
	Victor CLEMENT <victor.clement@openwide.fr>,
	julien.viarddegalbert@openwide.fr
Subject: [Qemu-devel] [PATCH 7/7] scenario engine: add a Qemu option to start it
Date: Fri, 11 Sep 2015 14:50:30 +0200	[thread overview]
Message-ID: <1441975830-11828-8-git-send-email-victor.clement@openwide.fr> (raw)
In-Reply-To: <1441975830-11828-1-git-send-email-victor.clement@openwide.fr>

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

Signed-off-by: Victor CLEMENT <victor.clement@openwide.fr>
---
 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
+@item -scenario [file=@var{file}]
+@findex -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

  parent reply	other threads:[~2015-09-11 12:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-11 12:50 [Qemu-devel] [PATCH 0/7] Qemu scenario engine Victor CLEMENT
2015-09-11 12:50 ` [Qemu-devel] [PATCH 1/7] configure: add --enable-scenario-engine option Victor CLEMENT
2015-09-11 12:50 ` [Qemu-devel] [PATCH 2/7] gpio-pl061: add a scenario engine interaction API Victor CLEMENT
2015-09-11 12:50 ` [Qemu-devel] [PATCH 3/7] chardev: add a scenario engine backend Victor CLEMENT
2015-09-11 13:11   ` Eric Blake
2015-09-11 12:50 ` [Qemu-devel] [PATCH 4/7] scenario-engine: add utilities Victor CLEMENT
2015-09-11 12:50 ` [Qemu-devel] [PATCH 5/7] scenario-engine: add a time based event scheduler Victor CLEMENT
2015-09-11 12:50 ` [Qemu-devel] [PATCH 6/7] scenario engine: provide a scenario file template Victor CLEMENT
2015-09-11 12:50 ` Victor CLEMENT [this message]
2015-09-11 13:11 ` [Qemu-devel] [PATCH 0/7] Qemu scenario engine Andreas Färber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1441975830-11828-8-git-send-email-victor.clement@openwide.fr \
    --to=victor.clement@openwide.fr \
    --cc=julien.viarddegalbert@openwide.fr \
    --cc=qemu-devel@nongnu.org \
    --cc=victor.clement@outlook.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).