#include "hw/boards.h"
#include "sysemu/accel.h"
#include "hw/usb.h"
-#include "hw/i386/pc.h"
#include "hw/isa/isa.h"
#include "hw/scsi/scsi.h"
+#include "hw/display/vga.h"
#include "hw/bt.h"
#include "sysemu/watchdog.h"
#include "hw/smbios/smbios.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"
QEMUClockType rtc_clock;
int vga_interface_type = VGA_NONE;
static int full_screen = 0;
-static int no_frame = 0;
+int no_frame;
int no_quit = 0;
static bool grab_on_hover;
Chardev *serial_hds[MAX_SERIAL_PORTS];
Chardev *sclp_hds[MAX_SCLP_CONSOLES];
int win2k_install_hack = 0;
int singlestep = 0;
-int smp_cpus = 1;
-int max_cpus = 1;
+int smp_cpus;
+unsigned int max_cpus;
int smp_cores = 1;
int smp_threads = 1;
int acpi_enabled = 1;
static int usb_device_add(const char *devname)
{
USBDevice *dev = NULL;
-#ifndef CONFIG_LINUX
- const char *p;
-#endif
if (!machine_usb(current_machine)) {
return -1;
}
- /* drivers with .usbdevice_name entry in USBDeviceInfo */
dev = usbdevice_create(devname);
- if (dev)
- goto done;
-
- /* the other ones */
-#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(usb_bus_find(-1), p);
- }
-#endif
if (!dev)
return -1;
-done:
return 0;
}
-static int usb_device_del(const char *devname)
-{
- int bus_num, addr;
- const char *p;
-
- if (strstart(devname, "host:", &p)) {
- return -1;
- }
-
- if (!machine_usb(current_machine)) {
- return -1;
- }
-
- p = strchr(devname, '.');
- if (!p)
- return -1;
- bus_num = strtoul(devname, NULL, 0);
- addr = strtoul(p + 1, NULL, 0);
-
- return usb_device_delete_addr(bus_num, addr);
-}
-
static int usb_parse(const char *cmdline)
{
int r;
return r;
}
-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);
- }
-}
-
/***********************************************************/
/* machine registration */
display_opengl = 1;
display = DT_EGL;
#else
- fprintf(stderr, "egl support is disabled\n");
+ error_report("egl support is disabled");
exit(1);
#endif
} else if (strstart(p, "curses", &opts)) {
return NULL;
}
+static void qemu_add_data_dir(const char *path)
+{
+ int i;
+
+ if (path == NULL) {
+ return;
+ }
+ if (data_dir_idx == ARRAY_SIZE(data_dir)) {
+ return;
+ }
+ for (i = 0; i < data_dir_idx; i++) {
+ if (strcmp(data_dir[i], path) == 0) {
+ return; /* duplicate */
+ }
+ }
+ data_dir[data_dir_idx++] = g_strdup(path);
+}
+
static inline bool nonempty_str(const char *str)
{
return str && *str;
const char *boot_order = NULL;
const char *boot_once = NULL;
DisplayState *ds;
- int cyls, heads, secs, translation;
QemuOpts *opts, *machine_opts;
- QemuOpts *hda_opts = NULL, *icount_opts = NULL, *accel_opts = NULL;
+ QemuOpts *icount_opts = NULL, *accel_opts = NULL;
QemuOptsList *olist;
int optind;
const char *optarg;
const char *qtest_log = NULL;
const char *pid_file = NULL;
const char *incoming = NULL;
- bool defconfig = true;
bool userconfig = true;
bool nographic = false;
DisplayType display_type = DT_DEFAULT;
Error *main_loop_err = NULL;
Error *err = NULL;
bool list_data_dirs = false;
+ char *dir, **dirs;
typedef struct BlockdevOptions_queue {
BlockdevOptions *bdo;
Location loc;
cpu_model = NULL;
snapshot = 0;
- cyls = heads = secs = 0;
- translation = BIOS_ATA_TRANSLATION_AUTO;
nb_nics = 0;
popt = lookup_opt(argc, argv, &optarg, &optind);
switch (popt->index) {
case QEMU_OPTION_nodefconfig:
- defconfig = false;
- break;
case QEMU_OPTION_nouserconfig:
userconfig = false;
break;
}
}
- if (defconfig && userconfig) {
+ if (userconfig) {
if (qemu_read_default_config_file() < 0) {
exit(1);
}
if (optind >= argc)
break;
if (argv[optind][0] != '-') {
- hda_opts = drive_add(IF_DEFAULT, 0, argv[optind++], HD_OPTS);
+ drive_add(IF_DEFAULT, 0, argv[optind++], HD_OPTS);
} else {
const QEMUOption *popt;
cpu_model = optarg;
break;
case QEMU_OPTION_hda:
- {
- char buf[256];
- if (cyls == 0)
- snprintf(buf, sizeof(buf), "%s", HD_OPTS);
- else
- snprintf(buf, sizeof(buf),
- "%s,cyls=%d,heads=%d,secs=%d%s",
- HD_OPTS , cyls, heads, secs,
- translation == BIOS_ATA_TRANSLATION_LBA ?
- ",trans=lba" :
- translation == BIOS_ATA_TRANSLATION_NONE ?
- ",trans=none" : "");
- drive_add(IF_DEFAULT, 0, optarg, buf);
- break;
- }
case QEMU_OPTION_hdb:
case QEMU_OPTION_hdc:
case QEMU_OPTION_hdd:
case QEMU_OPTION_snapshot:
snapshot = 1;
break;
- case QEMU_OPTION_hdachs:
- {
- const char *p;
- p = optarg;
- cyls = strtol(p, (char **)&p, 0);
- if (cyls < 1 || cyls > 16383)
- goto chs_fail;
- if (*p != ',')
- goto chs_fail;
- p++;
- heads = strtol(p, (char **)&p, 0);
- if (heads < 1 || heads > 16)
- goto chs_fail;
- if (*p != ',')
- goto chs_fail;
- p++;
- secs = strtol(p, (char **)&p, 0);
- if (secs < 1 || secs > 63)
- goto chs_fail;
- if (*p == ',') {
- p++;
- if (!strcmp(p, "large")) {
- translation = BIOS_ATA_TRANSLATION_LARGE;
- } else if (!strcmp(p, "rechs")) {
- translation = BIOS_ATA_TRANSLATION_RECHS;
- } else if (!strcmp(p, "none")) {
- translation = BIOS_ATA_TRANSLATION_NONE;
- } else if (!strcmp(p, "lba")) {
- translation = BIOS_ATA_TRANSLATION_LBA;
- } else if (!strcmp(p, "auto")) {
- translation = BIOS_ATA_TRANSLATION_AUTO;
- } else {
- goto chs_fail;
- }
- } else if (*p != '\0') {
- chs_fail:
- error_report("invalid physical CHS format");
- exit(1);
- }
- if (hda_opts != NULL) {
- qemu_opt_set_number(hda_opts, "cyls", cyls,
- &error_abort);
- qemu_opt_set_number(hda_opts, "heads", heads,
- &error_abort);
- qemu_opt_set_number(hda_opts, "secs", secs,
- &error_abort);
- if (translation == BIOS_ATA_TRANSLATION_LARGE) {
- qemu_opt_set(hda_opts, "trans", "large",
- &error_abort);
- } else if (translation == BIOS_ATA_TRANSLATION_RECHS) {
- qemu_opt_set(hda_opts, "trans", "rechs",
- &error_abort);
- } else if (translation == BIOS_ATA_TRANSLATION_LBA) {
- qemu_opt_set(hda_opts, "trans", "lba",
- &error_abort);
- } else if (translation == BIOS_ATA_TRANSLATION_NONE) {
- qemu_opt_set(hda_opts, "trans", "none",
- &error_abort);
- }
- }
- }
- 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"),
optarg, true);
case QEMU_OPTION_L:
if (is_help_option(optarg)) {
list_data_dirs = true;
- } else if (data_dir_idx < ARRAY_SIZE(data_dir)) {
- data_dir[data_dir_idx++] = optarg;
+ } else {
+ qemu_add_data_dir(optarg);
}
break;
case QEMU_OPTION_bios:
olist = qemu_find_opts("machine");
qemu_opts_parse_noisily(olist, "accel=tcg", false);
break;
- case QEMU_OPTION_no_kvm_pit: {
- warn_report("ignoring deprecated option");
- break;
- }
case QEMU_OPTION_no_kvm_pit_reinjection: {
static GlobalProperty kvm_pit_lost_tick_policy = {
.driver = "kvm-pit",
qemu_set_log(0);
}
- /* If no data_dir is specified then try to find it relative to the
- executable path. */
- if (data_dir_idx < ARRAY_SIZE(data_dir)) {
- data_dir[data_dir_idx] = os_find_datadir();
- if (data_dir[data_dir_idx] != NULL) {
- data_dir_idx++;
- }
- }
- /* If all else fails use the install path specified when building. */
- if (data_dir_idx < ARRAY_SIZE(data_dir)) {
- data_dir[data_dir_idx++] = CONFIG_QEMU_DATADIR;
+ /* add configured firmware directories */
+ dirs = g_strsplit(CONFIG_QEMU_FIRMWAREPATH, G_SEARCHPATH_SEPARATOR_S, 0);
+ for (i = 0; dirs[i] != NULL; i++) {
+ qemu_add_data_dir(dirs[i]);
}
+ g_strfreev(dirs);
+
+ /* try to find datadir relative to the executable path */
+ dir = os_find_datadir();
+ qemu_add_data_dir(dir);
+ g_free(dir);
+
+ /* add the datadir specified when building */
+ qemu_add_data_dir(CONFIG_QEMU_DATADIR);
/* -L help lists the data directories and exits. */
if (list_data_dirs) {
exit(0);
}
+ /* machine_class: default to UP */
+ machine_class->max_cpus = machine_class->max_cpus ?: 1;
+ machine_class->min_cpus = machine_class->min_cpus ?: 1;
+ machine_class->default_cpus = machine_class->default_cpus ?: 1;
+
+ /* default to machine_class->default_cpus */
+ smp_cpus = machine_class->default_cpus;
+ max_cpus = machine_class->default_cpus;
+
smp_parse(qemu_opts_find(qemu_find_opts("smp-opts"), NULL));
- machine_class->max_cpus = machine_class->max_cpus ?: 1; /* Default to UP */
+ /* sanity-check smp_cpus and max_cpus against machine_class */
+ if (smp_cpus < machine_class->min_cpus) {
+ error_report("Invalid SMP CPUs %d. The min CPUs "
+ "supported by machine '%s' is %d", smp_cpus,
+ machine_class->name, machine_class->min_cpus);
+ exit(1);
+ }
if (max_cpus > machine_class->max_cpus) {
- error_report("Number of SMP CPUs requested (%d) exceeds max CPUs "
- "supported by machine '%s' (%d)", max_cpus,
+ error_report("Invalid SMP CPUs %d. The max CPUs "
+ "supported by machine '%s' is %d", max_cpus,
machine_class->name, machine_class->max_cpus);
exit(1);
}
exit(1);
}
-#ifdef CONFIG_TPM
if (tpm_init() < 0) {
exit(1);
}
-#endif
/* init the bluetooth world */
if (foreach_device_config(DEV_BT, bt_parse))
default_drive(default_floppy, snapshot, IF_FLOPPY, 0, FD_OPTS);
default_drive(default_sdcard, snapshot, IF_SD, 0, SD_OPTS);
- parse_numa_opts(current_machine);
-
if (qemu_opts_foreach(qemu_find_opts("mon"),
mon_init_func, NULL, NULL)) {
exit(1);
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;
cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model);
}
}
+ parse_numa_opts(current_machine);
machine_run_board_init(current_machine);
curses_display_init(ds, full_screen);
break;
case DT_SDL:
- sdl_display_init(ds, full_screen, no_frame);
+ sdl_display_init(ds, full_screen);
break;
case DT_COCOA:
cocoa_display_init(ds, full_screen);
res_free();
/* vhost-user must be cleaned up before chardevs. */
+ tpm_cleanup();
net_cleanup();
audio_cleanup();
monitor_cleanup();
qemu_chr_cleanup();
user_creatable_cleanup();
+ migration_object_finalize();
/* TODO: unref root container, check all devices are ok */
return 0;