From patchwork Fri Sep 11 12:50:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victor CLEMENT X-Patchwork-Id: 516791 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3303514030C for ; Fri, 11 Sep 2015 22:53:42 +1000 (AEST) Received: from localhost ([::1]:56157 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZaNpg-0006tu-KH for incoming@patchwork.ozlabs.org; Fri, 11 Sep 2015 08:53:36 -0400 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 Received: from localhost (localhost [127.0.0.1]) by zimbra2.corp.accelance.fr (Postfix) with ESMTP id 3E2C0C1468711; Fri, 11 Sep 2015 14:51:12 +0200 (CEST) Received: from mx1.openwide.fr ([127.0.0.1]) by localhost (zimbra2.corp.accelance.fr [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 8lbemhAjf4Cc; Fri, 11 Sep 2015 14:51:09 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra2.corp.accelance.fr (Postfix) with ESMTP id AAA8AC0650DB9; Fri, 11 Sep 2015 14:51:07 +0200 (CEST) X-Virus-Scanned: amavisd-new at accelance.fr Received: from mx1.openwide.fr ([127.0.0.1]) by localhost (zimbra2.corp.accelance.fr [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id XJ9NkbLIxUte; Fri, 11 Sep 2015 14:51:06 +0200 (CEST) Received: from vicx-dell.daviel.openwide.fr. (bob75-2-81-56-46-209.fbx.proxad.net [81.56.46.209]) by zimbra2.corp.accelance.fr (Postfix) with ESMTPSA id DAF94C1490325; Fri, 11 Sep 2015 14:51:05 +0200 (CEST) From: Victor CLEMENT To: qemu-devel@nongnu.org Date: Fri, 11 Sep 2015 14:50:30 +0200 Message-Id: <1441975830-11828-8-git-send-email-victor.clement@openwide.fr> X-Mailer: git-send-email 2.5.1 In-Reply-To: <1441975830-11828-1-git-send-email-victor.clement@openwide.fr> References: <1441975830-11828-1-git-send-email-victor.clement@openwide.fr> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 213.162.52.98 Cc: victor.clement@outlook.com, Victor CLEMENT , julien.viarddegalbert@openwide.fr Subject: [Qemu-devel] [PATCH 7/7] scenario engine: add a Qemu option to start it X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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();