diff options
Diffstat (limited to 'vl.c')
-rw-r--r-- | vl.c | 40 |
1 files changed, 25 insertions, 15 deletions
@@ -1187,7 +1187,7 @@ static QEMUMachine *find_machine(const char *name) return NULL; } -static QEMUMachine *find_default_machine(void) +QEMUMachine *find_default_machine(void) { QEMUMachine *m; @@ -1857,8 +1857,10 @@ struct device_config { DEV_PARALLEL, /* -parallel */ DEV_VIRTCON, /* -virtioconsole */ DEV_DEBUGCON, /* -debugcon */ + DEV_GDB, /* -gdb, -s */ } type; const char *cmdline; + Location loc; QTAILQ_ENTRY(device_config) next; }; QTAILQ_HEAD(, device_config) device_configs = QTAILQ_HEAD_INITIALIZER(device_configs); @@ -1870,6 +1872,7 @@ static void add_device_config(int type, const char *cmdline) conf = g_malloc0(sizeof(*conf)); conf->type = type; conf->cmdline = cmdline; + loc_save(&conf->loc); QTAILQ_INSERT_TAIL(&device_configs, conf, next); } @@ -1881,7 +1884,9 @@ static int foreach_device_config(int type, int (*func)(const char *cmdline)) QTAILQ_FOREACH(conf, &device_configs, next) { if (conf->type != type) continue; + loc_push_restore(&conf->loc); rc = func(conf->cmdline); + loc_pop(&conf->loc); if (0 != rc) return rc; } @@ -2178,7 +2183,6 @@ int qemu_init_main_loop(void) int main(int argc, char **argv, char **envp) { - const char *gdbstub_dev = NULL; int i; int snapshot, linux_boot; const char *icount_option = NULL; @@ -2238,11 +2242,8 @@ int main(int argc, char **argv, char **envp) module_call_init(MODULE_INIT_MACHINE); machine = find_default_machine(); cpu_model = NULL; - initrd_filename = NULL; ram_size = 0; snapshot = 0; - kernel_filename = NULL; - kernel_cmdline = ""; cyls = heads = secs = 0; translation = BIOS_ATA_TRANSLATION_AUTO; @@ -2318,9 +2319,6 @@ int main(int argc, char **argv, char **envp) cpu_model = optarg; } break; - case QEMU_OPTION_initrd: - initrd_filename = optarg; - break; case QEMU_OPTION_hda: { char buf[256]; @@ -2451,10 +2449,13 @@ int main(int argc, char **argv, char **envp) } break; case QEMU_OPTION_kernel: - kernel_filename = optarg; + qemu_opts_set(qemu_find_opts("machine"), 0, "kernel", optarg); + break; + case QEMU_OPTION_initrd: + qemu_opts_set(qemu_find_opts("machine"), 0, "initrd", optarg); break; case QEMU_OPTION_append: - kernel_cmdline = optarg; + qemu_opts_set(qemu_find_opts("machine"), 0, "append", optarg); break; case QEMU_OPTION_cdrom: drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS); @@ -2606,10 +2607,10 @@ int main(int argc, char **argv, char **envp) log_file = optarg; break; case QEMU_OPTION_s: - gdbstub_dev = "tcp::" DEFAULT_GDBSTUB_PORT; + add_device_config(DEV_GDB, "tcp::" DEFAULT_GDBSTUB_PORT); break; case QEMU_OPTION_gdb: - gdbstub_dev = optarg; + add_device_config(DEV_GDB, optarg); break; case QEMU_OPTION_L: data_dir = optarg; @@ -3249,6 +3250,17 @@ int main(int argc, char **argv, char **envp) fprintf(stderr, "qemu_init_main_loop failed\n"); exit(1); } + + kernel_filename = qemu_opt_get(qemu_opts_find(qemu_find_opts("machine"), + 0), "kernel"); + initrd_filename = qemu_opt_get(qemu_opts_find(qemu_find_opts("machine"), + 0), "initrd"); + kernel_cmdline = qemu_opt_get(qemu_opts_find(qemu_find_opts("machine"), + 0), "append"); + if (!kernel_cmdline) { + kernel_cmdline = ""; + } + linux_boot = (kernel_filename != NULL); if (!linux_boot && *kernel_cmdline != '\0') { @@ -3488,9 +3500,7 @@ int main(int argc, char **argv, char **envp) } text_consoles_set_display(ds); - if (gdbstub_dev && gdbserver_start(gdbstub_dev) < 0) { - fprintf(stderr, "qemu: could not open gdbserver on device '%s'\n", - gdbstub_dev); + if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) { exit(1); } |