#ifdef CONFIG_VIRTFS
#include "fsdev/qemu-fsdev.h"
#endif
+#include "qtest.h"
#include "disas.h"
static int default_floppy = 1;
static int default_cdrom = 1;
static int default_sdcard = 1;
+static int default_vga = 1;
static struct {
const char *driver;
{ .driver = "virtio-serial-pci", .flag = &default_virtcon },
{ .driver = "virtio-serial-s390", .flag = &default_virtcon },
{ .driver = "virtio-serial", .flag = &default_virtcon },
+ { .driver = "VGA", .flag = &default_vga },
+ { .driver = "isa-vga", .flag = &default_vga },
+ { .driver = "cirrus-vga", .flag = &default_vga },
+ { .driver = "isa-cirrus-vga", .flag = &default_vga },
+ { .driver = "vmware-svga", .flag = &default_vga },
+ { .driver = "qxl-vga", .flag = &default_vga },
};
static void res_free(void)
{ RUN_STATE_SHUTDOWN, RUN_STATE_PAUSED },
{ RUN_STATE_SHUTDOWN, RUN_STATE_FINISH_MIGRATE },
+ { RUN_STATE_DEBUG, RUN_STATE_SUSPENDED },
+ { RUN_STATE_RUNNING, RUN_STATE_SUSPENDED },
+ { RUN_STATE_SUSPENDED, RUN_STATE_RUNNING },
+ { RUN_STATE_SUSPENDED, RUN_STATE_FINISH_MIGRATE },
+
{ RUN_STATE_WATCHDOG, RUN_STATE_RUNNING },
{ RUN_STATE_WATCHDOG, RUN_STATE_FINISH_MIGRATE },
if (value) {
if (!strcmp(value, "host")) {
rtc_clock = host_clock;
+ } else if (!strcmp(value, "rt")) {
+ rtc_clock = rt_clock;
} else if (!strcmp(value, "vm")) {
rtc_clock = vm_clock;
} else {
#ifndef CONFIG_LINUX
/* only the linux version is qdev-ified, usb-bsd still needs this */
if (strstart(devname, "host:", &p)) {
- dev = usb_host_device_open(p);
+ dev = usb_host_device_open(usb_bus_find(-1), p);
} else
#endif
if (!strcmp(devname, "bt") || strstart(devname, "bt:", &p)) {
- dev = usb_bt_init(devname[2] ? hci_init(p) :
- bt_new_hci(qemu_find_bt_vlan(0)));
+ dev = usb_bt_init(usb_bus_find(-1),
+ devname[2] ? hci_init(p)
+ : bt_new_hci(qemu_find_bt_vlan(0)));
} else {
return -1;
}
static int powerdown_requested;
static int debug_requested;
static int suspend_requested;
-static bool is_suspended;
static NotifierList suspend_notifiers =
NOTIFIER_LIST_INITIALIZER(suspend_notifiers);
static NotifierList wakeup_notifiers =
void qemu_kill_report(void)
{
- if (shutdown_signal != -1) {
+ if (!qtest_enabled() && shutdown_signal != -1) {
fprintf(stderr, "qemu: terminating on signal %d", shutdown_signal);
if (shutdown_pid == 0) {
/* This happens for eg ^C at the terminal, so it's worth
{
pause_all_vcpus();
notifier_list_notify(&suspend_notifiers, NULL);
+ runstate_set(RUN_STATE_SUSPENDED);
monitor_protocol_event(QEVENT_SUSPEND, NULL);
- is_suspended = true;
}
void qemu_system_suspend_request(void)
{
- if (is_suspended) {
+ if (runstate_check(RUN_STATE_SUSPENDED)) {
return;
}
suspend_requested = 1;
void qemu_system_wakeup_request(WakeupReason reason)
{
- if (!is_suspended) {
+ if (!runstate_check(RUN_STATE_SUSPENDED)) {
return;
}
if (!(wakeup_reason_mask & (1 << reason))) {
return;
}
+ runstate_set(RUN_STATE_RUNNING);
monitor_protocol_event(QEVENT_WAKEUP, NULL);
notifier_list_notify(&wakeup_notifiers, &reason);
reset_requested = 1;
qemu_notify_event();
- is_suspended = false;
}
void qemu_system_wakeup_enable(WakeupReason reason, bool enabled)
{ "tcg", "tcg", tcg_available, tcg_init, &tcg_allowed },
{ "xen", "Xen", xen_available, xen_init, &xen_allowed },
{ "kvm", "KVM", kvm_available, kvm_init, &kvm_allowed },
+ { "qtest", "QTest", qtest_available, qtest_init, &qtest_allowed },
};
static int configure_accelerator(void)
const char *loadvm = NULL;
QEMUMachine *machine;
const char *cpu_model;
- const char *vga_model = NULL;
+ const char *vga_model = "none";
const char *pid_file = NULL;
const char *incoming = NULL;
#ifdef CONFIG_VNC
int show_vnc_port = 0;
#endif
- int defconfig = 1;
+ bool defconfig = true;
+ bool userconfig = true;
const char *log_mask = NULL;
const char *log_file = NULL;
GMemVTable mem_trace = {
#endif
}
+ module_call_init(MODULE_INIT_QOM);
+
runstate_init();
init_clocks();
popt = lookup_opt(argc, argv, &optarg, &optind);
switch (popt->index) {
case QEMU_OPTION_nodefconfig:
- defconfig=0;
+ defconfig = false;
+ break;
+ case QEMU_OPTION_nouserconfig:
+ userconfig = false;
break;
}
}
if (defconfig) {
int ret;
-
- ret = qemu_read_config_file(CONFIG_QEMU_CONFDIR "/qemu.conf");
- if (ret < 0 && ret != -ENOENT) {
- exit(1);
- }
-
- ret = qemu_read_config_file(arch_config_name);
- if (ret < 0 && ret != -ENOENT) {
+ ret = qemu_read_default_config_files(userconfig);
+ if (ret < 0) {
exit(1);
}
}
- cpudef_init();
/* second pass of option parsing */
optind = 1;
break;
case QEMU_OPTION_cpu:
/* hw initialization will check this */
- if (*optarg == '?') {
- list_cpus(stdout, &fprintf, optarg);
- exit(0);
- } else {
- cpu_model = optarg;
- }
+ cpu_model = optarg;
break;
case QEMU_OPTION_hda:
{
case QEMU_OPTION_append:
qemu_opts_set(qemu_find_opts("machine"), 0, "append", optarg);
break;
+ case QEMU_OPTION_dtb:
+ qemu_opts_set(qemu_find_opts("machine"), 0, "dtb", optarg);
+ break;
case QEMU_OPTION_cdrom:
drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS);
break;
break;
case QEMU_OPTION_vga:
vga_model = optarg;
+ default_vga = 0;
break;
case QEMU_OPTION_g:
{
default_floppy = 0;
default_cdrom = 0;
default_sdcard = 0;
- vga_model = "none";
+ default_vga = 0;
break;
case QEMU_OPTION_xen_domid:
if (!(xen_available())) {
fclose(fp);
break;
}
+ case QEMU_OPTION_qtest:
+ qtest_chrdev = optarg;
+ break;
+ case QEMU_OPTION_qtest_log:
+ qtest_log = optarg;
+ break;
default:
os_parse_cmd_args(popt->index, optarg);
}
}
loc_set_none();
+ /* Init CPU def lists, based on config
+ * - Must be called after all the qemu_read_config_file() calls
+ * - Must be called before list_cpus()
+ * - Must be called before machine->init()
+ */
+ cpudef_init();
+
+ if (cpu_model && *cpu_model == '?') {
+ list_cpus(stdout, &fprintf, cpu_model);
+ exit(0);
+ }
+
/* Open the logfile at this point, if necessary. We can't open the logfile
* when encountering either of the logging options (-d or -D) because the
* other one may be encountered later on the command line, changing the
exit(1);
}
+ if (!linux_boot && machine_opts && qemu_opt_get(machine_opts, "dtb")) {
+ fprintf(stderr, "-dtb only allowed with -kernel option\n");
+ exit(1);
+ }
+
os_set_line_buffering();
if (init_timer_alarm() < 0) {
exit(1);
}
+#ifdef CONFIG_SPICE
+ /* spice needs the timers to be initialized by this point */
+ qemu_spice_init();
+#endif
+
if (icount_option && (kvm_enabled() || xen_enabled())) {
fprintf(stderr, "-icount is not allowed with kvm or xen\n");
exit(1);
if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0)
exit(1);
- module_call_init(MODULE_INIT_QOM);
-
- /* must be after qdev registration but before machine init */
- if (vga_model) {
- select_vgahw(vga_model);
- } else if (cirrus_vga_available()) {
- select_vgahw("cirrus");
- } else {
- select_vgahw("none");
+ /* If no default VGA is requested, the default is "none". */
+ if (default_vga && cirrus_vga_available()) {
+ vga_model = "cirrus";
}
+ select_vgahw(vga_model);
if (qemu_opts_foreach(qemu_find_opts("device"), device_help_func, NULL, 0) != 0)
exit(0);
}
if (incoming) {
- int ret = qemu_start_incoming_migration(incoming);
+ Error *errp = NULL;
+ int ret = qemu_start_incoming_migration(incoming, &errp);
if (ret < 0) {
+ if (error_is_set(&errp)) {
+ fprintf(stderr, "Migrate: %s\n", error_get_pretty(errp));
+ error_free(errp);
+ }
fprintf(stderr, "Migration failed. Exit code %s(%d), exiting.\n",
incoming, ret);
exit(ret);