summaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorSeokYeon Hwang <syeon.hwang@samsung.com>2014-04-21 15:32:27 +0900
committerSeokYeon Hwang <syeon.hwang@samsung.com>2014-04-21 15:57:17 +0900
commitc38a355e67e966e447e3b58b897daffda70e2801 (patch)
tree3a90ebbaf8bf89014212325e374e5073f074b014 /vl.c
parent3d8e749baf4b053639581bc11e5664dc182e621d (diff)
parenta9e8aeb3755bccb7b51174adcf4a3fc427e0d147 (diff)
downloadqemu-c38a355e67e966e447e3b58b897daffda70e2801.tar.gz
qemu-c38a355e67e966e447e3b58b897daffda70e2801.tar.bz2
qemu-c38a355e67e966e447e3b58b897daffda70e2801.zip
Merge branch 'upstream_qemu_2.0' into tizen
Initial merge Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com> Conflicts: .gitignore Makefile.target block/raw-win32.c configure cpu-exec.c cpus.c hw/9pfs/virtio-9p-device.c hw/i386/pc_piix.c include/exec/cpu-defs.h include/qemu-common.h include/sysemu/sysemu.h include/ui/console.h tcg/i386/tcg-target.c tcg/tcg.h ui/console.c ui/input.c util/oslib-posix.c vl.c Change-Id: I52df9052942eea8d541bde75fd936e58a9f2f8ff
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c513
1 files changed, 326 insertions, 187 deletions
diff --git a/vl.c b/vl.c
index 6cf5fe3524..3d2af04e40 100644
--- a/vl.c
+++ b/vl.c
@@ -27,72 +27,17 @@
#include <time.h>
#include <errno.h>
#include <sys/time.h>
-#include <zlib.h>
-#include "qemu/bitmap.h"
-/* Needed early for CONFIG_BSD etc. */
#include "config-host.h"
-#ifndef _WIN32
-#include <libgen.h>
-#include <sys/times.h>
-#include <sys/wait.h>
-#include <termios.h>
-#include <sys/mman.h>
-#include <sys/ioctl.h>
-#include <sys/resource.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <net/if.h>
-#include <arpa/inet.h>
-#include <dirent.h>
-#include <netdb.h>
-#include <sys/select.h>
-
-#ifdef CONFIG_BSD
-#include <sys/stat.h>
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
-#include <sys/sysctl.h>
-#else
-#include <util.h>
-#endif
-#else
-#ifdef __linux__
-#include <malloc.h>
-
-#include <linux/ppdev.h>
-#include <linux/parport.h>
-#endif
-
#ifdef CONFIG_SECCOMP
#include "sysemu/seccomp.h"
#endif
-#ifdef __sun__
-#include <sys/stat.h>
-#include <sys/ethernet.h>
-#include <sys/sockio.h>
-#include <netinet/arp.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/ip_icmp.h> // must come after ip.h
-#include <netinet/udp.h>
-#include <netinet/tcp.h>
-#include <net/if.h>
-#include <syslog.h>
-#include <stropts.h>
-#endif
-#endif
-#endif
-
#if defined(CONFIG_VDE)
#include <libvdeplug.h>
#endif
-#ifdef _WIN32
-#include <windows.h>
-#endif
-
#ifdef CONFIG_SDL
#if defined(__APPLE__) || defined(main)
#include <SDL.h>
@@ -123,6 +68,7 @@ int qemu_main(int argc, char **argv, char **envp);
#include <glib.h>
+#include "qemu/sockets.h"
#include "hw/hw.h"
#include "hw/boards.h"
#include "hw/usb.h"
@@ -145,6 +91,7 @@ int qemu_main(int argc, char **argv, char **envp);
#include "exec/gdbstub.h"
#include "qemu/timer.h"
#include "sysemu/char.h"
+#include "qemu/bitmap.h"
#include "qemu/cache-utils.h"
#include "sysemu/blockdev.h"
#include "hw/block/block.h"
@@ -168,7 +115,6 @@ int qemu_main(int argc, char **argv, char **envp);
#include "disas/disas.h"
-#include "qemu/sockets.h"
#include "slirp/libslirp.h"
@@ -181,6 +127,7 @@ int qemu_main(int argc, char **argv, char **envp);
#include "ui/qemu-spice.h"
#include "qapi/string-input-visitor.h"
+#include "qom/object_interfaces.h"
#ifdef CONFIG_MARU
#include "tizen/src/maru_common.h"
@@ -192,9 +139,6 @@ int qemu_main(int argc, char **argv, char **envp);
#include "tizen/src/ecs/ecs.h"
#endif
-//#define DEBUG_NET
-//#define DEBUG_SLIRP
-
#define DEFAULT_RAM_SIZE 128
#define MAX_VIRTIO_CONSOLES 1
@@ -220,9 +164,7 @@ static int display_remote;
const char* keyboard_layout = NULL;
ram_addr_t ram_size;
const char *mem_path = NULL;
-#ifdef MAP_POPULATE
int mem_prealloc = 0; /* force preallocation of physical target memory */
-#endif
int nb_nics;
NICInfo nd_table[MAX_NICS];
int autostart;
@@ -233,6 +175,9 @@ int vga_interface_type = VGA_NONE;
static int full_screen = 0;
static int no_frame = 0;
int no_quit = 0;
+#ifdef CONFIG_GTK
+static bool grab_on_hover;
+#endif
CharDriverState *serial_hds[MAX_SERIAL_PORTS];
CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES];
@@ -264,7 +209,7 @@ int ctrl_grab = 0;
unsigned int nb_prom_envs = 0;
const char *prom_envs[MAX_PROM_ENVS];
int boot_menu;
-bool boot_strict;
+static bool boot_strict;
uint8_t *boot_splash_filedata;
size_t boot_splash_filedata_size;
uint8_t qemu_extra_params_fw[2];
@@ -306,6 +251,7 @@ uint32_t xen_domid;
enum xen_mode xen_mode = XEN_EMULATE;
static int tcg_tb_size;
+static int has_defaults = 1;
static int default_serial = 1;
static int default_parallel = 1;
static int default_virtcon = 1;
@@ -463,6 +409,14 @@ static QemuOptsList qemu_machine_opts = {
.name = "usb",
.type = QEMU_OPT_BOOL,
.help = "Set on/off to enable/disable usb",
+ },{
+ .name = "firmware",
+ .type = QEMU_OPT_STRING,
+ .help = "firmware image",
+ },{
+ .name = "kvm-type",
+ .type = QEMU_OPT_STRING,
+ .help = "Specifies the KVM virtualization mode (HV, PR)",
},
{ /* End of list */ }
},
@@ -494,7 +448,7 @@ static QemuOptsList qemu_boot_opts = {
.type = QEMU_OPT_STRING,
}, {
.name = "strict",
- .type = QEMU_OPT_STRING,
+ .type = QEMU_OPT_BOOL,
},
{ /*End of list */ }
},
@@ -564,6 +518,33 @@ static QemuOptsList qemu_msg_opts = {
},
};
+static QemuOptsList qemu_name_opts = {
+ .name = "name",
+ .implied_opt_name = "guest",
+ .merge_lists = true,
+ .head = QTAILQ_HEAD_INITIALIZER(qemu_name_opts.head),
+ .desc = {
+ {
+ .name = "guest",
+ .type = QEMU_OPT_STRING,
+ .help = "Sets the name of the guest.\n"
+ "This name will be displayed in the SDL window caption.\n"
+ "The name will also be used for the VNC server",
+ }, {
+ .name = "process",
+ .type = QEMU_OPT_STRING,
+ .help = "Sets the name of the QEMU process, as shown in top etc",
+ }, {
+ .name = "debug-threads",
+ .type = QEMU_OPT_BOOL,
+ .help = "When enabled, name the individual threads; defaults off.\n"
+ "NOTE: The thread names are for debugging and not a\n"
+ "stable API.",
+ },
+ { /* End of list */ }
+ },
+};
+
/**
* Get machine options
*
@@ -578,7 +559,7 @@ QemuOpts *qemu_get_machine_opts(void)
assert(list);
opts = qemu_opts_find(list, NULL);
if (!opts) {
- opts = qemu_opts_create_nofail(list);
+ opts = qemu_opts_create(list, NULL, 0, &error_abort);
}
return opts;
}
@@ -624,6 +605,7 @@ typedef struct {
static const RunStateTransition runstate_transitions_def[] = {
/* from -> to */
{ RUN_STATE_DEBUG, RUN_STATE_RUNNING },
+ { RUN_STATE_DEBUG, RUN_STATE_FINISH_MIGRATE },
{ RUN_STATE_INMIGRATE, RUN_STATE_RUNNING },
{ RUN_STATE_INMIGRATE, RUN_STATE_PAUSED },
@@ -1013,9 +995,25 @@ static int parse_sandbox(QemuOpts *opts, void *opaque)
return 0;
}
+static void parse_name(QemuOpts *opts)
+{
+ const char *proc_name;
+
+ if (qemu_opt_get(opts, "debug-threads")) {
+ qemu_thread_naming(qemu_opt_get_bool(opts, "debug-threads", false));
+ }
+ qemu_name = qemu_opt_get(opts, "guest");
+
+ proc_name = qemu_opt_get(opts, "process");
+ if (proc_name) {
+ os_set_proc_name(proc_name);
+ }
+}
+
bool usb_enabled(bool default_usb)
{
- return qemu_opt_get_bool(qemu_get_machine_opts(), "usb", default_usb);
+ return qemu_opt_get_bool(qemu_get_machine_opts(), "usb",
+ has_defaults && default_usb);
}
#ifndef _WIN32
@@ -1246,7 +1244,7 @@ DeviceState *get_boot_device(uint32_t position)
* memory pointed by "size" is assigned total length of the array in bytes
*
*/
-char *get_boot_devices_list(size_t *size)
+char *get_boot_devices_list(size_t *size, bool ignore_suffixes)
{
FWBootEntry *i;
size_t total = 0;
@@ -1261,7 +1259,7 @@ char *get_boot_devices_list(size_t *size)
assert(devpath);
}
- if (i->suffix && devpath) {
+ if (i->suffix && !ignore_suffixes && devpath) {
size_t bootpathlen = strlen(devpath) + strlen(i->suffix) + 1;
bootpath = g_malloc(bootpathlen);
@@ -1269,9 +1267,11 @@ char *get_boot_devices_list(size_t *size)
g_free(devpath);
} else if (devpath) {
bootpath = devpath;
- } else {
+ } else if (!ignore_suffixes) {
assert(i->suffix);
bootpath = g_strdup(i->suffix);
+ } else {
+ bootpath = g_strdup("");
}
if (total) {
@@ -1455,7 +1455,7 @@ static void smp_parse(QemuOpts *opts)
max_cpus = smp_cpus;
}
- if (max_cpus > 255) {
+ if (max_cpus > MAX_CPUMASK_BITS) {
fprintf(stderr, "Unsupported number of maxcpus\n");
exit(1);
}
@@ -1613,54 +1613,84 @@ void pcmcia_info(Monitor *mon, const QDict *qdict)
/***********************************************************/
/* machine registration */
-static QEMUMachine *first_machine = NULL;
-QEMUMachine *current_machine = NULL;
+MachineState *current_machine;
+
+static void machine_class_init(ObjectClass *oc, void *data)
+{
+ MachineClass *mc = MACHINE_CLASS(oc);
+
+ mc->qemu_machine = data;
+}
int qemu_register_machine(QEMUMachine *m)
{
- QEMUMachine **pm;
- pm = &first_machine;
- while (*pm != NULL)
- pm = &(*pm)->next;
- m->next = NULL;
- *pm = m;
+ char *name = g_strconcat(m->name, TYPE_MACHINE_SUFFIX, NULL);
+ TypeInfo ti = {
+ .name = name,
+ .parent = TYPE_MACHINE,
+ .class_init = machine_class_init,
+ .class_data = (void *)m,
+ };
+
+ type_register(&ti);
+ g_free(name);
+
return 0;
}
-static QEMUMachine *find_machine(const char *name)
+static MachineClass *find_machine(const char *name)
{
- QEMUMachine *m;
+ GSList *el, *machines = object_class_get_list(TYPE_MACHINE, false);
+ MachineClass *mc = NULL;
- for(m = first_machine; m != NULL; m = m->next) {
- if (!strcmp(m->name, name))
- return m;
- if (m->alias && !strcmp(m->alias, name))
- return m;
+ for (el = machines; el; el = el->next) {
+ MachineClass *temp = el->data;
+
+ if (!strcmp(temp->qemu_machine->name, name)) {
+ mc = temp;
+ break;
+ }
+ if (temp->qemu_machine->alias &&
+ !strcmp(temp->qemu_machine->alias, name)) {
+ mc = temp;
+ break;
+ }
}
- return NULL;
+
+ g_slist_free(machines);
+ return mc;
}
-QEMUMachine *find_default_machine(void)
+MachineClass *find_default_machine(void)
{
- QEMUMachine *m;
+ GSList *el, *machines = object_class_get_list(TYPE_MACHINE, false);
+ MachineClass *mc = NULL;
- for(m = first_machine; m != NULL; m = m->next) {
- if (m->is_default) {
- return m;
+ for (el = machines; el; el = el->next) {
+ MachineClass *temp = el->data;
+
+ if (temp->qemu_machine->is_default) {
+ mc = temp;
+ break;
}
}
- return NULL;
+
+ g_slist_free(machines);
+ return mc;
}
MachineInfoList *qmp_query_machines(Error **errp)
{
+ GSList *el, *machines = object_class_get_list(TYPE_MACHINE, false);
MachineInfoList *mach_list = NULL;
QEMUMachine *m;
- for (m = first_machine; m; m = m->next) {
+ for (el = machines; el; el = el->next) {
+ MachineClass *mc = el->data;
MachineInfoList *entry;
MachineInfo *info;
+ m = mc->qemu_machine;
info = g_malloc0(sizeof(*info));
if (m->is_default) {
info->has_is_default = true;
@@ -1681,6 +1711,7 @@ MachineInfoList *qmp_query_machines(Error **errp)
mach_list = entry;
}
+ g_slist_free(machines);
return mach_list;
}
@@ -1781,7 +1812,7 @@ static int qemu_shutdown_requested(void)
static void qemu_kill_report(void)
{
- if (!qtest_enabled() && shutdown_signal != -1) {
+ if (!qtest_driver() && 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
@@ -1874,8 +1905,12 @@ void qemu_devices_reset(void)
void qemu_system_reset(bool report)
{
- if (current_machine && current_machine->reset) {
- current_machine->reset();
+ MachineClass *mc;
+
+ mc = current_machine ? MACHINE_GET_CLASS(current_machine) : NULL;
+
+ if (mc && mc->qemu_machine->reset) {
+ mc->qemu_machine->reset();
} else {
qemu_devices_reset();
}
@@ -1921,6 +1956,7 @@ void qemu_register_suspend_notifier(Notifier *notifier)
void qemu_system_wakeup_request(WakeupReason reason)
{
+ trace_system_wakeup_request(reason);
if (!runstate_check(RUN_STATE_SUSPENDED)) {
return;
@@ -2136,12 +2172,21 @@ static bool maru_vga_available(void)
return object_class_by_name("MARU_VGA");
}
#endif
+static bool tcx_vga_available(void)
+{
+ return object_class_by_name("SUNW,tcx");
+}
+
+static bool cg3_vga_available(void)
+{
+ return object_class_by_name("cgthree");
+}
static void select_vgahw (const char *p)
{
const char *opts;
- vga_interface_type = VGA_NONE;
+ assert(vga_interface_type == VGA_NONE);
if (strstart(p, "std", &opts)) {
if (vga_available()) {
vga_interface_type = VGA_STD;
@@ -2172,6 +2217,20 @@ static void select_vgahw (const char *p)
fprintf(stderr, "Error: QXL VGA not available\n");
exit(0);
}
+ } else if (strstart(p, "tcx", &opts)) {
+ if (tcx_vga_available()) {
+ vga_interface_type = VGA_TCX;
+ } else {
+ fprintf(stderr, "Error: TCX framebuffer not available\n");
+ exit(0);
+ }
+ } else if (strstart(p, "cg3", &opts)) {
+ if (cg3_vga_available()) {
+ vga_interface_type = VGA_CG3;
+ } else {
+ fprintf(stderr, "Error: CG3 framebuffer not available\n");
+ exit(0);
+ }
#ifdef CONFIG_MARU
} else if (strstart(p, "maru", &opts)) {
if (maru_vga_available()) {
@@ -2288,6 +2347,25 @@ static DisplayType select_display(const char *p)
} else if (strstart(p, "gtk", &opts)) {
#ifdef CONFIG_GTK
display = DT_GTK;
+ while (*opts) {
+ const char *nextopt;
+
+ if (strstart(opts, ",grab_on_hover=", &nextopt)) {
+ opts = nextopt;
+ if (strstart(opts, "on", &nextopt)) {
+ grab_on_hover = true;
+ } else if (strstart(opts, "off", &nextopt)) {
+ grab_on_hover = false;
+ } else {
+ goto invalid_gtk_args;
+ }
+ } else {
+ invalid_gtk_args:
+ fprintf(stderr, "Invalid GTK option string: %s\n", p);
+ exit(1);
+ }
+ opts = nextopt;
+ }
#else
fprintf(stderr, "GTK support is disabled\n");
exit(1);
@@ -2318,7 +2396,8 @@ static int balloon_parse(const char *arg)
return -1;
} else {
/* create empty opts */
- opts = qemu_opts_create_nofail(qemu_find_opts("device"));
+ opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0,
+ &error_abort);
}
qemu_opt_set(opts, "driver", "virtio-balloon");
return 0;
@@ -2388,7 +2467,7 @@ static int chardev_init_func(QemuOpts *opts, void *opaque)
Error *local_err = NULL;
qemu_chr_new_from_opts(opts, NULL, &local_err);
- if (error_is_set(&local_err)) {
+ if (local_err) {
error_report("%s", error_get_pretty(local_err));
error_free(local_err);
return -1;
@@ -2584,14 +2663,14 @@ static int virtcon_parse(const char *devname)
exit(1);
}
- bus_opts = qemu_opts_create_nofail(device);
+ 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");
} else {
qemu_opt_set(bus_opts, "driver", "virtio-serial-pci");
}
- dev_opts = qemu_opts_create_nofail(device);
+ dev_opts = qemu_opts_create(device, NULL, 0, &error_abort);
qemu_opt_set(dev_opts, "driver", "virtconsole");
snprintf(label, sizeof(label), "virtcon%d", index);
@@ -2657,28 +2736,38 @@ static int debugcon_parse(const char *devname)
return 0;
}
-static QEMUMachine *machine_parse(const char *name)
+static MachineClass *machine_parse(const char *name)
{
- QEMUMachine *m, *machine = NULL;
+ MachineClass *mc = NULL;
+ GSList *el, *machines = object_class_get_list(TYPE_MACHINE, false);
if (name) {
- machine = find_machine(name);
+ mc = find_machine(name);
}
- if (machine) {
- return machine;
+ if (mc) {
+ return mc;
}
- printf("Supported machines are:\n");
- for (m = first_machine; m != NULL; m = m->next) {
- if (m->alias) {
- printf("%-20s %s (alias of %s)\n", m->alias, m->desc, m->name);
+ if (name && !is_help_option(name)) {
+ error_report("Unsupported machine type");
+ error_printf("Use -machine help to list supported machines!\n");
+ } else {
+ printf("Supported machines are:\n");
+ for (el = machines; el; el = el->next) {
+ MachineClass *mc = el->data;
+ QEMUMachine *m = mc->qemu_machine;
+ if (m->alias) {
+ printf("%-20s %s (alias of %s)\n", m->alias, m->desc, m->name);
+ }
+ printf("%-20s %s%s\n", m->name, m->desc,
+ m->is_default ? " (default)" : "");
}
- printf("%-20s %s%s\n", m->name, m->desc,
- m->is_default ? " (default)" : "");
}
+
+ g_slist_free(machines);
exit(!name || !is_help_option(name));
}
-static int tcg_init(void)
+static int tcg_init(QEMUMachine *machine)
{
int ret = 0;
tcg_exec_init(tcg_tb_size * 1024 * 1024);
@@ -2690,16 +2779,16 @@ static struct {
const char *opt_name;
const char *name;
int (*available)(void);
- int (*init)(void);
+ int (*init)(QEMUMachine *);
bool *allowed;
} accel_list[] = {
{ "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 },
+ { "qtest", "QTest", qtest_available, qtest_init_accel, &qtest_allowed },
};
-static int configure_accelerator(void)
+static int configure_accelerator(QEMUMachine *machine)
{
const char *p;
char buf[10];
@@ -2726,7 +2815,7 @@ static int configure_accelerator(void)
continue;
}
*(accel_list[i].allowed) = true;
- ret = accel_list[i].init();
+ ret = accel_list[i].init(machine);
if (ret < 0) {
init_failed = true;
fprintf(stderr, "failed to initialize %s: %s\n",
@@ -2879,6 +2968,7 @@ static int object_create(QemuOpts *opts, void *opaque)
{
const char *type = qemu_opt_get(opts, "qom-type");
const char *id = qemu_opts_id(opts);
+ Error *local_err = NULL;
Object *obj;
g_assert(type != NULL);
@@ -2890,12 +2980,31 @@ static int object_create(QemuOpts *opts, void *opaque)
obj = object_new(type);
if (qemu_opt_foreach(opts, object_set_property, obj, 1) < 0) {
+ object_unref(obj);
return -1;
}
+ if (!object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {
+ error_setg(&local_err, "object '%s' isn't supported by -object",
+ id);
+ goto out;
+ }
+
+ user_creatable_complete(obj, &local_err);
+ if (local_err) {
+ goto out;
+ }
+
object_property_add_child(container_get(object_get_root(), "/objects"),
- id, obj, NULL);
+ id, obj, &local_err);
+out:
+ object_unref(obj);
+ if (local_err) {
+ qerror_report_err(local_err);
+ error_free(local_err);
+ return -1;
+ }
return 0;
}
@@ -2920,9 +3029,12 @@ int main(int argc, char **argv, char **envp)
int optind;
const char *optarg;
const char *loadvm = NULL;
+ MachineClass *machine_class;
QEMUMachine *machine;
const char *cpu_model;
- const char *vga_model = "none";
+ const char *vga_model = NULL;
+ const char *qtest_chrdev = NULL;
+ const char *qtest_log = NULL;
const char *pid_file = NULL;
const char *incoming = NULL;
#ifdef CONFIG_VNC
@@ -2942,16 +3054,9 @@ int main(int argc, char **argv, char **envp)
atexit(qemu_run_exit_notifiers);
error_set_progname(argv[0]);
+ qemu_init_exec_dir(argv[0]);
g_mem_set_vtable(&mem_trace);
- if (!g_thread_supported()) {
-#if !GLIB_CHECK_VERSION(2, 31, 0)
- g_thread_init(NULL);
-#else
- fprintf(stderr, "glib threading failed to initialize.\n");
- exit(1);
-#endif
- }
module_call_init(MODULE_INIT_QOM);
@@ -2977,19 +3082,21 @@ int main(int argc, char **argv, char **envp)
qemu_add_opts(&qemu_tpmdev_opts);
qemu_add_opts(&qemu_realtime_opts);
qemu_add_opts(&qemu_msg_opts);
+ qemu_add_opts(&qemu_name_opts);
runstate_init();
init_clocks();
rtc_clock = QEMU_CLOCK_HOST;
- qemu_cache_utils_init(envp);
+ qemu_init_auxval(envp);
+ qemu_cache_utils_init();
QLIST_INIT (&vm_change_state_head);
os_setup_early_signal_handling();
module_call_init(MODULE_INIT_MACHINE);
- machine = find_default_machine();
+ machine_class = find_default_machine();
cpu_model = NULL;
ram_size = 0;
snapshot = 0;
@@ -3006,7 +3113,7 @@ int main(int argc, char **argv, char **envp)
bdrv_init_with_whitelist();
- autostart= 1;
+ autostart = 1;
/* first pass of option parsing */
optind = 1;
@@ -3055,7 +3162,7 @@ int main(int argc, char **argv, char **envp)
}
switch(popt->index) {
case QEMU_OPTION_M:
- machine = machine_parse(optarg);
+ machine_class = machine_parse(optarg);
break;
case QEMU_OPTION_no_kvm_irqchip: {
olist = qemu_find_opts("machine");
@@ -3134,14 +3241,19 @@ int main(int argc, char **argv, char **envp)
goto chs_fail;
if (*p == ',') {
p++;
- if (!strcmp(p, "none"))
+ 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"))
+ } else if (!strcmp(p, "lba")) {
translation = BIOS_ATA_TRANSLATION_LBA;
- else if (!strcmp(p, "auto"))
+ } else if (!strcmp(p, "auto")) {
translation = BIOS_ATA_TRANSLATION_AUTO;
- else
+ } else {
goto chs_fail;
+ }
} else if (*p != '\0') {
chs_fail:
fprintf(stderr, "qemu: invalid physical CHS format\n");
@@ -3155,10 +3267,15 @@ int main(int argc, char **argv, char **envp)
qemu_opt_set(hda_opts, "heads", num);
snprintf(num, sizeof(num), "%d", secs);
qemu_opt_set(hda_opts, "secs", num);
- if (translation == BIOS_ATA_TRANSLATION_LBA)
+ if (translation == BIOS_ATA_TRANSLATION_LARGE) {
+ qemu_opt_set(hda_opts, "trans", "large");
+ } else if (translation == BIOS_ATA_TRANSLATION_RECHS) {
+ qemu_opt_set(hda_opts, "trans", "rechs");
+ } else if (translation == BIOS_ATA_TRANSLATION_LBA) {
qemu_opt_set(hda_opts, "trans", "lba");
- if (translation == BIOS_ATA_TRANSLATION_NONE)
+ } else if (translation == BIOS_ATA_TRANSLATION_NONE) {
qemu_opt_set(hda_opts, "trans", "none");
+ }
}
}
break;
@@ -3295,11 +3412,9 @@ int main(int argc, char **argv, char **envp)
case QEMU_OPTION_mempath:
mem_path = optarg;
break;
-#ifdef MAP_POPULATE
case QEMU_OPTION_mem_prealloc:
mem_prealloc = 1;
break;
-#endif
case QEMU_OPTION_d:
log_mask = optarg;
break;
@@ -3318,7 +3433,7 @@ int main(int argc, char **argv, char **envp)
}
break;
case QEMU_OPTION_bios:
- bios_name = optarg;
+ qemu_opts_set(qemu_find_opts("machine"), 0, "firmware", optarg);
break;
case QEMU_OPTION_singlestep:
singlestep = 1;
@@ -3466,7 +3581,8 @@ int main(int argc, char **argv, char **envp)
qemu_opt_set_bool(fsdev, "readonly",
qemu_opt_get_bool(opts, "readonly", 0));
- device = qemu_opts_create_nofail(qemu_find_opts("device"));
+ 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",
qemu_opt_get(opts, "mount_tag"));
@@ -3486,7 +3602,8 @@ int main(int argc, char **argv, char **envp)
}
qemu_opt_set(fsdev, "fsdriver", "synth");
- device = qemu_opts_create_nofail(qemu_find_opts("device"));
+ 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");
@@ -3577,11 +3694,16 @@ int main(int argc, char **argv, char **envp)
}
case QEMU_OPTION_acpitable:
opts = qemu_opts_parse(qemu_find_opts("acpi"), optarg, 1);
- g_assert(opts != NULL);
+ if (!opts) {
+ exit(1);
+ }
do_acpitable_option(opts);
break;
case QEMU_OPTION_smbios:
opts = qemu_opts_parse(qemu_find_opts("smbios"), optarg, 0);
+ if (!opts) {
+ exit(1);
+ }
do_smbios_option(opts);
break;
case QEMU_OPTION_enable_kvm:
@@ -3635,7 +3757,7 @@ int main(int argc, char **argv, char **envp)
}
optarg = qemu_opt_get(opts, "type");
if (optarg) {
- machine = machine_parse(optarg);
+ machine_class = machine_parse(optarg);
}
break;
case QEMU_OPTION_no_kvm:
@@ -3745,19 +3867,11 @@ int main(int argc, char **argv, char **envp)
"is no longer supported.\n");
break;
case QEMU_OPTION_name:
- qemu_name = g_strdup(optarg);
- {
- char *p = strchr(qemu_name, ',');
- if (p != NULL) {
- *p++ = 0;
- if (strncmp(p, "process=", 8)) {
- fprintf(stderr, "Unknown subargument %s to -name\n", p);
- exit(1);
- }
- p += 8;
- os_set_proc_name(p);
- }
- }
+ opts = qemu_opts_parse(qemu_find_opts("name"), optarg, 1);
+ if (!opts) {
+ exit(1);
+ }
+ parse_name(opts);
break;
case QEMU_OPTION_prom_env:
if (nb_prom_envs >= MAX_PROM_ENVS) {
@@ -3799,16 +3913,7 @@ int main(int argc, char **argv, char **envp)
runstate_set(RUN_STATE_INMIGRATE);
break;
case QEMU_OPTION_nodefaults:
- default_serial = 0;
- default_parallel = 0;
- default_virtcon = 0;
- default_sclp = 0;
- default_monitor = 0;
- default_net = 0;
- default_floppy = 0;
- default_cdrom = 0;
- default_sdcard = 0;
- default_vga = 0;
+ has_defaults = 0;
break;
case QEMU_OPTION_xen_domid:
if (!(xen_available())) {
@@ -3979,11 +4084,18 @@ int main(int argc, char **argv, char **envp)
}
#endif
- if (machine == NULL) {
- fprintf(stderr, "No machine found.\n");
+ if (machine_class == NULL) {
+ fprintf(stderr, "No machine specified, and there is no default.\n"
+ "Use -machine help to list supported machines!\n");
exit(1);
}
+ current_machine = MACHINE(object_new(object_class_get_name(
+ OBJECT_CLASS(machine_class))));
+ object_property_add_child(object_get_root(), "machine",
+ OBJECT(current_machine), &error_abort);
+
+ machine = machine_class->qemu_machine;
if (machine->hw_version) {
qemu_set_version(machine->hw_version);
}
@@ -4063,14 +4175,16 @@ int main(int argc, char **argv, char **envp)
qemu_set_log(mask);
}
- if (!trace_backend_init(trace_events, trace_file)) {
- exit(1);
+ if (!is_daemonized()) {
+ if (!trace_backend_init(trace_events, trace_file)) {
+ exit(1);
+ }
}
/* 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(argv[0]);
+ data_dir[data_dir_idx] = os_find_datadir();
if (data_dir[data_dir_idx] != NULL) {
data_dir_idx++;
}
@@ -4102,27 +4216,35 @@ int main(int argc, char **argv, char **envp)
qemu_opts_foreach(qemu_find_opts("device"), default_driver_check, NULL, 0);
qemu_opts_foreach(qemu_find_opts("global"), default_driver_check, NULL, 0);
- if (machine->no_serial) {
+ if (!vga_model && !default_vga) {
+ vga_interface_type = VGA_DEVICE;
+ }
+ if (!has_defaults || machine->no_serial) {
default_serial = 0;
}
- if (machine->no_parallel) {
+ if (!has_defaults || machine->no_parallel) {
default_parallel = 0;
}
- if (!machine->use_virtcon) {
+ if (!has_defaults || !machine->use_virtcon) {
default_virtcon = 0;
}
- if (!machine->use_sclp) {
+ if (!has_defaults || !machine->use_sclp) {
default_sclp = 0;
}
- if (machine->no_floppy) {
+ if (!has_defaults || machine->no_floppy) {
default_floppy = 0;
}
- if (machine->no_cdrom) {
+ if (!has_defaults || machine->no_cdrom) {
default_cdrom = 0;
}
- if (machine->no_sdcard) {
+ if (!has_defaults || machine->no_sdcard) {
default_sdcard = 0;
}
+ if (!has_defaults) {
+ default_monitor = 0;
+ default_net = 0;
+ default_vga = 0;
+ }
if (is_daemonized()) {
/* According to documentation and historically, -nographic redirects
@@ -4247,16 +4369,23 @@ int main(int argc, char **argv, char **envp)
exit(0);
}
- configure_accelerator();
+ configure_accelerator(machine);
- if (!qtest_enabled() && qtest_chrdev) {
- qtest_init();
+ if (qtest_chrdev) {
+ 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);
+ exit(1);
+ }
}
machine_opts = qemu_get_machine_opts();
kernel_filename = qemu_opt_get(machine_opts, "kernel");
initrd_filename = qemu_opt_get(machine_opts, "initrd");
kernel_cmdline = qemu_opt_get(machine_opts, "append");
+ bios_name = qemu_opt_get(machine_opts, "firmware");
boot_order = machine->default_boot_order;
opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL);
@@ -4279,6 +4408,7 @@ int main(int argc, char **argv, char **envp)
}
boot_menu = qemu_opt_get_bool(opts, "menu", boot_menu);
+ boot_strict = qemu_opt_get_bool(opts, "strict", false);
}
if (!kernel_cmdline) {
@@ -4429,7 +4559,9 @@ int main(int argc, char **argv, char **envp)
vga_model = "std";
}
}
- select_vgahw(vga_model);
+ if (vga_model) {
+ select_vgahw(vga_model);
+ }
if (watchdog) {
i = select_watchdog(watchdog);
@@ -4448,13 +4580,16 @@ int main(int argc, char **argv, char **envp)
// Returned variable points different address from input variable.
kernel_cmdline = prepare_maru_devices(kernel_cmdline);
#endif
- QEMUMachineInitArgs args = { .ram_size = ram_size,
+ QEMUMachineInitArgs args = { .machine = machine,
+ .ram_size = ram_size,
.boot_order = boot_order,
.kernel_filename = kernel_filename,
.kernel_cmdline = kernel_cmdline,
.initrd_filename = initrd_filename,
.cpu_model = cpu_model };
- machine->init(&args);
+
+ current_machine->init_args = args;
+ machine->init(&current_machine->init_args);
// TODO: Check about it...
audio_init();
@@ -4463,8 +4598,6 @@ int main(int argc, char **argv, char **envp)
set_numa_modes();
- current_machine = machine;
-
if (hax_enabled()) {
hax_sync_vcpus();
}
@@ -4516,7 +4649,7 @@ int main(int argc, char **argv, char **envp)
#endif
#if defined(CONFIG_GTK)
case DT_GTK:
- gtk_display_init(ds, full_screen);
+ gtk_display_init(ds, full_screen, grab_on_hover);
break;
#endif
default:
@@ -4595,6 +4728,12 @@ int main(int argc, char **argv, char **envp)
os_setup_post();
+ if (is_daemonized()) {
+ if (!trace_backend_init(trace_events, trace_file)) {
+ exit(1);
+ }
+ }
+
main_loop();
bdrv_close_all();
pause_all_vcpus();