Received: from eggs.gnu.org ([2001:4830:134:3::10]:56857) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaNnN-0002Wa-Vr for qemu-devel@nongnu.org; Fri, 11 Sep 2015 08:51:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZaNnM-000681-V2 for qemu-devel@nongnu.org; Fri, 11 Sep 2015 08:51:13 -0400 Received: from mx1.openwide.fr ([213.162.52.98]:47230) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaNnM-00067b-Ll for qemu-devel@nongnu.org; Fri, 11 Sep 2015 08:51:12 -0400 From: Victor CLEMENT Date: Fri, 11 Sep 2015 14:50:30 +0200 Message-Id: <1441975830-11828-8-git-send-email-victor.clement@openwide.fr> In-Reply-To: <1441975830-11828-1-git-send-email-victor.clement@openwide.fr> References: <1441975830-11828-1-git-send-email-victor.clement@openwide.fr> Subject: [Qemu-devel] [PATCH 7/7] scenario engine: add a Qemu option to start it List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: victor.clement@outlook.com, Victor CLEMENT , julien.viarddegalbert@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 --- 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=]\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=]\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