From nobody Sat Feb 7 08:45:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150817125489718.36808253061281; Mon, 16 Oct 2017 09:27:34 -0700 (PDT) Received: from localhost ([::1]:33997 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e48Eg-0007lu-37 for importer@patchew.org; Mon, 16 Oct 2017 12:27:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34059) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e48B0-0004j9-37 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 12:23:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e48Au-0007Bc-2F for qemu-devel@nongnu.org; Mon, 16 Oct 2017 12:23:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51486) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e48At-0007AW-Oi for qemu-devel@nongnu.org; Mon, 16 Oct 2017 12:23:31 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BD48B806B1; Mon, 16 Oct 2017 16:23:30 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F0C8600CE; Mon, 16 Oct 2017 16:23:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BD48B806B1 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 18:22:54 +0200 Message-Id: <1508170976-96869-5-git-send-email-imammedo@redhat.com> In-Reply-To: <1508170976-96869-1-git-send-email-imammedo@redhat.com> References: <1508170976-96869-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 16 Oct 2017 16:23:30 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 4/6] CLI: add -paused option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, pkrempa@redhat.com, ehabkost@redhat.com, cohuck@redhat.com, armbru@redhat.com, pbonzini@redhat.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Igor Mammedov --- include/sysemu/sysemu.h | 1 + qemu-options.hx | 15 ++++++++++++++ qmp.c | 5 +++++ vl.c | 54 +++++++++++++++++++++++++++++++++++++++++++++= +++- 4 files changed, 74 insertions(+), 1 deletion(-) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index b213696..3feb94f 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -66,6 +66,7 @@ typedef enum WakeupReason { QEMU_WAKEUP_REASON_OTHER, } WakeupReason; =20 +void qemu_exit_preconfig_request(void); void qemu_system_reset_request(ShutdownCause reason); void qemu_system_suspend_request(void); void qemu_register_suspend_notifier(Notifier *notifier); diff --git a/qemu-options.hx b/qemu-options.hx index 39225ae..bd44db8 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3498,6 +3498,21 @@ STEXI Run the emulation in single step mode. ETEXI =20 +DEF("paused", HAS_ARG, QEMU_OPTION_paused, \ + "-paused [state=3D]postconf|preconf\n" + " postconf: pause QEMU after machine is initialized\n" + " preconf: pause QEMU before machine is initialized\n", + QEMU_ARCH_ALL) +STEXI +@item -paused +@findex -paused +if set enabled interactive configuration stages before machine emulation s= tarts. +'postconf' option value mimics -S option behaviour where machine is created +but emulation isn't started. 'preconf' option value pauses QEMU before mac= hine +is created, which allows to query and configure properties affecting machi= ne +initialization. Use monitor/QMP command 'cont' to go to exit paused state. +ETEXI + DEF("S", 0, QEMU_OPTION_S, \ "-S freeze CPU at startup (use 'c' to start execution)\n", QEMU_ARCH_ALL) diff --git a/qmp.c b/qmp.c index e8c3031..49e9a5c 100644 --- a/qmp.c +++ b/qmp.c @@ -167,6 +167,11 @@ void qmp_cont(Error **errp) BlockBackend *blk; Error *local_err =3D NULL; =20 + if (runstate_check(RUN_STATE_PRELAUNCH)) { + qemu_exit_preconfig_request(); + return; + } + /* if there is a dump in background, we should wait until the dump * finished */ if (dump_in_progress()) { diff --git a/vl.c b/vl.c index 3fed457..30631fd 100644 --- a/vl.c +++ b/vl.c @@ -555,6 +555,20 @@ static QemuOptsList qemu_fw_cfg_opts =3D { }, }; =20 +static QemuOptsList qemu_paused_opts =3D { + .name =3D "paused", + .implied_opt_name =3D "state", + .head =3D QTAILQ_HEAD_INITIALIZER(qemu_paused_opts.head), + .desc =3D { + { + .name =3D "state", + .type =3D QEMU_OPT_STRING, + .help =3D "Pause state of QEMU on startup", + }, + { /* end of list */ } + }, +}; + /** * Get machine options * @@ -1689,6 +1703,11 @@ static pid_t shutdown_pid; static int powerdown_requested; static int debug_requested; static int suspend_requested; +static enum { + PRECONFIG_CONT =3D 0, + PRECONFIG_PAUSE, + PRECONFIG_SKIP, +} preconfig_requested; static WakeupReason wakeup_reason; static NotifierList powerdown_notifiers =3D NOTIFIER_LIST_INITIALIZER(powerdown_notifiers); @@ -1773,6 +1792,11 @@ static int qemu_debug_requested(void) return r; } =20 +void qemu_exit_preconfig_request(void) +{ + preconfig_requested =3D PRECONFIG_CONT; +} + /* * Reset the VM. Issue an event unless @reason is SHUTDOWN_CAUSE_NONE. */ @@ -1939,6 +1963,12 @@ static bool main_loop_should_exit(void) RunState r; ShutdownCause request; =20 + if (runstate_check(RUN_STATE_PRELAUNCH)) { + if (preconfig_requested =3D=3D PRECONFIG_CONT) { + preconfig_requested =3D PRECONFIG_SKIP; + return true; + } + } if (qemu_debug_requested()) { vm_stop(RUN_STATE_DEBUG); } @@ -3177,6 +3207,7 @@ int main(int argc, char **argv, char **envp) qemu_add_opts(&qemu_icount_opts); qemu_add_opts(&qemu_semihosting_config_opts); qemu_add_opts(&qemu_fw_cfg_opts); + qemu_add_opts(&qemu_paused_opts); module_call_init(MODULE_INIT_OPTS); =20 runstate_init(); @@ -3845,6 +3876,26 @@ int main(int argc, char **argv, char **envp) exit(1); } break; + case QEMU_OPTION_paused: + { + const char *value; + + opts =3D qemu_opts_parse_noisily(qemu_find_opts("pause= d"), + optarg, true); + if (opts =3D=3D NULL) { + exit(1); + } + value =3D qemu_opt_get(opts, "state"); + if (!strcmp(value, "postconf")) { + autostart =3D 0; + } else if (!strcmp(value, "preconf")) { + preconfig_requested =3D PRECONFIG_PAUSE; + } else { + error_report("incomplete '-paused' option\n"); + exit(1); + } + break; + } case QEMU_OPTION_enable_kvm: olist =3D qemu_find_opts("machine"); qemu_opts_parse_noisily(olist, "accel=3Dkvm", false); @@ -4731,7 +4782,6 @@ int main(int argc, char **argv, char **envp) current_machine->boot_order =3D boot_order; current_machine->cpu_model =3D cpu_model; =20 - /* parse features once if machine provides default cpu_type */ if (machine_class->default_cpu_type) { current_machine->cpu_type =3D machine_class->default_cpu_type; @@ -4741,6 +4791,8 @@ int main(int argc, char **argv, char **envp) } } =20 + main_loop(); /* do monitor/qmp handling at preconfig state if requeste= d */ + machine_run_board_init(current_machine); =20 realtime_init(); --=20 2.7.4