uint32_t xen_domid;
enum xen_mode xen_mode = XEN_EMULATE;
-#ifdef SIGRTMIN
-#define SIG_IPI (SIGRTMIN+4)
-#else
-#define SIG_IPI SIGUSR1
-#endif
-
static int default_serial = 1;
static int default_parallel = 1;
static int default_virtcon = 1;
opts = qemu_opts_parse(&qemu_drive_opts, optstr, 0);
if (!opts) {
- fprintf(stderr, "%s: huh? duplicate? (%s)\n",
- __FUNCTION__, optstr);
return NULL;
}
if (file)
QEMUMachine *machine = opaque;
int max_devs;
int index;
- int cache;
- int aio = 0;
int ro = 0;
- int bdrv_flags;
+ int bdrv_flags = 0;
int on_read_error, on_write_error;
const char *devaddr;
DriveInfo *dinfo;
*fatal_error = 1;
translation = BIOS_ATA_TRANSLATION_AUTO;
- cache = 1;
if (machine && machine->use_scsi) {
type = IF_SCSI;
}
if ((buf = qemu_opt_get(opts, "cache")) != NULL) {
- if (!strcmp(buf, "off") || !strcmp(buf, "none"))
- cache = 0;
- else if (!strcmp(buf, "writethrough"))
- cache = 1;
- else if (!strcmp(buf, "writeback"))
- cache = 2;
- else {
+ if (!strcmp(buf, "off") || !strcmp(buf, "none")) {
+ bdrv_flags |= BDRV_O_NOCACHE;
+ } else if (!strcmp(buf, "writeback")) {
+ bdrv_flags |= BDRV_O_CACHE_WB;
+ } else if (!strcmp(buf, "writethrough")) {
+ /* this is the default */
+ } else {
fprintf(stderr, "qemu: invalid cache option\n");
return NULL;
}
#ifdef CONFIG_LINUX_AIO
if ((buf = qemu_opt_get(opts, "aio")) != NULL) {
- if (!strcmp(buf, "threads"))
- aio = 0;
- else if (!strcmp(buf, "native"))
- aio = 1;
- else {
+ if (!strcmp(buf, "native")) {
+ bdrv_flags |= BDRV_O_NATIVE_AIO;
+ } else if (!strcmp(buf, "threads")) {
+ /* this is the default */
+ } else {
fprintf(stderr, "qemu: invalid aio option\n");
return NULL;
}
*fatal_error = 0;
return NULL;
}
- bdrv_flags = 0;
if (snapshot) {
- bdrv_flags |= BDRV_O_SNAPSHOT;
- cache = 2; /* always use write-back with snapshot */
- }
- if (cache == 0) /* no caching */
- bdrv_flags |= BDRV_O_NOCACHE;
- else if (cache == 2) /* write-back */
- bdrv_flags |= BDRV_O_CACHE_WB;
-
- if (aio == 1) {
- bdrv_flags |= BDRV_O_NATIVE_AIO;
- } else {
- bdrv_flags &= ~BDRV_O_NATIVE_AIO;
+ /* always use write-back with snapshot */
+ bdrv_flags &= ~BDRV_O_CACHE_MASK;
+ bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB);
}
if (media == MEDIA_CDROM) {
bdrv_flags |= ro ? 0 : BDRV_O_RDWR;
- if (bdrv_open2(dinfo->bdrv, file, bdrv_flags, drv) < 0) {
+ if (bdrv_open(dinfo->bdrv, file, bdrv_flags, drv) < 0) {
fprintf(stderr, "qemu: could not open disk image %s: %s\n",
file, strerror(errno));
return NULL;
return boot_set_handler(boot_set_opaque, boot_devices);
}
-static int parse_bootdevices(char *devices)
+static void validate_bootdevices(char *devices)
{
/* We just do some generic consistency checks */
const char *p;
}
bitmap |= 1 << (*p - 'a');
}
- return bitmap;
}
static void restore_boot_devices(void *opaque)
static int shutdown_requested;
static int powerdown_requested;
int debug_requested;
-static int vmstop_requested;
+int vmstop_requested;
+static int exit_requested;
int qemu_shutdown_requested(void)
{
return r;
}
+int qemu_exit_requested(void)
+{
+ /* just return it, we'll exit() anyway */
+ return exit_requested;
+}
+
static int qemu_debug_requested(void)
{
int r = debug_requested;
qemu_notify_event();
}
+void qemu_system_exit_request(void)
+{
+ exit_requested = 1;
+ qemu_notify_event();
+}
+
#ifdef _WIN32
static void host_main_loop_wait(int *timeout)
{
return 0;
if (debug_requested)
return 0;
+ if (exit_requested)
+ return 0;
return 1;
}
{
int r;
-#ifdef CONFIG_IOTHREAD
- qemu_system_ready = 1;
- qemu_cond_broadcast(&qemu_system_cond);
-#endif
+ qemu_main_loop_start();
for (;;) {
do {
if ((r = qemu_vmstop_requested())) {
vm_stop(r);
}
+ if (qemu_exit_requested()) {
+ exit(0);
+ }
}
pause_all_vcpus();
}
int main(int argc, char **argv, char **envp)
{
const char *gdbstub_dev = NULL;
- uint32_t boot_devices_bitmap = 0;
int i;
- int snapshot, linux_boot, net_boot;
+ int snapshot, linux_boot;
const char *icount_option = NULL;
const char *initrd_filename;
const char *kernel_filename, *kernel_cmdline;
}
if (defconfig) {
- const char *fname;
- FILE *fp;
+ int ret;
- fname = CONFIG_QEMU_CONFDIR "/qemu.conf";
- fp = fopen(fname, "r");
- if (fp) {
- if (qemu_config_parse(fp, fname) != 0) {
- exit(1);
- }
- fclose(fp);
+ ret = qemu_read_config_file(CONFIG_QEMU_CONFDIR "/qemu.conf");
+ if (ret == -EINVAL) {
+ exit(1);
}
- fname = arch_config_name;
- fp = fopen(fname, "r");
- if (fp) {
- if (qemu_config_parse(fp, fname) != 0) {
- exit(1);
- }
- fclose(fp);
+ ret = qemu_read_config_file(arch_config_name);
+ if (ret == -EINVAL) {
+ exit(1);
}
}
cpudef_init();
if (legacy ||
get_param_value(buf, sizeof(buf), "order", optarg)) {
- boot_devices_bitmap = parse_bootdevices(buf);
+ validate_bootdevices(buf);
pstrcpy(boot_devices, sizeof(boot_devices), buf);
}
if (!legacy) {
if (get_param_value(buf, sizeof(buf),
"once", optarg)) {
- boot_devices_bitmap |= parse_bootdevices(buf);
+ validate_bootdevices(buf);
standard_boot_devices = qemu_strdup(boot_devices);
pstrcpy(boot_devices, sizeof(boot_devices), buf);
qemu_register_reset(restore_boot_devices,
case QEMU_OPTION_mon:
opts = qemu_opts_parse(&qemu_mon_opts, optarg, 1);
if (!opts) {
- fprintf(stderr, "parse error: %s\n", optarg);
exit(1);
}
default_monitor = 0;
case QEMU_OPTION_chardev:
opts = qemu_opts_parse(&qemu_chardev_opts, optarg, 1);
if (!opts) {
- fprintf(stderr, "parse error: %s\n", optarg);
exit(1);
}
break;
do_smbios_option(optarg);
break;
case QEMU_OPTION_enable_kvm:
- if (!(kvm_available())) {
- printf("Option %s not supported for this target\n", popt->name);
- exit(1);
- }
kvm_allowed = 1;
break;
case QEMU_OPTION_usb:
case QEMU_OPTION_rtc:
opts = qemu_opts_parse(&qemu_rtc_opts, optarg, 0);
if (!opts) {
- fprintf(stderr, "parse error: %s\n", optarg);
exit(1);
}
configure_rtc(opts);
break;
case QEMU_OPTION_readconfig:
{
- FILE *fp;
- fp = fopen(optarg, "r");
- if (fp == NULL) {
- fprintf(stderr, "open %s: %s\n", optarg, strerror(errno));
- exit(1);
- }
- if (qemu_config_parse(fp, optarg) != 0) {
+ int ret = qemu_read_config_file(optarg);
+ if (ret < 0) {
+ fprintf(stderr, "read config %s: %s\n", optarg,
+ strerror(-ret));
exit(1);
}
- fclose(fp);
break;
}
case QEMU_OPTION_writeconfig:
exit(1);
}
- if (kvm_enabled()) {
- int ret;
-
- ret = kvm_init(smp_cpus);
+ if (kvm_allowed) {
+ int ret = kvm_init(smp_cpus);
if (ret < 0) {
- fprintf(stderr, "failed to initialize KVM\n");
+ if (!kvm_available()) {
+ printf("KVM not supported for this target\n");
+ } else {
+ fprintf(stderr, "failed to initialize KVM: %s\n", strerror(-ret));
+ }
exit(1);
}
}
exit(1);
}
- net_boot = (boot_devices_bitmap >> ('n' - 'a')) & 0xF;
- net_set_boot_mask(net_boot);
-
/* init the bluetooth world */
if (foreach_device_config(DEV_BT, bt_parse))
exit(1);