#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"
+#include "hw/acpi/acpi.h"
#include "hw/xen/xen.h"
#include "hw/qdev.h"
#include "hw/loader.h"
#include "sysemu/numa.h"
#include "exec/gdbstub.h"
#include "qemu/timer.h"
-#include "sysemu/char.h"
+#include "chardev/char.h"
#include "qemu/bitmap.h"
#include "qemu/log.h"
#include "sysemu/blockdev.h"
#include "hw/block/block.h"
-#include "migration/block.h"
+#include "migration/misc.h"
+#include "migration/snapshot.h"
+#include "migration/global_state.h"
#include "sysemu/tpm.h"
#include "sysemu/dma.h"
+#include "hw/audio/soundhw.h"
#include "audio/audio.h"
-#include "migration/migration.h"
#include "sysemu/cpus.h"
#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"
#include "slirp/libslirp.h"
-#include "trace.h"
+#include "trace-root.h"
#include "trace/control.h"
#include "qemu/queue.h"
#include "sysemu/arch_init.h"
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;
bool xen_allowed;
uint32_t xen_domid;
enum xen_mode xen_mode = XEN_EMULATE;
+bool xen_domid_restrict;
static int has_defaults = 1;
static int default_serial = 1;
{ .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 },
},
};
+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",
}, {
.name = "rrfile",
.type = QEMU_OPT_STRING,
+ }, {
+ .name = "rrsnapshot",
+ .type = QEMU_OPT_STRING,
},
{ /* end of list */ }
},
},
};
-#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
*
return info;
}
-static bool qemu_vmstop_requested(RunState *r)
+bool qemu_vmstop_requested(RunState *r)
{
qemu_mutex_lock(&vmstop_lock);
*r = vmstop_requested;
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 */
max_cpus = qemu_opt_get_number(opts, "maxcpus", cpus);
- if (max_cpus > MAX_CPUMASK_BITS) {
- error_report("unsupported number of maxcpus");
- exit(1);
- }
-
if (max_cpus < cpus) {
error_report("maxcpus must be equal to or greater than smp");
exit(1);
void hmp_usb_add(Monitor *mon, const QDict *qdict)
{
const char *devname = qdict_get_str(qdict, "devname");
+
+ error_report("usb_add is deprecated, please use device_add instead");
+
if (usb_device_add(devname) < 0) {
error_report("could not add USB device '%s'", devname);
}
void hmp_usb_del(Monitor *mon, const QDict *qdict)
{
const char *devname = qdict_get_str(qdict, "devname");
+
+ error_report("usb_del is deprecated, please use device_del instead");
+
if (usb_device_del(devname) < 0) {
error_report("could not delete USB device '%s'", devname);
}
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;
}
}
-/* reset/shutdown handler */
-
-typedef struct QEMUResetEntry {
- QTAILQ_ENTRY(QEMUResetEntry) entry;
- QEMUResetHandler *func;
- void *opaque;
-} QEMUResetEntry;
-
-static QTAILQ_HEAD(reset_handlers, QEMUResetEntry) reset_handlers =
- QTAILQ_HEAD_INITIALIZER(reset_handlers);
-static int reset_requested;
-static int shutdown_requested, shutdown_signal = -1;
+static ShutdownCause reset_requested;
+static ShutdownCause shutdown_requested;
+static int shutdown_signal;
static pid_t shutdown_pid;
static int powerdown_requested;
static int debug_requested;
NOTIFIER_LIST_INITIALIZER(wakeup_notifiers);
static uint32_t wakeup_reason_mask = ~(1 << QEMU_WAKEUP_REASON_NONE);
-int qemu_shutdown_requested_get(void)
+ShutdownCause qemu_shutdown_requested_get(void)
{
return shutdown_requested;
}
-int qemu_reset_requested_get(void)
+ShutdownCause qemu_reset_requested_get(void)
{
return reset_requested;
}
static int qemu_shutdown_requested(void)
{
- return atomic_xchg(&shutdown_requested, 0);
+ return atomic_xchg(&shutdown_requested, SHUTDOWN_CAUSE_NONE);
}
static void qemu_kill_report(void)
{
- if (!qtest_driver() && shutdown_signal != -1) {
+ if (!qtest_driver() && shutdown_signal) {
if (shutdown_pid == 0) {
/* This happens for eg ^C at the terminal, so it's worth
* avoiding printing an odd message in that case.
shutdown_cmd ? shutdown_cmd : "<unknown process>");
g_free(shutdown_cmd);
}
- shutdown_signal = -1;
+ shutdown_signal = 0;
}
}
-static int qemu_reset_requested(void)
+static ShutdownCause qemu_reset_requested(void)
{
- int r = reset_requested;
+ ShutdownCause r = reset_requested;
+
if (r && replay_checkpoint(CHECKPOINT_RESET_REQUESTED)) {
- reset_requested = 0;
+ reset_requested = SHUTDOWN_CAUSE_NONE;
return r;
}
- return false;
+ return SHUTDOWN_CAUSE_NONE;
}
static int qemu_suspend_requested(void)
return r;
}
-void qemu_register_reset(QEMUResetHandler *func, void *opaque)
-{
- QEMUResetEntry *re = g_malloc0(sizeof(QEMUResetEntry));
-
- re->func = func;
- re->opaque = opaque;
- QTAILQ_INSERT_TAIL(&reset_handlers, re, entry);
-}
-
-void qemu_unregister_reset(QEMUResetHandler *func, void *opaque)
-{
- QEMUResetEntry *re;
-
- QTAILQ_FOREACH(re, &reset_handlers, entry) {
- if (re->func == func && re->opaque == opaque) {
- QTAILQ_REMOVE(&reset_handlers, re, entry);
- g_free(re);
- return;
- }
- }
-}
-
-void qemu_devices_reset(void)
-{
- QEMUResetEntry *re, *nre;
-
- /* reset all devices */
- QTAILQ_FOREACH_SAFE(re, &reset_handlers, entry, nre) {
- re->func(re->opaque);
- }
-}
-
-void qemu_system_reset(bool report)
+/*
+ * Reset the VM. Issue an event unless @reason is SHUTDOWN_CAUSE_NONE.
+ */
+void qemu_system_reset(ShutdownCause reason)
{
MachineClass *mc;
} else {
qemu_devices_reset();
}
- if (report) {
- qapi_event_send_reset(&error_abort);
+ if (reason) {
+ qapi_event_send_reset(shutdown_caused_by_guest(reason),
+ &error_abort);
}
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,
+ !!info, info, &error_abort);
+ qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_PANIC);
+ }
+
+ 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)
+void qemu_system_reset_request(ShutdownCause reason)
{
if (no_reboot) {
- shutdown_requested = 1;
+ shutdown_requested = reason;
} else {
- reset_requested = 1;
+ reset_requested = reason;
}
cpu_stop_current();
qemu_notify_event();
/* Cannot call qemu_system_shutdown_request directly because
* we are in a signal handler.
*/
- shutdown_requested = 1;
+ shutdown_requested = SHUTDOWN_CAUSE_HOST_SIGNAL;
qemu_notify_event();
}
-void qemu_system_shutdown_request(void)
+void qemu_system_shutdown_request(ShutdownCause reason)
{
- trace_qemu_system_shutdown_request();
- replay_shutdown_request();
- shutdown_requested = 1;
+ trace_qemu_system_shutdown_request(reason);
+ replay_shutdown_request(reason);
+ shutdown_requested = reason;
qemu_notify_event();
}
static bool main_loop_should_exit(void)
{
RunState r;
+ ShutdownCause request;
+
if (qemu_debug_requested()) {
vm_stop(RUN_STATE_DEBUG);
}
if (qemu_suspend_requested()) {
qemu_system_suspend();
}
- if (qemu_shutdown_requested()) {
+ request = qemu_shutdown_requested();
+ if (request) {
qemu_kill_report();
- qapi_event_send_shutdown(&error_abort);
+ qapi_event_send_shutdown(shutdown_caused_by_guest(request),
+ &error_abort);
if (no_shutdown) {
vm_stop(RUN_STATE_SHUTDOWN);
} else {
return true;
}
}
- if (qemu_reset_requested()) {
+ request = qemu_reset_requested();
+ if (request) {
pause_all_vcpus();
- qemu_system_reset(VMRESET_REPORT);
+ qemu_system_reset(request);
resume_all_vcpus();
if (!runstate_check(RUN_STATE_RUNNING) &&
!runstate_check(RUN_STATE_INMIGRATE)) {
}
if (qemu_wakeup_requested()) {
pause_all_vcpus();
- qemu_system_reset(VMRESET_SILENT);
+ qemu_system_reset(SHUTDOWN_CAUSE_NONE);
notifier_list_notify(&wakeup_notifiers, &wakeup_reason);
wakeup_reason = QEMU_WAKEUP_REASON_NONE;
resume_all_vcpus();
static void main_loop(void)
{
- bool nonblocking;
- int last_io = 0;
#ifdef CONFIG_PROFILER
int64_t ti;
#endif
do {
- nonblocking = !kvm_enabled() && !xen_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
DT_SDL,
DT_COCOA,
DT_GTK,
+ DT_EGL,
DT_NONE,
} DisplayType;
error_report("VNC requires a display argument vnc=<display>");
exit(1);
}
+ } else if (strstart(p, "egl-headless", &opts)) {
+#ifdef CONFIG_OPENGL_DMABUF
+ request_opengl = 1;
+ display_opengl = 1;
+ display = DT_EGL;
+#else
+ fprintf(stderr, "egl support is disabled\n");
+ exit(1);
+#endif
} else if (strstart(p, "curses", &opts)) {
#ifdef CONFIG_CURSES
display = DT_CURSES;
static int mon_init_func(void *opaque, QemuOpts *opts, Error **errp)
{
- CharDriverState *chr;
+ Chardev *chr;
const char *chardev;
const char *mode;
int flags;
g_str_equal(type, "filter-mirror") ||
g_str_equal(type, "filter-redirector") ||
g_str_equal(type, "colo-compare") ||
- g_str_equal(type, "filter-rewriter")) {
+ g_str_equal(type, "filter-rewriter") ||
+ g_str_equal(type, "filter-replay")) {
return false;
}
return 0;
}
+static int qemu_read_default_config_file(void)
+{
+ int ret;
+
+ ret = qemu_read_config_file(CONFIG_QEMU_CONFDIR "/qemu.conf");
+ if (ret < 0 && ret != -ENOENT) {
+ return ret;
+ }
+
+ return 0;
+}
+
+static void user_register_global_props(void)
+{
+ qemu_opts_foreach(qemu_find_opts("global"),
+ global_init_func, NULL, NULL);
+}
+
+/*
+ * Note: we should see that these properties are actually having a
+ * priority: accel < machine < user. This means e.g. when user
+ * specifies something in "-global", it'll always be used with highest
+ * priority than either machine/accelerator compat properties.
+ */
+static void register_global_properties(MachineState *ms)
+{
+ accel_register_compat_props(ms->accelerator);
+ machine_register_compat_props(ms);
+ user_register_global_props();
+}
+
int main(int argc, char **argv, char **envp)
{
int i;
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;
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);
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);
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);
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();
}
}
- if (defconfig) {
- int ret;
- ret = qemu_read_default_config_files(userconfig);
- if (ret < 0) {
+ if (defconfig && userconfig) {
+ if (qemu_read_default_config_file() < 0) {
exit(1);
}
}
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);
}
}
}
+ error_report("'-hdachs' is deprecated, please use '-device"
+ " ide-hd,cyls=c,heads=h,secs=s,...' instead");
break;
case QEMU_OPTION_numa:
opts = qemu_opts_parse_noisily(qemu_find_opts("numa"),
exit(1);
}
fsdev = qemu_opts_create(qemu_find_opts("fsdev"),
+ qemu_opts_id(opts) ?:
qemu_opt_get(opts, "mount_tag"),
1, NULL);
if (!fsdev) {
- error_report("duplicate fsdev id: %s",
+ error_report("duplicate or invalid fsdev id: %s",
qemu_opt_get(opts, "mount_tag"));
exit(1);
}
&error_abort);
qemu_opt_set(device, "driver", "virtio-9p-pci", &error_abort);
qemu_opt_set(device, "fsdev",
- qemu_opt_get(opts, "mount_tag"), &error_abort);
+ qemu_opts_id(fsdev), &error_abort);
qemu_opt_set(device, "mount_tag",
qemu_opt_get(opts, "mount_tag"), &error_abort);
break;
if (!opts) {
exit(1);
}
- do_acpitable_option(opts);
+ acpi_table_add(opts, &error_fatal);
break;
case QEMU_OPTION_smbios:
opts = qemu_opts_parse_noisily(qemu_find_opts("smbios"),
if (!opts) {
exit(1);
}
- do_smbios_option(opts);
+ smbios_entry_add(opts, &error_fatal);
break;
case QEMU_OPTION_fwcfg:
opts = qemu_opts_parse_noisily(qemu_find_opts("fw_cfg"),
olist = qemu_find_opts("machine");
qemu_opts_parse_noisily(olist, "accel=kvm", false);
break;
+ case QEMU_OPTION_enable_hax:
+ olist = qemu_find_opts("machine");
+ qemu_opts_parse_noisily(olist, "accel=hax", false);
+ break;
case QEMU_OPTION_M:
case QEMU_OPTION_machine:
olist = qemu_find_opts("machine");
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");
+ if (!optarg || is_help_option(optarg)) {
+ error_printf("Possible accelerators: kvm, xen, hax, tcg\n");
+ exit(0);
+ }
+ opts = qemu_opts_create(qemu_find_opts("machine"), NULL,
+ false, &error_abort);
+ qemu_opt_set(opts, "accel", optarg, &error_abort);
+ break;
case QEMU_OPTION_usb:
olist = qemu_find_opts("machine");
qemu_opts_parse_noisily(olist, "usb=on", false);
break;
case QEMU_OPTION_usbdevice:
+ error_report("'-usbdevice' is deprecated, please use "
+ "'-device usb-...' instead");
olist = qemu_find_opts("machine");
qemu_opts_parse_noisily(olist, "usb=on", false);
add_device_config(DEV_USB, optarg);
configure_rtc(opts);
break;
case QEMU_OPTION_tb_size:
- tcg_tb_size = strtol(optarg, NULL, 0);
- if (tcg_tb_size < 0) {
- tcg_tb_size = 0;
+ if (!tcg_enabled()) {
+ error_report("TCG is disabled");
+ exit(1);
+ }
+ if (qemu_strtoul(optarg, NULL, 0, &tcg_tb_size) < 0) {
+ error_report("Invalid argument to -tb-size");
+ exit(1);
}
break;
case QEMU_OPTION_icount:
}
incoming = optarg;
break;
+ case QEMU_OPTION_only_migratable:
+ /*
+ * TODO: we can remove this option one day, and we
+ * should all use:
+ *
+ * "-global migration.only-migratable=true"
+ */
+ qemu_global_option("migration.only-migratable=true");
+ break;
case QEMU_OPTION_nodefaults:
has_defaults = 0;
break;
}
xen_mode = XEN_ATTACH;
break;
+ case QEMU_OPTION_xen_domid_restrict:
+ if (!(xen_available())) {
+ error_report("Option not supported for this target");
+ exit(1);
+ }
+ xen_domid_restrict = true;
+ break;
case QEMU_OPTION_trace:
g_free(trace_file);
trace_file = trace_opt_parse(optarg);
os_daemonize();
+ if (pid_file && qemu_create_pidfile(pid_file) != 0) {
+ error_report("could not acquire pid file: %s", strerror(errno));
+ exit(1);
+ }
+
if (qemu_init_main_loop(&main_loop_err)) {
error_report_err(main_loop_err);
exit(1);
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");
}
#endif
- if (pid_file && qemu_create_pidfile(pid_file) != 0) {
- error_report("could not acquire pid file: %s", strerror(errno));
- exit(1);
- }
-
if (qemu_opts_foreach(qemu_find_opts("device"),
device_help_func, NULL, NULL)) {
exit(0);
configure_accelerator(current_machine);
+ /*
+ * Register all the global properties, including accel properties,
+ * machine properties, and user-specified ones.
+ */
+ register_global_properties(current_machine);
+
+ /*
+ * Migration object can only be created after global properties
+ * are applied correctly.
+ */
+ migration_object_init();
+
if (qtest_chrdev) {
qtest_init(qtest_chrdev, qtest_log, &error_fatal);
}
cpu_ticks_init();
if (icount_opts) {
- if (kvm_enabled() || xen_enabled()) {
- error_report("-icount is not allowed with kvm or xen");
+ if (!tcg_enabled()) {
+ error_report("-icount is not allowed with hardware virtualization");
exit(1);
}
configure_icount(icount_opts, &error_abort);
qemu_opts_del(icount_opts);
}
+ if (tcg_enabled()) {
+ 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);
}
/* 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);
default_drive(default_floppy, snapshot, IF_FLOPPY, 0, FD_OPTS);
default_drive(default_sdcard, snapshot, IF_SD, 0, SD_OPTS);
- parse_numa_opts(machine_class);
+ parse_numa_opts(current_machine);
if (qemu_opts_foreach(qemu_find_opts("mon"),
mon_init_func, NULL, NULL)) {
exit (i == 1 ? 1 : 0);
}
- machine_register_compat_props(current_machine);
-
- qemu_opts_foreach(qemu_find_opts("global"),
- global_init_func, NULL, NULL);
-
/* This checkpoint is required by replay to separate prior clock
reading from the other reads, because timer polling functions query
clock values from the log. */
current_machine->boot_order = boot_order;
current_machine->cpu_model = cpu_model;
- machine_class->init(current_machine);
+ machine_run_board_init(current_machine);
realtime_init();
- audio_init();
+ soundhw_init();
- cpu_synchronize_all_post_init();
-
- numa_post_machine_init();
+ if (hax_enabled()) {
+ hax_sync_vcpus();
+ }
if (qemu_opts_foreach(qemu_find_opts("fw_cfg"),
parse_fw_cfg, fw_cfg_find(), NULL) != 0) {
device_init_func, NULL, NULL)) {
exit(1);
}
+
+ cpu_synchronize_all_post_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();
qemu_spice_display_init();
}
+#ifdef CONFIG_OPENGL_DMABUF
+ if (display_type == DT_EGL) {
+ egl_headless_init();
+ }
+#endif
+
if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) {
exit(1);
}
reading from the other reads, because timer polling functions query
clock values from the log. */
replay_checkpoint(CHECKPOINT_RESET);
- qemu_system_reset(VMRESET_SILENT);
+ qemu_system_reset(SHUTDOWN_CAUSE_NONE);
register_global_state();
- if (loadvm) {
- if (load_vmstate(loadvm) < 0) {
+ if (replay_mode != REPLAY_MODE_NONE) {
+ replay_vmstate_init();
+ } else if (loadvm) {
+ Error *local_err = NULL;
+ if (load_snapshot(loadvm, &local_err) < 0) {
+ error_report_err(local_err);
autostart = 0;
}
}
audio_cleanup();
monitor_cleanup();
qemu_chr_cleanup();
+ /* TODO: unref root container, check all devices are ok */
return 0;
}