[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V1 12/32] vl: pause option
From: |
Steve Sistare |
Subject: |
[PATCH V1 12/32] vl: pause option |
Date: |
Thu, 30 Jul 2020 08:14:16 -0700 |
Provide the -pause command-line parameter and the QEMU_PAUSE environment
variable to briefly pause QEMU in main and allow a developer to attach gdb.
Useful when the developer does not invoke QEMU directly, such as when using
libvirt.
Usage:
qemu -pause <seconds>
or
export QEMU_PAUSE=<seconds>
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
qemu-options.hx | 9 +++++++++
softmmu/vl.c | 15 ++++++++++++++-
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/qemu-options.hx b/qemu-options.hx
index 708583b..8505cf2 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -3668,6 +3668,15 @@ SRST
option is experimental.
ERST
+DEF("pause", HAS_ARG, QEMU_OPTION_pause, \
+ "-pause secs Pause for secs seconds on entry to main.\n", QEMU_ARCH_ALL)
+
+SRST
+``--pause secs``
+ Pause for a number of seconds on entry to main. Useful for attaching
+ a debugger after QEMU has been launched by some other entity.
+ERST
+
DEF("S", 0, QEMU_OPTION_S, \
"-S freeze CPU at startup (use 'c' to start execution)\n",
QEMU_ARCH_ALL)
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 8478778..951994f 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -2844,7 +2844,7 @@ static void create_default_memdev(MachineState *ms, const
char *path)
void qemu_init(int argc, char **argv, char **envp)
{
- int i;
+ int i, seconds;
int snapshot, linux_boot;
const char *initrd_filename;
const char *kernel_filename, *kernel_cmdline;
@@ -2882,6 +2882,13 @@ void qemu_init(int argc, char **argv, char **envp)
QemuPluginList plugin_list = QTAILQ_HEAD_INITIALIZER(plugin_list);
int mem_prealloc = 0; /* force preallocation of physical target memory */
+ if (getenv("QEMU_PAUSE")) {
+ seconds = atoi(getenv("QEMU_PAUSE"));
+ printf("Pausing %d seconds for debugger. QEMU PID is %d\n",
+ seconds, getpid());
+ sleep(seconds);
+ }
+
os_set_line_buffering();
error_init(argv[0]);
@@ -3204,6 +3211,12 @@ void qemu_init(int argc, char **argv, char **envp)
case QEMU_OPTION_gdb:
add_device_config(DEV_GDB, optarg);
break;
+ case QEMU_OPTION_pause:
+ seconds = atoi(optarg);
+ printf("Pausing %d seconds for debugger. QEMU PID is %d\n",
+ seconds, getpid());
+ sleep(seconds);
+ break;
case QEMU_OPTION_L:
if (is_help_option(optarg)) {
list_data_dirs = true;
--
1.8.3.1
- Re: [PATCH V1 07/32] savevm: QMP command for cprinfo, (continued)
- [PATCH V1 04/32] savevm: HMP Command for cprsave, Steve Sistare, 2020/07/30
- [PATCH V1 03/32] savevm: QMP command for cprsave, Steve Sistare, 2020/07/30
- [PATCH V1 10/32] kvmclock: restore paused KVM clock, Steve Sistare, 2020/07/30
- [PATCH V1 01/32] savevm: add vmstate handler iterators, Steve Sistare, 2020/07/30
- [PATCH V1 08/32] savevm: HMP command for cprinfo, Steve Sistare, 2020/07/30
- [PATCH V1 06/32] savevm: HMP Command for cprload, Steve Sistare, 2020/07/30
- [PATCH V1 11/32] cpu: disable ticks when suspended, Steve Sistare, 2020/07/30
- [PATCH V1 12/32] vl: pause option,
Steve Sistare <=
- Re: [PATCH V1 12/32] vl: pause option, Alex Bennée, 2020/07/30
[PATCH V1 14/32] savevm: VMS_RESTART and cprsave restart, Steve Sistare, 2020/07/30