X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=vl.c;h=0b4ed5241c8412c0533d2ffc134bcc4d26ad9072;hb=8bc0673f6dc2485b46da6de8204aaca2a711acea;hp=68e8c003d1b34986cb76b39038608a2b726c0de7;hpb=d15c05fc1f9c0ddbbab1b2a08b976be82f2d0654;p=mirror_qemu.git diff --git a/vl.c b/vl.c index 68e8c003d1..0b4ed5241c 100644 --- a/vl.c +++ b/vl.c @@ -62,6 +62,7 @@ int main(int argc, char **argv) #include "hw/usb.h" #include "hw/i386/pc.h" #include "hw/isa/isa.h" +#include "hw/scsi/scsi.h" #include "hw/bt.h" #include "sysemu/watchdog.h" #include "hw/smbios/smbios.h" @@ -94,6 +95,9 @@ int main(int argc, char **argv) #include "migration/colo.h" #include "sysemu/kvm.h" #include "sysemu/hax.h" +#include "qapi/qobject-input-visitor.h" +#include "qapi/qobject-input-visitor.h" +#include "qapi-visit.h" #include "qapi/qmp/qjson.h" #include "qemu/option.h" #include "qemu/config-file.h" @@ -110,7 +114,7 @@ int main(int argc, char **argv) #include "slirp/libslirp.h" -#include "trace.h" +#include "trace-root.h" #include "trace/control.h" #include "qemu/queue.h" #include "sysemu/arch_init.h" @@ -151,10 +155,10 @@ static int full_screen = 0; static int no_frame = 0; int no_quit = 0; static bool grab_on_hover; -CharDriverState *serial_hds[MAX_SERIAL_PORTS]; -CharDriverState *parallel_hds[MAX_PARALLEL_PORTS]; -CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES]; -CharDriverState *sclp_hds[MAX_SCLP_CONSOLES]; +Chardev *serial_hds[MAX_SERIAL_PORTS]; +Chardev *parallel_hds[MAX_PARALLEL_PORTS]; +Chardev *virtcon_hds[MAX_VIRTIO_CONSOLES]; +Chardev *sclp_hds[MAX_SCLP_CONSOLES]; int win2k_install_hack = 0; int singlestep = 0; int smp_cpus = 1; @@ -226,6 +230,7 @@ static struct { { .driver = "ide-hd", .flag = &default_cdrom }, { .driver = "ide-drive", .flag = &default_cdrom }, { .driver = "scsi-cd", .flag = &default_cdrom }, + { .driver = "scsi-hd", .flag = &default_cdrom }, { .driver = "virtio-serial-pci", .flag = &default_virtcon }, { .driver = "virtio-serial", .flag = &default_virtcon }, { .driver = "VGA", .flag = &default_vga }, @@ -299,6 +304,26 @@ static QemuOptsList qemu_machine_opts = { }, }; +static QemuOptsList qemu_accel_opts = { + .name = "accel", + .implied_opt_name = "accel", + .head = QTAILQ_HEAD_INITIALIZER(qemu_accel_opts.head), + .merge_lists = true, + .desc = { + { + .name = "accel", + .type = QEMU_OPT_STRING, + .help = "Select the type of accelerator", + }, + { + .name = "thread", + .type = QEMU_OPT_STRING, + .help = "Enable/disable multi-threaded TCG", + }, + { /* end of list */ } + }, +}; + static QemuOptsList qemu_boot_opts = { .name = "boot-opts", .implied_opt_name = "order", @@ -465,6 +490,9 @@ static QemuOptsList qemu_icount_opts = { }, { .name = "rrfile", .type = QEMU_OPT_STRING, + }, { + .name = "rrsnapshot", + .type = QEMU_OPT_STRING, }, { /* end of list */ } }, @@ -512,43 +540,6 @@ static QemuOptsList qemu_fw_cfg_opts = { }, }; -#ifdef CONFIG_LIBISCSI -static QemuOptsList qemu_iscsi_opts = { - .name = "iscsi", - .head = QTAILQ_HEAD_INITIALIZER(qemu_iscsi_opts.head), - .desc = { - { - .name = "user", - .type = QEMU_OPT_STRING, - .help = "username for CHAP authentication to target", - },{ - .name = "password", - .type = QEMU_OPT_STRING, - .help = "password for CHAP authentication to target", - },{ - .name = "password-secret", - .type = QEMU_OPT_STRING, - .help = "ID of the secret providing password for CHAP " - "authentication to target", - },{ - .name = "header-digest", - .type = QEMU_OPT_STRING, - .help = "HeaderDigest setting. " - "{CRC32C|CRC32C-NONE|NONE-CRC32C|NONE}", - },{ - .name = "initiator-name", - .type = QEMU_OPT_STRING, - .help = "Initiator iqn name to use when connecting", - },{ - .name = "timeout", - .type = QEMU_OPT_NUMBER, - .help = "Request timeout in seconds (default 0 = no timeout)", - }, - { /* end of list */ } - }, -}; -#endif - /** * Get machine options * @@ -758,7 +749,7 @@ StatusInfo *qmp_query_status(Error **errp) return info; } -static bool qemu_vmstop_requested(RunState *r) +bool qemu_vmstop_requested(RunState *r) { qemu_mutex_lock(&vmstop_lock); *r = vmstop_requested; @@ -779,34 +770,6 @@ void qemu_system_vmstop_request(RunState state) qemu_notify_event(); } -void vm_start(void) -{ - RunState requested; - - qemu_vmstop_requested(&requested); - if (runstate_is_running() && requested == RUN_STATE__MAX) { - return; - } - - /* Ensure that a STOP/RESUME pair of events is emitted if a - * vmstop request was pending. The BLOCK_IO_ERROR event, for - * example, according to documentation is always followed by - * the STOP event. - */ - if (runstate_is_running()) { - qapi_event_send_stop(&error_abort); - } else { - replay_enable_events(); - cpu_enable_ticks(); - runstate_set(RUN_STATE_RUNNING); - vm_state_notify(1, RUN_STATE_RUNNING); - resume_all_vcpus(); - } - - qapi_event_send_resume(&error_abort); -} - - /***********************************************************/ /* real time host monotonic timer */ @@ -1553,7 +1516,7 @@ MachineInfoList *qmp_query_machines(Error **errp) info->name = g_strdup(mc->name); info->cpu_max = !mc->max_cpus ? 1 : mc->max_cpus; - info->hotpluggable_cpus = !!mc->query_hotpluggable_cpus; + info->hotpluggable_cpus = mc->has_hotpluggable_cpus; entry = g_malloc0(sizeof(*entry)); entry->value = info; @@ -1741,18 +1704,34 @@ void qemu_system_reset(bool report) cpu_synchronize_all_post_reset(); } -void qemu_system_guest_panicked(void) +void qemu_system_guest_panicked(GuestPanicInformation *info) { + qemu_log_mask(LOG_GUEST_ERROR, "Guest crashed\n"); + if (current_cpu) { current_cpu->crash_occurred = true; } - qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, &error_abort); + qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, + !!info, info, &error_abort); vm_stop(RUN_STATE_GUEST_PANICKED); if (!no_shutdown) { qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_POWEROFF, - &error_abort); + !!info, info, &error_abort); qemu_system_shutdown_request(); } + + if (info) { + if (info->type == GUEST_PANIC_INFORMATION_TYPE_HYPER_V) { + qemu_log_mask(LOG_GUEST_ERROR, "HV crash parameters: (%#"PRIx64 + " %#"PRIx64" %#"PRIx64" %#"PRIx64" %#"PRIx64")\n", + info->u.hyper_v.arg1, + info->u.hyper_v.arg2, + info->u.hyper_v.arg3, + info->u.hyper_v.arg4, + info->u.hyper_v.arg5); + } + qapi_free_GuestPanicInformation(info); + } } void qemu_system_reset_request(void) @@ -1909,17 +1888,14 @@ static bool main_loop_should_exit(void) static void main_loop(void) { - bool nonblocking; - int last_io = 0; #ifdef CONFIG_PROFILER int64_t ti; #endif do { - nonblocking = tcg_enabled() && last_io > 0; #ifdef CONFIG_PROFILER ti = profile_getclock(); #endif - last_io = main_loop_wait(nonblocking); + main_loop_wait(false); #ifdef CONFIG_PROFILER dev_time += profile_getclock() - ti; #endif @@ -2356,7 +2332,7 @@ static int fsdev_init_func(void *opaque, QemuOpts *opts, Error **errp) static int mon_init_func(void *opaque, QemuOpts *opts, Error **errp) { - CharDriverState *chr; + Chardev *chr; const char *chardev; const char *mode; int flags; @@ -2973,7 +2949,8 @@ int main(int argc, char **argv, char **envp) const char *boot_once = NULL; DisplayState *ds; int cyls, heads, secs, translation; - QemuOpts *hda_opts = NULL, *opts, *machine_opts, *icount_opts = NULL; + QemuOpts *opts, *machine_opts; + QemuOpts *hda_opts = NULL, *icount_opts = NULL, *accel_opts = NULL; QemuOptsList *olist; int optind; const char *optarg; @@ -2999,6 +2976,13 @@ int main(int argc, char **argv, char **envp) Error *main_loop_err = NULL; Error *err = NULL; bool list_data_dirs = false; + typedef struct BlockdevOptions_queue { + BlockdevOptions *bdo; + Location loc; + QSIMPLEQ_ENTRY(BlockdevOptions_queue) entry; + } BlockdevOptions_queue; + QSIMPLEQ_HEAD(, BlockdevOptions_queue) bdo_queue + = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue); module_call_init(MODULE_INIT_TRACE); @@ -3011,7 +2995,7 @@ int main(int argc, char **argv, char **envp) qemu_init_exec_dir(argv[0]); module_call_init(MODULE_INIT_QOM); - module_call_init(MODULE_INIT_QAPI); + monitor_init_qmp_commands(); qemu_add_opts(&qemu_drive_opts); qemu_add_drive_opts(&qemu_legacy_drive_opts); @@ -3028,6 +3012,7 @@ int main(int argc, char **argv, char **envp) qemu_add_opts(&qemu_trace_opts); qemu_add_opts(&qemu_option_rom_opts); qemu_add_opts(&qemu_machine_opts); + qemu_add_opts(&qemu_accel_opts); qemu_add_opts(&qemu_mem_opts); qemu_add_opts(&qemu_smp_opts); qemu_add_opts(&qemu_boot_opts); @@ -3042,9 +3027,6 @@ 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); -#ifdef CONFIG_LIBISCSI - qemu_add_opts(&qemu_iscsi_opts); -#endif module_call_init(MODULE_INIT_OPTS); runstate_init(); @@ -3143,6 +3125,25 @@ int main(int argc, char **argv, char **envp) drive_add(IF_DEFAULT, popt->index - QEMU_OPTION_hda, optarg, HD_OPTS); break; + case QEMU_OPTION_blockdev: + { + Visitor *v; + BlockdevOptions_queue *bdo; + + v = qobject_input_visitor_new_str(optarg, "driver", &err); + if (!v) { + error_report_err(err); + exit(1); + } + + bdo = g_new(BlockdevOptions_queue, 1); + visit_type_BlockdevOptions(v, NULL, &bdo->bdo, + &error_fatal); + visit_free(v); + loc_save(&bdo->loc); + QSIMPLEQ_INSERT_TAIL(&bdo_queue, bdo, entry); + break; + } case QEMU_OPTION_drive: if (drive_def(optarg) == NULL) { exit(1); @@ -3723,6 +3724,26 @@ int main(int argc, char **argv, char **envp) qdev_prop_register_global(&kvm_pit_lost_tick_policy); break; } + case QEMU_OPTION_accel: + accel_opts = qemu_opts_parse_noisily(qemu_find_opts("accel"), + optarg, true); + optarg = qemu_opt_get(accel_opts, "accel"); + + olist = qemu_find_opts("machine"); + if (strcmp("kvm", optarg) == 0) { + qemu_opts_parse_noisily(olist, "accel=kvm", false); + } else if (strcmp("xen", optarg) == 0) { + qemu_opts_parse_noisily(olist, "accel=xen", false); + } else if (strcmp("tcg", optarg) == 0) { + qemu_opts_parse_noisily(olist, "accel=tcg", false); + } else { + if (!is_help_option(optarg)) { + error_printf("Unknown accelerator: %s", optarg); + } + error_printf("Supported accelerators: kvm, xen, tcg\n"); + exit(1); + } + break; case QEMU_OPTION_usb: olist = qemu_find_opts("machine"); qemu_opts_parse_noisily(olist, "usb=on", false); @@ -4289,6 +4310,8 @@ int main(int argc, char **argv, char **envp) sdl_display_early_init(request_opengl); } + qemu_console_early_init(); + if (request_opengl == 1 && display_opengl == 0) { #if defined(CONFIG_OPENGL) error_report("OpenGL is not supported by the display"); @@ -4400,6 +4423,8 @@ int main(int argc, char **argv, char **envp) qemu_opts_del(icount_opts); } + qemu_tcg_configure(accel_opts, &error_fatal); + if (default_net) { QemuOptsList *net = qemu_find_opts("net"); qemu_opts_set(net, NULL, "type", "nic", &error_abort); @@ -4449,6 +4474,16 @@ int main(int argc, char **argv, char **envp) } /* open the virtual block devices */ + while (!QSIMPLEQ_EMPTY(&bdo_queue)) { + BlockdevOptions_queue *bdo = QSIMPLEQ_FIRST(&bdo_queue); + + QSIMPLEQ_REMOVE_HEAD(&bdo_queue, entry); + loc_push_restore(&bdo->loc); + qmp_blockdev_add(bdo->bdo, &error_fatal); + loc_pop(&bdo->loc); + qapi_free_BlockdevOptions(bdo->bdo); + g_free(bdo); + } if (snapshot || replay_mode != REPLAY_MODE_NONE) { qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot, NULL, NULL); @@ -4525,8 +4560,6 @@ int main(int argc, char **argv, char **envp) audio_init(); - cpu_synchronize_all_post_init(); - if (hax_enabled()) { hax_sync_vcpus(); } @@ -4552,10 +4585,21 @@ int main(int argc, char **argv, char **envp) exit(1); } + cpu_synchronize_all_post_init(); + numa_post_machine_init(); rom_reset_order_override(); + /* + * Create frontends for -drive if=scsi leftovers. + * Normally, frontends for -drive get created by machine + * initialization for onboard SCSI HBAs. However, we create a few + * more ever since SCSI qdevification, but this is pretty much an + * implementation accident, and deprecated. + */ + scsi_legacy_handle_cmdline(); + /* Did we create any drives that we failed to create a device for? */ drive_check_orphaned(); @@ -4634,7 +4678,9 @@ int main(int argc, char **argv, char **envp) replay_checkpoint(CHECKPOINT_RESET); qemu_system_reset(VMRESET_SILENT); register_global_state(); - if (loadvm) { + if (replay_mode != REPLAY_MODE_NONE) { + replay_vmstate_init(); + } else if (loadvm) { if (load_vmstate(loadvm) < 0) { autostart = 0; }