#include "monitor/monitor.h"
#include "ui/console.h"
#include "sysemu/sysemu.h"
+#include "sysemu/numa.h"
#include "exec/gdbstub.h"
#include "qemu/timer.h"
#include "sysemu/char.h"
const char *bios_name = NULL;
enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
DisplayType display_type = DT_DEFAULT;
+int request_opengl = -1;
+int display_opengl;
static int display_remote;
const char* keyboard_layout = NULL;
ram_addr_t ram_size;
int max_cpus = 0;
int smp_cores = 1;
int smp_threads = 1;
-#ifdef CONFIG_VNC
-const char *vnc_display;
-#endif
int acpi_enabled = 1;
int no_hpet = 0;
int fd_bootchk = 1;
int icount_align_option;
-int nb_numa_nodes;
-int max_numa_nodeid;
-NodeInfo numa_info[MAX_NODES];
-
/* The bytes in qemu_uuid[] are in the order specified by RFC4122, _not_ in the
* little-endian "wire format" described in the SMBIOS 2.6 specification.
*/
/***********************************************************/
/* real time host monotonic timer */
+static time_t qemu_time(void)
+{
+ return qemu_clock_get_ms(QEMU_CLOCK_HOST) / 1000;
+}
+
/***********************************************************/
/* host time/date access */
void qemu_get_timedate(struct tm *tm, int offset)
{
- time_t ti;
+ time_t ti = qemu_time();
- time(&ti);
ti += offset;
if (rtc_date_offset == -1) {
if (rtc_utc)
else
seconds = mktimegm(tm) + rtc_date_offset;
- return seconds - time(NULL);
+ return seconds - qemu_time();
}
static void configure_rtc_date_offset(const char *startdate, int legacy)
"'2006-06-17T16:01:21' or '2006-06-17'\n");
exit(1);
}
- rtc_date_offset = time(NULL) - rtc_start_date;
+ rtc_date_offset = qemu_time() - rtc_start_date;
}
}
int fd, dupfd, flags;
int64_t fdset_id;
const char *fd_opaque = NULL;
+ AddfdInfo *fdinfo;
fd = qemu_opt_get_number(opts, "fd", -1);
fdset_id = qemu_opt_get_number(opts, "set", -1);
}
/* add the duplicate fd, and optionally the opaque string, to the fd set */
- monitor_fdset_add_fd(dupfd, true, fdset_id, fd_opaque ? true : false,
- fd_opaque, NULL);
+ fdinfo = monitor_fdset_add_fd(dupfd, true, fdset_id, !!fd_opaque, fd_opaque,
+ &error_abort);
+ g_free(fdinfo);
return 0;
}
static int drive_enable_snapshot(QemuOpts *opts, void *opaque)
{
if (qemu_opt_get(opts, "snapshot") == NULL) {
- qemu_opt_set(opts, "snapshot", "on");
+ qemu_opt_set(opts, "snapshot", "on", &error_abort);
}
return 0;
}
if (cpus == 0) {
cpus = cores * threads * sockets;
}
- } else {
- if (cores == 0) {
- threads = threads > 0 ? threads : 1;
- cores = cpus / (sockets * threads);
- } else {
- threads = cpus / (cores * sockets);
- }
+ } else if (cores == 0) {
+ threads = threads > 0 ? threads : 1;
+ cores = cpus / (sockets * threads);
+ } else if (threads == 0) {
+ threads = cpus / (cores * sockets);
+ } else if (sockets * cores * threads < cpus) {
+ fprintf(stderr, "cpu topology: error: "
+ "sockets (%u) * cores (%u) * threads (%u) < "
+ "smp_cpus (%u)\n",
+ sockets, cores, threads, cpus);
+ exit(1);
}
max_cpus = qemu_opt_get_number(opts, "maxcpus", 0);
return r;
}
-void do_usb_add(Monitor *mon, const QDict *qdict)
+void hmp_usb_add(Monitor *mon, const QDict *qdict)
{
const char *devname = qdict_get_str(qdict, "devname");
if (usb_device_add(devname) < 0) {
}
}
-void do_usb_del(Monitor *mon, const QDict *qdict)
+void hmp_usb_del(Monitor *mon, const QDict *qdict)
{
const char *devname = qdict_get_str(qdict, "devname");
if (usb_device_del(devname) < 0) {
} else {
goto invalid_sdl_args;
}
+ } else if (strstart(opts, ",gl=", &nextopt)) {
+ opts = nextopt;
+ if (strstart(opts, "on", &nextopt)) {
+ request_opengl = 1;
+ } else if (strstart(opts, "off", &nextopt)) {
+ request_opengl = 0;
+ } else {
+ goto invalid_sdl_args;
+ }
} else {
invalid_sdl_args:
fprintf(stderr, "Invalid SDL option string: %s\n", p);
#endif
} else if (strstart(p, "vnc", &opts)) {
#ifdef CONFIG_VNC
- display_remote++;
-
- if (*opts) {
- const char *nextopt;
-
- if (strstart(opts, "=", &nextopt)) {
- vnc_display = nextopt;
+ if (*opts == '=') {
+ if (vnc_parse_func(opts+1) == NULL) {
+ exit(1);
}
- }
- if (!vnc_display) {
+ } else {
fprintf(stderr, "VNC requires a display argument vnc=<display>\n");
exit(1);
}
opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0,
&error_abort);
}
- qemu_opt_set(opts, "driver", "virtio-balloon");
+ qemu_opt_set(opts, "driver", "virtio-balloon", &error_abort);
return 0;
}
qemu_chr_new_from_opts(opts, NULL, &local_err);
if (local_err) {
- error_report("%s", error_get_pretty(local_err));
- error_free(local_err);
+ error_report_err(local_err);
return -1;
}
return 0;
static void monitor_parse(const char *optarg, const char *mode, bool pretty)
{
static int monitor_device_index = 0;
+ Error *local_err = NULL;
QemuOpts *opts;
const char *p;
char label[32];
}
}
- opts = qemu_opts_create(qemu_find_opts("mon"), label, 1, NULL);
+ opts = qemu_opts_create(qemu_find_opts("mon"), label, 1, &local_err);
if (!opts) {
- fprintf(stderr, "duplicate chardev: %s\n", label);
+ error_report_err(local_err);
exit(1);
}
- qemu_opt_set(opts, "mode", mode);
- qemu_opt_set(opts, "chardev", label);
- qemu_opt_set_bool(opts, "pretty", pretty);
+ qemu_opt_set(opts, "mode", mode, &error_abort);
+ qemu_opt_set(opts, "chardev", label, &error_abort);
+ qemu_opt_set_bool(opts, "pretty", pretty, &error_abort);
if (def)
- qemu_opt_set(opts, "default", "on");
+ qemu_opt_set(opts, "default", "on", &error_abort);
monitor_device_index++;
}
bus_opts = qemu_opts_create(device, NULL, 0, &error_abort);
if (arch_type == QEMU_ARCH_S390X) {
- qemu_opt_set(bus_opts, "driver", "virtio-serial-s390");
+ qemu_opt_set(bus_opts, "driver", "virtio-serial-s390", &error_abort);
} else {
- qemu_opt_set(bus_opts, "driver", "virtio-serial-pci");
+ qemu_opt_set(bus_opts, "driver", "virtio-serial-pci", &error_abort);
}
dev_opts = qemu_opts_create(device, NULL, 0, &error_abort);
- qemu_opt_set(dev_opts, "driver", "virtconsole");
+ qemu_opt_set(dev_opts, "driver", "virtconsole", &error_abort);
snprintf(label, sizeof(label), "virtcon%d", index);
virtcon_hds[index] = qemu_chr_new(label, devname, NULL);
" to character backend '%s'\n", devname);
return -1;
}
- qemu_opt_set(dev_opts, "chardev", label);
+ qemu_opt_set(dev_opts, "chardev", label, &error_abort);
index++;
return 0;
assert(arch_type == QEMU_ARCH_S390X);
dev_opts = qemu_opts_create(device, NULL, 0, NULL);
- qemu_opt_set(dev_opts, "driver", "sclpconsole");
+ qemu_opt_set(dev_opts, "driver", "sclpconsole", &error_abort);
snprintf(label, sizeof(label), "sclpcon%d", index);
sclp_hds[index] = qemu_chr_new(label, devname, NULL);
" to character backend '%s'\n", devname);
return -1;
}
- qemu_opt_set(dev_opts, "chardev", label);
+ qemu_opt_set(dev_opts, "chardev", label, &error_abort);
index++;
return 0;
fprintf(stderr, "qemu: already have a debugcon device\n");
exit(1);
}
- qemu_opt_set(opts, "driver", "isa-debugcon");
- qemu_opt_set(opts, "chardev", "debugcon");
+ qemu_opt_set(opts, "driver", "isa-debugcon", &error_abort);
+ qemu_opt_set(opts, "chardev", "debugcon", &error_abort);
return 0;
}
mc = find_machine(name);
}
if (mc) {
+ g_slist_free(machines);
return mc;
}
if (name && !is_help_option(name)) {
g_free(qom_name);
if (local_err) {
- qerror_report_err(local_err);
- error_free(local_err);
+ error_report_err(local_err);
return -1;
}
g_free(type);
g_free(dummy);
if (err) {
- qerror_report_err(err);
- error_free(err);
+ error_report_err(err);
return -1;
}
return 0;
}
+static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size)
+{
+ uint64_t sz;
+ const char *mem_str;
+ const char *maxmem_str, *slots_str;
+ const ram_addr_t default_ram_size = (ram_addr_t)DEFAULT_RAM_SIZE *
+ 1024 * 1024;
+ QemuOpts *opts = qemu_find_opts_singleton("memory");
+
+ sz = 0;
+ mem_str = qemu_opt_get(opts, "size");
+ if (mem_str) {
+ if (!*mem_str) {
+ error_report("missing 'size' option value");
+ exit(EXIT_FAILURE);
+ }
+
+ sz = qemu_opt_get_size(opts, "size", ram_size);
+
+ /* Fix up legacy suffix-less format */
+ if (g_ascii_isdigit(mem_str[strlen(mem_str) - 1])) {
+ uint64_t overflow_check = sz;
+
+ sz <<= 20;
+ if ((sz >> 20) != overflow_check) {
+ error_report("too large 'size' option value");
+ exit(EXIT_FAILURE);
+ }
+ }
+ }
+
+ /* backward compatibility behaviour for case "-m 0" */
+ if (sz == 0) {
+ sz = default_ram_size;
+ }
+
+ sz = QEMU_ALIGN_UP(sz, 8192);
+ ram_size = sz;
+ if (ram_size != sz) {
+ error_report("ram size too large");
+ exit(EXIT_FAILURE);
+ }
+
+ /* store value for the future use */
+ 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) {
+ uint64_t slots;
+
+ sz = qemu_opt_get_size(opts, "maxmem", 0);
+ slots = qemu_opt_get_number(opts, "slots", 0);
+ if (sz < ram_size) {
+ error_report("invalid value of -m option maxmem: "
+ "maximum memory size (0x%" PRIx64 ") must be at least "
+ "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) {
+ 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 "
+ "(0x" RAM_ADDR_FMT ")", sz, ram_size);
+ exit(EXIT_FAILURE);
+ }
+
+ *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");
+ exit(EXIT_FAILURE);
+ }
+}
+
int main(int argc, char **argv, char **envp)
{
int i;
int snapshot, linux_boot;
const char *initrd_filename;
const char *kernel_filename, *kernel_cmdline;
- const char *boot_order;
+ const char *boot_order = NULL;
+ const char *boot_once = NULL;
DisplayState *ds;
int cyls, heads, secs, translation;
QemuOpts *hda_opts = NULL, *opts, *machine_opts, *icount_opts = NULL;
};
const char *trace_events = NULL;
const char *trace_file = NULL;
- const ram_addr_t default_ram_size = (ram_addr_t)DEFAULT_RAM_SIZE *
- 1024 * 1024;
- ram_addr_t maxram_size = default_ram_size;
+ ram_addr_t maxram_size;
uint64_t ram_slots = 0;
FILE *vmstate_dump_file = NULL;
Error *main_loop_err = NULL;
+ qemu_init_cpu_loop();
+ qemu_mutex_lock_iothread();
+
atexit(qemu_run_exit_notifiers);
error_set_progname(argv[0]);
qemu_init_exec_dir(argv[0]);
module_call_init(MODULE_INIT_MACHINE);
machine_class = find_default_machine();
cpu_model = NULL;
- ram_size = default_ram_size;
snapshot = 0;
cyls = heads = secs = 0;
translation = BIOS_ATA_TRANSLATION_AUTO;
- for (i = 0; i < MAX_NODES; i++) {
- numa_info[i].node_mem = 0;
- numa_info[i].present = false;
- bitmap_zero(numa_info[i].node_cpu, MAX_CPUMASK_BITS);
- }
-
- nb_numa_nodes = 0;
- max_numa_nodeid = 0;
nb_nics = 0;
bdrv_init_with_whitelist();
if (optind >= argc)
break;
if (argv[optind][0] != '-') {
- hda_opts = drive_add(IF_DEFAULT, 0, argv[optind++], HD_OPTS);
+ hda_opts = drive_add(IF_DEFAULT, 0, argv[optind++], HD_OPTS);
} else {
const QEMUOption *popt;
exit(1);
}
switch(popt->index) {
- case QEMU_OPTION_M:
- machine_class = machine_parse(optarg);
- break;
case QEMU_OPTION_no_kvm_irqchip: {
olist = qemu_find_opts("machine");
qemu_opts_parse(olist, "kernel_irqchip=off", 0);
if (drive_def(optarg) == NULL) {
exit(1);
}
- break;
+ break;
case QEMU_OPTION_set:
if (qemu_set_option(optarg) != 0)
exit(1);
- break;
+ break;
case QEMU_OPTION_global:
if (qemu_global_option(optarg) != 0)
exit(1);
- break;
+ break;
case QEMU_OPTION_mtdblock:
drive_add(IF_MTD, -1, optarg, MTD_OPTS);
break;
fprintf(stderr, "qemu: invalid physical CHS format\n");
exit(1);
}
- if (hda_opts != NULL) {
- char num[16];
- snprintf(num, sizeof(num), "%d", cyls);
- qemu_opt_set(hda_opts, "cyls", num);
- snprintf(num, sizeof(num), "%d", heads);
- qemu_opt_set(hda_opts, "heads", num);
- snprintf(num, sizeof(num), "%d", secs);
- qemu_opt_set(hda_opts, "secs", num);
+ 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");
+ qemu_opt_set(hda_opts, "trans", "large",
+ &error_abort);
} else if (translation == BIOS_ATA_TRANSLATION_RECHS) {
- qemu_opt_set(hda_opts, "trans", "rechs");
+ qemu_opt_set(hda_opts, "trans", "rechs",
+ &error_abort);
} else if (translation == BIOS_ATA_TRANSLATION_LBA) {
- qemu_opt_set(hda_opts, "trans", "lba");
+ qemu_opt_set(hda_opts, "trans", "lba",
+ &error_abort);
} else if (translation == BIOS_ATA_TRANSLATION_NONE) {
- qemu_opt_set(hda_opts, "trans", "none");
+ qemu_opt_set(hda_opts, "trans", "none",
+ &error_abort);
}
}
}
}
break;
case QEMU_OPTION_kernel:
- qemu_opts_set(qemu_find_opts("machine"), 0, "kernel", optarg);
+ qemu_opts_set(qemu_find_opts("machine"), 0, "kernel", optarg,
+ &error_abort);
break;
case QEMU_OPTION_initrd:
- qemu_opts_set(qemu_find_opts("machine"), 0, "initrd", optarg);
+ qemu_opts_set(qemu_find_opts("machine"), 0, "initrd", optarg,
+ &error_abort);
break;
case QEMU_OPTION_append:
- qemu_opts_set(qemu_find_opts("machine"), 0, "append", optarg);
+ qemu_opts_set(qemu_find_opts("machine"), 0, "append", optarg,
+ &error_abort);
break;
case QEMU_OPTION_dtb:
- qemu_opts_set(qemu_find_opts("machine"), 0, "dtb", optarg);
+ qemu_opts_set(qemu_find_opts("machine"), 0, "dtb", optarg,
+ &error_abort);
break;
case QEMU_OPTION_cdrom:
drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS);
version();
exit(0);
break;
- case QEMU_OPTION_m: {
- uint64_t sz;
- const char *mem_str;
- const char *maxmem_str, *slots_str;
-
+ case QEMU_OPTION_m:
opts = qemu_opts_parse(qemu_find_opts("memory"),
optarg, 1);
if (!opts) {
exit(EXIT_FAILURE);
}
-
- mem_str = qemu_opt_get(opts, "size");
- if (!mem_str) {
- error_report("invalid -m option, missing 'size' option");
- exit(EXIT_FAILURE);
- }
- if (!*mem_str) {
- error_report("missing 'size' option value");
- exit(EXIT_FAILURE);
- }
-
- sz = qemu_opt_get_size(opts, "size", ram_size);
-
- /* Fix up legacy suffix-less format */
- if (g_ascii_isdigit(mem_str[strlen(mem_str) - 1])) {
- uint64_t overflow_check = sz;
-
- sz <<= 20;
- if ((sz >> 20) != overflow_check) {
- error_report("too large 'size' option value");
- exit(EXIT_FAILURE);
- }
- }
-
- /* backward compatibility behaviour for case "-m 0" */
- if (sz == 0) {
- sz = default_ram_size;
- }
-
- sz = QEMU_ALIGN_UP(sz, 8192);
- ram_size = sz;
- if (ram_size != sz) {
- error_report("ram size too large");
- exit(EXIT_FAILURE);
- }
- maxram_size = ram_size;
-
- maxmem_str = qemu_opt_get(opts, "maxmem");
- slots_str = qemu_opt_get(opts, "slots");
- if (maxmem_str && slots_str) {
- uint64_t slots;
-
- sz = qemu_opt_get_size(opts, "maxmem", 0);
- if (sz < ram_size) {
- error_report("invalid -m option value: maxmem "
- "(0x%" PRIx64 ") <= initial memory (0x"
- RAM_ADDR_FMT ")", sz, ram_size);
- exit(EXIT_FAILURE);
- }
-
- slots = qemu_opt_get_number(opts, "slots", 0);
- if ((sz > ram_size) && !slots) {
- error_report("invalid -m option value: maxmem "
- "(0x%" PRIx64 ") more than initial memory (0x"
- RAM_ADDR_FMT ") but no hotplug slots where "
- "specified", sz, ram_size);
- exit(EXIT_FAILURE);
- }
-
- if ((sz <= ram_size) && slots) {
- error_report("invalid -m option value: %"
- PRIu64 " hotplug slots where specified but "
- "maxmem (0x%" PRIx64 ") <= initial memory (0x"
- RAM_ADDR_FMT ")", slots, sz, ram_size);
- exit(EXIT_FAILURE);
- }
- 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");
- exit(EXIT_FAILURE);
- }
break;
- }
#ifdef CONFIG_TPM
case QEMU_OPTION_tpmdev:
if (tpm_config_parse(qemu_find_opts("tpmdev"), optarg) < 0) {
}
break;
case QEMU_OPTION_bios:
- qemu_opts_set(qemu_find_opts("machine"), 0, "firmware", optarg);
+ qemu_opts_set(qemu_find_opts("machine"), 0, "firmware", optarg,
+ &error_abort);
break;
case QEMU_OPTION_singlestep:
singlestep = 1;
case QEMU_OPTION_S:
autostart = 0;
break;
- case QEMU_OPTION_k:
- keyboard_layout = optarg;
- break;
+ case QEMU_OPTION_k:
+ keyboard_layout = optarg;
+ break;
case QEMU_OPTION_localtime:
rtc_utc = 0;
break;
writeout = qemu_opt_get(opts, "writeout");
if (writeout) {
#ifdef CONFIG_SYNC_FILE_RANGE
- qemu_opt_set(fsdev, "writeout", writeout);
+ qemu_opt_set(fsdev, "writeout", writeout, &error_abort);
#else
fprintf(stderr, "writeout=immediate not supported on "
"this platform\n");
exit(1);
#endif
}
- qemu_opt_set(fsdev, "fsdriver", qemu_opt_get(opts, "fsdriver"));
- qemu_opt_set(fsdev, "path", qemu_opt_get(opts, "path"));
+ qemu_opt_set(fsdev, "fsdriver",
+ qemu_opt_get(opts, "fsdriver"), &error_abort);
+ qemu_opt_set(fsdev, "path", qemu_opt_get(opts, "path"),
+ &error_abort);
qemu_opt_set(fsdev, "security_model",
- qemu_opt_get(opts, "security_model"));
+ qemu_opt_get(opts, "security_model"),
+ &error_abort);
socket = qemu_opt_get(opts, "socket");
if (socket) {
- qemu_opt_set(fsdev, "socket", socket);
+ qemu_opt_set(fsdev, "socket", socket, &error_abort);
}
sock_fd = qemu_opt_get(opts, "sock_fd");
if (sock_fd) {
- qemu_opt_set(fsdev, "sock_fd", sock_fd);
+ qemu_opt_set(fsdev, "sock_fd", sock_fd, &error_abort);
}
qemu_opt_set_bool(fsdev, "readonly",
- qemu_opt_get_bool(opts, "readonly", 0));
+ qemu_opt_get_bool(opts, "readonly", 0),
+ &error_abort);
device = qemu_opts_create(qemu_find_opts("device"), NULL, 0,
&error_abort);
- qemu_opt_set(device, "driver", "virtio-9p-pci");
+ qemu_opt_set(device, "driver", "virtio-9p-pci", &error_abort);
qemu_opt_set(device, "fsdev",
- qemu_opt_get(opts, "mount_tag"));
+ qemu_opt_get(opts, "mount_tag"), &error_abort);
qemu_opt_set(device, "mount_tag",
- qemu_opt_get(opts, "mount_tag"));
+ qemu_opt_get(opts, "mount_tag"), &error_abort);
break;
}
case QEMU_OPTION_virtfs_synth: {
fprintf(stderr, "duplicate option: %s\n", "virtfs_synth");
exit(1);
}
- qemu_opt_set(fsdev, "fsdriver", "synth");
+ qemu_opt_set(fsdev, "fsdriver", "synth", &error_abort);
device = qemu_opts_create(qemu_find_opts("device"), NULL, 0,
&error_abort);
- qemu_opt_set(device, "driver", "virtio-9p-pci");
- qemu_opt_set(device, "fsdev", "v_synth");
- qemu_opt_set(device, "mount_tag", "v_synth");
+ qemu_opt_set(device, "driver", "virtio-9p-pci", &error_abort);
+ qemu_opt_set(device, "fsdev", "v_synth", &error_abort);
+ qemu_opt_set(device, "mount_tag", "v_synth", &error_abort);
break;
}
case QEMU_OPTION_serial:
case QEMU_OPTION_debugcon:
add_device_config(DEV_DEBUGCON, optarg);
break;
- case QEMU_OPTION_loadvm:
- loadvm = optarg;
- break;
+ case QEMU_OPTION_loadvm:
+ loadvm = optarg;
+ break;
case QEMU_OPTION_full_screen:
full_screen = 1;
break;
olist = qemu_find_opts("machine");
qemu_opts_parse(olist, "accel=kvm", 0);
break;
+ case QEMU_OPTION_M:
case QEMU_OPTION_machine:
olist = qemu_find_opts("machine");
opts = qemu_opts_parse(olist, optarg, 1);
if (!opts) {
exit(1);
}
- optarg = qemu_opt_get(opts, "type");
- if (optarg) {
- machine_class = machine_parse(optarg);
- }
break;
case QEMU_OPTION_no_kvm:
olist = qemu_find_opts("machine");
exit(1);
}
break;
- case QEMU_OPTION_vnc:
+ case QEMU_OPTION_vnc:
#ifdef CONFIG_VNC
- display_remote++;
- vnc_display = optarg;
+ if (vnc_parse_func(optarg) == NULL) {
+ exit(1);
+ }
#else
fprintf(stderr, "VNC support is disabled\n");
exit(1);
}
qemu_uuid_set = true;
break;
- case QEMU_OPTION_option_rom:
- if (nb_option_roms >= MAX_OPTION_ROMS) {
- fprintf(stderr, "Too many option ROMs\n");
- exit(1);
- }
+ case QEMU_OPTION_option_rom:
+ if (nb_option_roms >= MAX_OPTION_ROMS) {
+ fprintf(stderr, "Too many option ROMs\n");
+ exit(1);
+ }
opts = qemu_opts_parse(qemu_find_opts("option-rom"), optarg, 1);
if (!opts) {
exit(1);
fprintf(stderr, "Option ROM file is not specified\n");
exit(1);
}
- nb_option_roms++;
- break;
+ nb_option_roms++;
+ break;
case QEMU_OPTION_semihosting:
semihosting_enabled = 1;
semihosting_target = SEMIHOSTING_TARGET_AUTO;
}
break;
case QEMU_OPTION_incoming:
+ if (!incoming) {
+ runstate_set(RUN_STATE_INMIGRATE);
+ }
incoming = optarg;
- runstate_set(RUN_STATE_INMIGRATE);
break;
case QEMU_OPTION_nodefaults:
has_defaults = 0;
}
}
}
+
+ opts = qemu_get_machine_opts();
+ optarg = qemu_opt_get(opts, "type");
+ if (optarg) {
+ machine_class = machine_parse(optarg);
+ }
+
+ set_memory_options(&ram_slots, &maxram_size);
+
loc_set_none();
os_daemonize();
if (qemu_init_main_loop(&main_loop_err)) {
- error_report("%s", error_get_pretty(main_loop_err));
+ error_report_err(main_loop_err);
exit(1);
}
smp_parse(qemu_opts_find(qemu_find_opts("smp-opts"), NULL));
machine_class->max_cpus = machine_class->max_cpus ?: 1; /* Default to UP */
- if (smp_cpus > machine_class->max_cpus) {
+ if (max_cpus > machine_class->max_cpus) {
fprintf(stderr, "Number of SMP cpus requested (%d), exceeds max cpus "
- "supported by machine `%s' (%d)\n", smp_cpus,
+ "supported by machine `%s' (%d)\n", max_cpus,
machine_class->name, machine_class->max_cpus);
exit(1);
}
}
}
+#if defined(CONFIG_VNC)
+ if (!QTAILQ_EMPTY(&(qemu_find_opts("vnc")->head))) {
+ display_remote++;
+ }
+#endif
if (display_type == DT_DEFAULT && !display_remote) {
#if defined(CONFIG_GTK)
display_type = DT_GTK;
#elif defined(CONFIG_SDL) || defined(CONFIG_COCOA)
display_type = DT_SDL;
#elif defined(CONFIG_VNC)
- vnc_display = "localhost:0,to=99";
+ vnc_parse_func("localhost:0,to=99,id=default");
show_vnc_port = 1;
#else
display_type = DT_NONE;
early_gtk_display_init();
}
#endif
+#if defined(CONFIG_SDL)
+ if (display_type == DT_SDL) {
+ sdl_display_early_init(request_opengl);
+ }
+#endif
+ if (request_opengl == 1 && display_opengl == 0) {
+#if defined(CONFIG_OPENGL)
+ fprintf(stderr, "OpenGL is not supported by the display.\n");
+#else
+ fprintf(stderr, "QEMU was built without opengl support.\n");
+#endif
+ exit(1);
+ }
socket_init();
exit(1);
}
- /* store value for the future use */
- qemu_opt_set_number(qemu_find_opts_singleton("memory"), "size", ram_size);
-
if (qemu_opts_foreach(qemu_find_opts("device"), device_help_func, NULL, 0)
!= 0) {
exit(0);
Error *local_err = NULL;
qtest_init(qtest_chrdev, qtest_log, &local_err);
if (local_err) {
- error_report("%s", error_get_pretty(local_err));
- error_free(local_err);
+ error_report_err(local_err);
exit(1);
}
}
kernel_cmdline = qemu_opt_get(machine_opts, "append");
bios_name = qemu_opt_get(machine_opts, "firmware");
- boot_order = machine_class->default_boot_order;
opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL);
if (opts) {
- char *normal_boot_order;
- const char *order, *once;
Error *local_err = NULL;
- order = qemu_opt_get(opts, "order");
- if (order) {
- validate_bootdevices(order, &local_err);
+ boot_order = qemu_opt_get(opts, "order");
+ if (boot_order) {
+ validate_bootdevices(boot_order, &local_err);
if (local_err) {
- error_report("%s", error_get_pretty(local_err));
+ error_report_err(local_err);
exit(1);
}
- boot_order = order;
}
- once = qemu_opt_get(opts, "once");
- if (once) {
- validate_bootdevices(once, &local_err);
+ boot_once = qemu_opt_get(opts, "once");
+ if (boot_once) {
+ validate_bootdevices(boot_once, &local_err);
if (local_err) {
- error_report("%s", error_get_pretty(local_err));
+ error_report_err(local_err);
exit(1);
}
- normal_boot_order = g_strdup(boot_order);
- boot_order = once;
- qemu_register_reset(restore_boot_order, normal_boot_order);
}
boot_menu = qemu_opt_get_bool(opts, "menu", boot_menu);
boot_strict = qemu_opt_get_bool(opts, "strict", false);
}
+ if (!boot_order) {
+ boot_order = machine_class->default_boot_order;
+ }
+
if (!kernel_cmdline) {
kernel_cmdline = "";
current_machine->kernel_cmdline = (char *)kernel_cmdline;
os_set_line_buffering();
- qemu_init_cpu_loop();
- qemu_mutex_lock_iothread();
-
#ifdef CONFIG_SPICE
/* spice needs the timers to be initialized by this point */
qemu_spice_init();
default_drive(default_floppy, snapshot, IF_FLOPPY, 0, FD_OPTS);
default_drive(default_sdcard, snapshot, IF_SD, 0, SD_OPTS);
- if (qemu_opts_foreach(qemu_find_opts("numa"), numa_init_func,
- NULL, 1) != 0) {
- exit(1);
- }
-
- set_numa_nodes();
+ parse_numa_opts(machine_class);
if (qemu_opts_foreach(qemu_find_opts("mon"), mon_init_func, NULL, 1) != 0) {
exit(1);
cpu_synchronize_all_post_init();
- set_numa_modes();
+ numa_post_machine_init();
/* init USB devices */
if (usb_enabled()) {
net_check_clients();
+ if (boot_once) {
+ Error *local_err = NULL;
+ qemu_boot_set(boot_once, &local_err);
+ if (local_err) {
+ error_report("%s", error_get_pretty(local_err));
+ exit(1);
+ }
+ qemu_register_reset(restore_boot_order, g_strdup(boot_order));
+ }
+
ds = init_displaystate();
/* init local displays */
#ifdef CONFIG_VNC
/* init remote displays */
- if (vnc_display) {
- Error *local_err = NULL;
- vnc_display_init(ds);
- vnc_display_open(ds, vnc_display, &local_err);
- if (local_err != NULL) {
- error_report("Failed to start VNC server on `%s': %s",
- vnc_display, error_get_pretty(local_err));
- error_free(local_err);
- exit(1);
- }
-
- if (show_vnc_port) {
- printf("VNC server running on `%s'\n", vnc_display_local_addr(ds));
- }
+ qemu_opts_foreach(qemu_find_opts("vnc"), vnc_init_func, NULL, 0);
+ if (show_vnc_port) {
+ printf("VNC server running on `%s'\n",
+ vnc_display_local_addr("default"));
}
#endif
#ifdef CONFIG_SPICE