#include "audio/audio.h"
#include "sysemu/cpus.h"
#include "migration/colo.h"
+#include "migration/postcopy-ram.h"
#include "sysemu/kvm.h"
#include "sysemu/hax.h"
#include "qapi/qobject-input-visitor.h"
-#include "qapi-visit.h"
#include "qemu/option.h"
#include "qemu/config-file.h"
#include "qemu-options.h"
-#include "qmp-commands.h"
#include "qemu/main-loop.h"
#ifdef CONFIG_VIRTFS
#include "fsdev/qemu-fsdev.h"
#include "qapi/string-input-visitor.h"
#include "qapi/opts-visitor.h"
#include "qom/object_interfaces.h"
-#include "qapi-event.h"
#include "exec/semihost.h"
#include "crypto/init.h"
#include "sysemu/replay.h"
+#include "qapi/qapi-events-run-state.h"
+#include "qapi/qapi-visit-block-core.h"
+#include "qapi/qapi-commands-block-core.h"
+#include "qapi/qapi-commands-misc.h"
+#include "qapi/qapi-commands-run-state.h"
#include "qapi/qmp/qerror.h"
#include "sysemu/iothread.h"
#define MAX_VIRTIO_CONSOLES 1
-#define MAX_SCLP_CONSOLES 1
static const char *data_dir[16];
static int data_dir_idx;
int vga_interface_type = VGA_NONE;
static DisplayOptions dpy;
int no_frame;
-Chardev *serial_hds[MAX_SERIAL_PORTS];
+static int num_serial_hds = 0;
+static Chardev **serial_hds = NULL;
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;
static int default_serial = 1;
static int default_parallel = 1;
static int default_virtcon = 1;
-static int default_sclp = 1;
static int default_monitor = 1;
static int default_floppy = 1;
static int default_cdrom = 1;
static void version(void)
{
- printf("QEMU emulator version " QEMU_VERSION QEMU_PKGVERSION "\n"
+ printf("QEMU emulator version " QEMU_FULL_VERSION "\n"
QEMU_COPYRIGHT "\n");
}
opts = nextopt;
dpy.has_gl = true;
if (strstart(opts, "on", &nextopt)) {
- dpy.gl = true;
+ dpy.gl = DISPLAYGL_MODE_ON;
+ } else if (strstart(opts, "core", &nextopt)) {
+ dpy.gl = DISPLAYGL_MODE_CORE;
+ } else if (strstart(opts, "es", &nextopt)) {
+ dpy.gl = DISPLAYGL_MODE_ES;
} else if (strstart(opts, "off", &nextopt)) {
- dpy.gl = false;
+ dpy.gl = DISPLAYGL_MODE_OFF;
} else {
goto invalid_sdl_args;
}
exit(1);
}
} else if (strstart(p, "egl-headless", &opts)) {
-#ifdef CONFIG_OPENGL_DMABUF
- display_opengl = 1;
dpy.type = DISPLAY_TYPE_EGL_HEADLESS;
-#else
- error_report("egl support is disabled");
- exit(1);
-#endif
} else if (strstart(p, "curses", &opts)) {
dpy.type = DISPLAY_TYPE_CURSES;
} else if (strstart(p, "gtk", &opts)) {
opts = nextopt;
dpy.has_gl = true;
if (strstart(opts, "on", &nextopt)) {
- dpy.gl = true;
+ dpy.gl = DISPLAYGL_MODE_ON;
} else if (strstart(opts, "off", &nextopt)) {
- dpy.gl = false;
+ dpy.gl = DISPLAYGL_MODE_OFF;
} else {
goto invalid_gtk_args;
}
{
QemuOpts *opts;
+ warn_report("This option is deprecated. "
+ "Use '--device virtio-balloon' to enable the balloon device.");
+
if (strcmp(arg, "none") == 0) {
return 0;
}
if (qemu_opt_get_bool(opts, "pretty", 0))
flags |= MONITOR_USE_PRETTY;
+ /* OOB is off by default */
+ if (qemu_opt_get_bool(opts, "x-oob", 0)) {
+ flags |= MONITOR_USE_OOB;
+ }
+
chardev = qemu_opt_get(opts, "chardev");
chr = qemu_chr_find(chardev);
if (chr == NULL) {
static int serial_parse(const char *devname)
{
- static int index = 0;
+ int index = num_serial_hds;
char label[32];
if (strcmp(devname, "none") == 0)
return 0;
- if (index == MAX_SERIAL_PORTS) {
- error_report("too many serial ports");
- exit(1);
- }
snprintf(label, sizeof(label), "serial%d", index);
+ serial_hds = g_renew(Chardev *, serial_hds, index + 1);
+
serial_hds[index] = qemu_chr_new(label, devname);
if (!serial_hds[index]) {
error_report("could not connect serial device"
" to character backend '%s'", devname);
return -1;
}
- index++;
+ num_serial_hds++;
return 0;
}
+Chardev *serial_hd(int i)
+{
+ assert(i >= 0);
+ if (i < num_serial_hds) {
+ return serial_hds[i];
+ }
+ return NULL;
+}
+
+int serial_max_hds(void)
+{
+ return num_serial_hds;
+}
+
static int parallel_parse(const char *devname)
{
static int index = 0;
return 0;
}
-static int sclp_parse(const char *devname)
-{
- QemuOptsList *device = qemu_find_opts("device");
- static int index = 0;
- char label[32];
- QemuOpts *dev_opts;
-
- if (strcmp(devname, "none") == 0) {
- return 0;
- }
- if (index == MAX_SCLP_CONSOLES) {
- error_report("too many sclp consoles");
- exit(1);
- }
-
- assert(arch_type == QEMU_ARCH_S390X);
-
- dev_opts = qemu_opts_create(device, NULL, 0, NULL);
- qemu_opt_set(dev_opts, "driver", "sclpconsole", &error_abort);
-
- snprintf(label, sizeof(label), "sclpcon%d", index);
- sclp_hds[index] = qemu_chr_new(label, devname);
- if (!sclp_hds[index]) {
- error_report("could not connect sclp console"
- " to character backend '%s'", devname);
- return -1;
- }
- qemu_opt_set(dev_opts, "chardev", label, &error_abort);
-
- index++;
- return 0;
-}
-
static int debugcon_parse(const char *devname)
{
QemuOpts *opts;
notifier_list_notify(&exit_notifiers, NULL);
}
-static bool machine_init_done;
+bool machine_init_done;
void qemu_add_machine_init_done_notifier(Notifier *notify)
{
static void qemu_run_machine_init_done_notifiers(void)
{
- notifier_list_notify(&machine_init_done_notifiers, NULL);
machine_init_done = true;
+ notifier_list_notify(&machine_init_done_notifiers, NULL);
}
static const QEMUOption *lookup_opt(int argc, char **argv,
{
uint64_t sz;
const char *mem_str;
- const char *maxmem_str, *slots_str;
const ram_addr_t default_ram_size = mc->default_ram_size;
QemuOpts *opts = qemu_find_opts_singleton("memory");
Location loc;
qemu_opt_set_number(opts, "size", ram_size, &error_abort);
*maxram_size = ram_size;
- maxmem_str = qemu_opt_get(opts, "maxmem");
- slots_str = qemu_opt_get(opts, "slots");
- if (maxmem_str && slots_str) {
+ if (qemu_opt_get(opts, "maxmem")) {
uint64_t slots;
sz = qemu_opt_get_size(opts, "maxmem", 0);
"the initial memory size (0x" RAM_ADDR_FMT ")",
sz, ram_size);
exit(EXIT_FAILURE);
- } else if (sz > ram_size) {
- if (!slots) {
- error_report("invalid value of -m option: maxmem was "
- "specified, but no hotplug slots were specified");
- exit(EXIT_FAILURE);
- }
- } else if (slots) {
+ } else if (slots && sz == ram_size) {
error_report("invalid value of -m option maxmem: "
"memory slots were specified but maximum memory size "
"(0x%" PRIx64 ") is equal to the initial memory size "
*maxram_size = sz;
*ram_slots = slots;
- } else if ((!maxmem_str && slots_str) ||
- (maxmem_str && !slots_str)) {
- error_report("invalid -m option value: missing "
- "'%s' option", slots_str ? "maxmem" : "slots");
+ } else if (qemu_opt_get(opts, "slots")) {
+ error_report("invalid -m option value: missing 'maxmem' option");
exit(EXIT_FAILURE);
}
qemu_init_cpu_list();
qemu_init_cpu_loop();
+
qemu_mutex_lock_iothread();
atexit(qemu_run_exit_notifiers);
qemu_init_exec_dir(argv[0]);
module_call_init(MODULE_INIT_QOM);
- monitor_init_qmp_commands();
qemu_add_opts(&qemu_drive_opts);
qemu_add_drive_opts(&qemu_legacy_drive_opts);
qemu_add_opts(&qemu_chardev_opts);
qemu_add_opts(&qemu_device_opts);
qemu_add_opts(&qemu_netdev_opts);
+ qemu_add_opts(&qemu_nic_opts);
qemu_add_opts(&qemu_net_opts);
qemu_add_opts(&qemu_rtc_opts);
qemu_add_opts(&qemu_global_opts);
module_call_init(MODULE_INIT_OPTS);
runstate_init();
+ postcopy_infrastructure_init();
if (qcrypto_init(&err) < 0) {
error_reportf_err(err, "cannot initialize crypto: ");
exit(1);
}
break;
+ case QEMU_OPTION_nic:
+ default_net = 0;
+ if (net_client_parse(qemu_find_opts("nic"), optarg) == -1) {
+ exit(1);
+ }
+ break;
case QEMU_OPTION_net:
default_net = 0;
if (net_client_parse(qemu_find_opts("net"), optarg) == -1) {
break;
case QEMU_OPTION_localtime:
rtc_utc = 0;
+ warn_report("This option is deprecated, "
+ "use '-rtc base=localtime' instead.");
break;
case QEMU_OPTION_vga:
vga_model = optarg;
};
qdev_prop_register_global(&slew_lost_ticks);
+ warn_report("This option is deprecated, "
+ "use '-rtc driftfix=slew' instead.");
break;
}
case QEMU_OPTION_acpitable:
exit(1);
}
break;
- case QEMU_OPTION_tdf:
- warn_report("ignoring deprecated option");
- break;
case QEMU_OPTION_name:
opts = qemu_opts_parse_noisily(qemu_find_opts("name"),
optarg, true);
*/
break;
case QEMU_OPTION_startdate:
+ warn_report("This option is deprecated, use '-rtc base=' instead.");
configure_rtc_date_offset(optarg, 1);
break;
case QEMU_OPTION_rtc:
if (!has_defaults || !machine_class->use_virtcon) {
default_virtcon = 0;
}
- if (!has_defaults || !machine_class->use_sclp) {
- default_sclp = 0;
- }
if (!has_defaults || machine_class->no_floppy) {
default_floppy = 0;
}
add_device_config(DEV_SERIAL, "mon:stdio");
} else if (default_virtcon && default_monitor) {
add_device_config(DEV_VIRTCON, "mon:stdio");
- } else if (default_sclp && default_monitor) {
- add_device_config(DEV_SCLP, "mon:stdio");
} else {
if (default_serial)
add_device_config(DEV_SERIAL, "stdio");
if (default_virtcon)
add_device_config(DEV_VIRTCON, "stdio");
- if (default_sclp) {
- add_device_config(DEV_SCLP, "stdio");
- }
if (default_monitor)
monitor_parse("stdio", "readline", false);
}
monitor_parse("vc:80Cx24C", "readline", false);
if (default_virtcon)
add_device_config(DEV_VIRTCON, "vc:80Cx24C");
- if (default_sclp) {
- add_device_config(DEV_SCLP, "vc:80Cx24C");
- }
}
#if defined(CONFIG_VNC)
}
#endif
if (dpy.type == DISPLAY_TYPE_DEFAULT && !display_remote) {
-#if defined(CONFIG_GTK)
- dpy.type = DISPLAY_TYPE_GTK;
-#elif defined(CONFIG_SDL)
- dpy.type = DISPLAY_TYPE_SDL;
-#elif defined(CONFIG_COCOA)
- dpy.type = DISPLAY_TYPE_COCOA;
-#elif defined(CONFIG_VNC)
- vnc_parse("localhost:0,to=99,id=default", &error_abort);
-#else
- dpy.type = DISPLAY_TYPE_NONE;
+ if (!qemu_display_find_default(&dpy)) {
+ dpy.type = DISPLAY_TYPE_NONE;
+#if defined(CONFIG_VNC)
+ vnc_parse("localhost:0,to=99,id=default", &error_abort);
#endif
+ }
}
if (dpy.type == DISPLAY_TYPE_DEFAULT) {
dpy.type = DISPLAY_TYPE_NONE;
qemu_display_early_init(&dpy);
qemu_console_early_init();
- if (dpy.has_gl && dpy.gl && display_opengl == 0) {
+ if (dpy.has_gl && dpy.gl != DISPLAYGL_MODE_OFF && display_opengl == 0) {
#if defined(CONFIG_OPENGL)
error_report("OpenGL is not supported by the display");
#else
colo_info_init();
- if (net_init_clients() < 0) {
+ if (net_init_clients(&err) < 0) {
+ error_report_err(err);
exit(1);
}
blk_mig_init();
ram_mig_init();
+ dirty_bitmap_mig_init();
/* If the currently selected machine wishes to override the units-per-bus
* property of its default HBA interface type, do so now. */
default_drive(default_floppy, snapshot, IF_FLOPPY, 0, FD_OPTS);
default_drive(default_sdcard, snapshot, IF_SD, 0, SD_OPTS);
+ /*
+ * Note: qtest_enabled() (which is used in monitor_qapi_event_init())
+ * depends on configure_accelerator() above.
+ */
+ monitor_init_globals();
+
if (qemu_opts_foreach(qemu_find_opts("mon"),
mon_init_func, NULL, NULL)) {
exit(1);
exit(1);
if (foreach_device_config(DEV_VIRTCON, virtcon_parse) < 0)
exit(1);
- if (foreach_device_config(DEV_SCLP, sclp_parse) < 0) {
- exit(1);
- }
if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0)
exit(1);
current_machine->maxram_size = maxram_size;
current_machine->ram_slots = ram_slots;
current_machine->boot_order = boot_order;
- current_machine->cpu_model = cpu_model;
/* parse features once if machine provides default cpu_type */
- if (machine_class->default_cpu_type) {
- current_machine->cpu_type = machine_class->default_cpu_type;
- if (cpu_model) {
- current_machine->cpu_type =
- cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model);
- }
+ current_machine->cpu_type = machine_class->default_cpu_type;
+ if (cpu_model) {
+ current_machine->cpu_type = parse_cpu_model(cpu_model);
}
parse_numa_opts(current_machine);
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 (dpy.type == DISPLAY_TYPE_EGL_HEADLESS) {
- egl_headless_init(&dpy);
- }
-#endif
-
if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) {
exit(1);
}
vm_start();
}
+ accel_setup_post(current_machine);
os_setup_post();
main_loop();
- replay_disable_events();
-
- /* The ordering of the following is delicate. Stop vcpus to prevent new
- * I/O requests being queued by the guest. Then stop IOThreads (this
- * includes a drain operation and completes all request processing). At
- * this point emulated devices are still associated with their IOThreads
- * (if any) but no longer have any work to do. Only then can we close
- * block devices safely because we know there is no more I/O coming.
- */
- pause_all_vcpus();
- iothread_stop_all();
+
+ gdbserver_cleanup();
+
+ /* No more vcpu or device emulation activity beyond this point */
+ vm_shutdown();
+
bdrv_close_all();
res_free();