~ubuntu-branches/ubuntu/trusty/qemu/trusty

« back to all changes in this revision

Viewing changes to vl.c

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2013-10-22 22:47:07 UTC
  • mfrom: (1.8.3) (10.1.42 sid)
  • Revision ID: package-import@ubuntu.com-20131022224707-1lya34fw3k3f24tv
Tags: 1.6.0+dfsg-2ubuntu1
* Merge 1.6.0~rc0+dfsg-2exp from debian experimental.  Remaining changes:
  - debian/control
    * update maintainer
    * remove libiscsi, usb-redir, vde, vnc-jpeg, and libssh2-1-dev
      from build-deps
    * enable rbd
    * add qemu-system and qemu-common B/R to qemu-keymaps
    * add D:udev, R:qemu, R:qemu-common and B:qemu-common to
      qemu-system-common
    * qemu-system-arm, qemu-system-ppc, qemu-system-sparc:
      - add qemu-kvm to Provides
      - add qemu-common, qemu-kvm, kvm to B/R
      - remove openbios-sparc from qemu-system-sparc D
      - drop openbios-ppc and openhackware Depends to Suggests (for now)
    * qemu-system-x86:
      - add qemu-common to Breaks/Replaces.
      - add cpu-checker to Recommends.
    * qemu-user: add B/R:qemu-kvm
    * qemu-kvm:
      - add armhf armel powerpc sparc to Architecture
      - C/R/P: qemu-kvm-spice
    * add qemu-common package
    * drop qemu-slof which is not packaged in ubuntu
  - add qemu-system-common.links for tap ifup/down scripts and OVMF link.
  - qemu-system-x86.links:
    * remove pxe rom links which are in kvm-ipxe
    * add symlink for kvm.1 manpage
  - debian/rules
    * add kvm-spice symlink to qemu-kvm
    * call dh_installmodules for qemu-system-x86
    * update dh_installinit to install upstart script
    * run dh_installman (Closes: #709241) (cherrypicked from 1.5.0+dfsg-2)
  - Add qemu-utils.links for kvm-* symlinks.
  - Add qemu-system-x86.qemu-kvm.upstart and .default
  - Add qemu-system-x86.modprobe to set nesting=1
  - Add qemu-system-common.preinst to add kvm group
  - qemu-system-common.postinst: remove bad group acl if there, then have
    udev relabel /dev/kvm.
  - New linaro patches from qemu-linaro rebasing branch
  - Dropped patches:
    * xen-simplify-xen_enabled.patch
    * sparc-linux-user-fix-missing-symbols-in-.rel-.rela.plt-sections.patch
    * main_loop-do-not-set-nonblocking-if-xen_enabled.patch
    * xen_machine_pv-do-not-create-a-dummy-CPU-in-machine-.patch
    * virtio-rng-fix-crash
  - Kept patches:
    * expose_vms_qemu64cpu.patch - updated
    * linaro arm patches from qemu-linaro rebasing branch
  - New patches:
    * fix-pci-add: change CONFIG variable in ifdef to make sure that
      pci_add is defined.
* Add linaro patches
* Add experimental mach-virt patches for arm virtualization.
* qemu-system-common.install: add debian/tmp/usr/lib to install the
  qemu-bridge-helper

Show diffs side-by-side

added added

removed removed

Lines of Context:
202
202
QEMUClock *rtc_clock;
203
203
int vga_interface_type = VGA_NONE;
204
204
static int full_screen = 0;
205
 
#ifdef CONFIG_SDL
206
205
static int no_frame = 0;
207
 
#endif
208
206
int no_quit = 0;
209
207
CharDriverState *serial_hds[MAX_SERIAL_PORTS];
210
208
CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
414
412
            .help = "Dump current dtb to a file and quit",
415
413
        }, {
416
414
            .name = "phandle_start",
417
 
            .type = QEMU_OPT_STRING,
 
415
            .type = QEMU_OPT_NUMBER,
418
416
            .help = "The first phandle ID we may generate dynamically",
419
417
        }, {
420
418
            .name = "dt_compatible",
439
437
 
440
438
static QemuOptsList qemu_boot_opts = {
441
439
    .name = "boot-opts",
 
440
    .implied_opt_name = "order",
 
441
    .merge_lists = true,
442
442
    .head = QTAILQ_HEAD_INITIALIZER(qemu_boot_opts.head),
443
443
    .desc = {
444
 
        /* the three names below are not used now */
445
444
        {
446
445
            .name = "order",
447
446
            .type = QEMU_OPT_STRING,
450
449
            .type = QEMU_OPT_STRING,
451
450
        }, {
452
451
            .name = "menu",
453
 
            .type = QEMU_OPT_STRING,
454
 
        /* following are really used */
 
452
            .type = QEMU_OPT_BOOL,
455
453
        }, {
456
454
            .name = "splash",
457
455
            .type = QEMU_OPT_STRING,
521
519
    },
522
520
};
523
521
 
 
522
static QemuOptsList qemu_msg_opts = {
 
523
    .name = "msg",
 
524
    .head = QTAILQ_HEAD_INITIALIZER(qemu_msg_opts.head),
 
525
    .desc = {
 
526
        {
 
527
            .name = "timestamp",
 
528
            .type = QEMU_OPT_BOOL,
 
529
        },
 
530
        { /* end of list */ }
 
531
    },
 
532
};
 
533
 
 
534
/**
 
535
 * Get machine options
 
536
 *
 
537
 * Returns: machine options (never null).
 
538
 */
 
539
QemuOpts *qemu_get_machine_opts(void)
 
540
{
 
541
    QemuOptsList *list;
 
542
    QemuOpts *opts;
 
543
 
 
544
    list = qemu_find_opts("machine");
 
545
    assert(list);
 
546
    opts = qemu_opts_find(list, NULL);
 
547
    if (!opts) {
 
548
        opts = qemu_opts_create_nofail(list);
 
549
    }
 
550
    return opts;
 
551
}
 
552
 
524
553
const char *qemu_get_vm_name(void)
525
554
{
526
555
    return qemu_name;
613
642
 
614
643
    { RUN_STATE_GUEST_PANICKED, RUN_STATE_PAUSED },
615
644
    { RUN_STATE_GUEST_PANICKED, RUN_STATE_FINISH_MIGRATE },
 
645
    { RUN_STATE_GUEST_PANICKED, RUN_STATE_DEBUG },
616
646
 
617
647
    { RUN_STATE_MAX, RUN_STATE_MAX },
618
648
};
1021
1051
    return 0;
1022
1052
}
1023
1053
 
1024
 
/*********QEMU USB setting******/
1025
1054
bool usb_enabled(bool default_usb)
1026
1055
{
1027
 
    QemuOpts *mach_opts;
1028
 
    mach_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
1029
 
    if (mach_opts) {
1030
 
        return qemu_opt_get_bool(mach_opts, "usb", default_usb);
1031
 
    }
1032
 
    return default_usb;
 
1056
    return qemu_opt_get_bool(qemu_get_machine_opts(), "usb", default_usb);
1033
1057
}
1034
1058
 
1035
1059
#ifndef _WIN32
1153
1177
    boot_set_opaque = opaque;
1154
1178
}
1155
1179
 
1156
 
int qemu_boot_set(const char *boot_devices)
 
1180
int qemu_boot_set(const char *boot_order)
1157
1181
{
1158
1182
    if (!boot_set_handler) {
1159
1183
        return -EINVAL;
1160
1184
    }
1161
 
    return boot_set_handler(boot_set_opaque, boot_devices);
 
1185
    return boot_set_handler(boot_set_opaque, boot_order);
1162
1186
}
1163
1187
 
1164
 
static void validate_bootdevices(char *devices)
 
1188
static void validate_bootdevices(const char *devices)
1165
1189
{
1166
1190
    /* We just do some generic consistency checks */
1167
1191
    const char *p;
1189
1213
    }
1190
1214
}
1191
1215
 
1192
 
static void restore_boot_devices(void *opaque)
 
1216
static void restore_boot_order(void *opaque)
1193
1217
{
1194
 
    char *standard_boot_devices = opaque;
 
1218
    char *normal_boot_order = opaque;
1195
1219
    static int first = 1;
1196
1220
 
1197
1221
    /* Restore boot order and remove ourselves after the first boot */
1200
1224
        return;
1201
1225
    }
1202
1226
 
1203
 
    qemu_boot_set(standard_boot_devices);
 
1227
    qemu_boot_set(normal_boot_order);
1204
1228
 
1205
 
    qemu_unregister_reset(restore_boot_devices, standard_boot_devices);
1206
 
    g_free(standard_boot_devices);
 
1229
    qemu_unregister_reset(restore_boot_order, normal_boot_order);
 
1230
    g_free(normal_boot_order);
1207
1231
}
1208
1232
 
1209
1233
void add_boot_device_path(int32_t bootindex, DeviceState *dev,
1405
1429
    }
1406
1430
}
1407
1431
 
1408
 
static void smp_parse(const char *optarg)
 
1432
static QemuOptsList qemu_smp_opts = {
 
1433
    .name = "smp-opts",
 
1434
    .implied_opt_name = "cpus",
 
1435
    .merge_lists = true,
 
1436
    .head = QTAILQ_HEAD_INITIALIZER(qemu_smp_opts.head),
 
1437
    .desc = {
 
1438
        {
 
1439
            .name = "cpus",
 
1440
            .type = QEMU_OPT_NUMBER,
 
1441
        }, {
 
1442
            .name = "sockets",
 
1443
            .type = QEMU_OPT_NUMBER,
 
1444
        }, {
 
1445
            .name = "cores",
 
1446
            .type = QEMU_OPT_NUMBER,
 
1447
        }, {
 
1448
            .name = "threads",
 
1449
            .type = QEMU_OPT_NUMBER,
 
1450
        }, {
 
1451
            .name = "maxcpus",
 
1452
            .type = QEMU_OPT_NUMBER,
 
1453
        },
 
1454
        { /*End of list */ }
 
1455
    },
 
1456
};
 
1457
 
 
1458
static void smp_parse(QemuOpts *opts)
1409
1459
{
1410
 
    int smp, sockets = 0, threads = 0, cores = 0;
1411
 
    char *endptr;
1412
 
    char option[128];
1413
 
 
1414
 
    smp = strtoul(optarg, &endptr, 10);
1415
 
    if (endptr != optarg) {
1416
 
        if (*endptr == ',') {
1417
 
            endptr++;
1418
 
        }
1419
 
    }
1420
 
    if (get_param_value(option, 128, "sockets", endptr) != 0)
1421
 
        sockets = strtoull(option, NULL, 10);
1422
 
    if (get_param_value(option, 128, "cores", endptr) != 0)
1423
 
        cores = strtoull(option, NULL, 10);
1424
 
    if (get_param_value(option, 128, "threads", endptr) != 0)
1425
 
        threads = strtoull(option, NULL, 10);
1426
 
    if (get_param_value(option, 128, "maxcpus", endptr) != 0)
1427
 
        max_cpus = strtoull(option, NULL, 10);
1428
 
 
1429
 
    /* compute missing values, prefer sockets over cores over threads */
1430
 
    if (smp == 0 || sockets == 0) {
1431
 
        sockets = sockets > 0 ? sockets : 1;
1432
 
        cores = cores > 0 ? cores : 1;
1433
 
        threads = threads > 0 ? threads : 1;
1434
 
        if (smp == 0) {
1435
 
            smp = cores * threads * sockets;
1436
 
        }
1437
 
    } else {
1438
 
        if (cores == 0) {
 
1460
    if (opts) {
 
1461
 
 
1462
        unsigned cpus    = qemu_opt_get_number(opts, "cpus", 0);
 
1463
        unsigned sockets = qemu_opt_get_number(opts, "sockets", 0);
 
1464
        unsigned cores   = qemu_opt_get_number(opts, "cores", 0);
 
1465
        unsigned threads = qemu_opt_get_number(opts, "threads", 0);
 
1466
 
 
1467
        /* compute missing values, prefer sockets over cores over threads */
 
1468
        if (cpus == 0 || sockets == 0) {
 
1469
            sockets = sockets > 0 ? sockets : 1;
 
1470
            cores = cores > 0 ? cores : 1;
1439
1471
            threads = threads > 0 ? threads : 1;
1440
 
            cores = smp / (sockets * threads);
 
1472
            if (cpus == 0) {
 
1473
                cpus = cores * threads * sockets;
 
1474
            }
1441
1475
        } else {
1442
 
            threads = smp / (cores * sockets);
 
1476
            if (cores == 0) {
 
1477
                threads = threads > 0 ? threads : 1;
 
1478
                cores = cpus / (sockets * threads);
 
1479
            } else {
 
1480
                threads = cpus / (cores * sockets);
 
1481
            }
1443
1482
        }
 
1483
 
 
1484
        max_cpus = qemu_opt_get_number(opts, "maxcpus", 0);
 
1485
 
 
1486
        smp_cpus = cpus;
 
1487
        smp_cores = cores > 0 ? cores : 1;
 
1488
        smp_threads = threads > 0 ? threads : 1;
 
1489
 
1444
1490
    }
1445
 
    smp_cpus = smp;
1446
 
    smp_cores = cores > 0 ? cores : 1;
1447
 
    smp_threads = threads > 0 ? threads : 1;
1448
 
    if (max_cpus == 0)
 
1491
 
 
1492
    if (max_cpus == 0) {
1449
1493
        max_cpus = smp_cpus;
 
1494
    }
 
1495
 
 
1496
    if (max_cpus > 255) {
 
1497
        fprintf(stderr, "Unsupported number of maxcpus\n");
 
1498
        exit(1);
 
1499
    }
 
1500
    if (max_cpus < smp_cpus) {
 
1501
        fprintf(stderr, "maxcpus must be equal to or greater than smp\n");
 
1502
        exit(1);
 
1503
    }
 
1504
 
1450
1505
}
1451
1506
 
1452
1507
static void configure_realtime(QemuOpts *opts)
1463
1518
    }
1464
1519
}
1465
1520
 
 
1521
 
 
1522
static void configure_msg(QemuOpts *opts)
 
1523
{
 
1524
    enable_timestamp_msg = qemu_opt_get_bool(opts, "timestamp", true);
 
1525
}
 
1526
 
1466
1527
/***********************************************************/
1467
1528
/* USB devices */
1468
1529
 
1734
1795
static int powerdown_requested;
1735
1796
static int debug_requested;
1736
1797
static int suspend_requested;
1737
 
static int wakeup_requested;
 
1798
static WakeupReason wakeup_reason;
1738
1799
static NotifierList powerdown_notifiers =
1739
1800
    NOTIFIER_LIST_INITIALIZER(powerdown_notifiers);
1740
1801
static NotifierList suspend_notifiers =
1741
1802
    NOTIFIER_LIST_INITIALIZER(suspend_notifiers);
1742
1803
static NotifierList wakeup_notifiers =
1743
1804
    NOTIFIER_LIST_INITIALIZER(wakeup_notifiers);
1744
 
static uint32_t wakeup_reason_mask = ~0;
 
1805
static uint32_t wakeup_reason_mask = ~(1 << QEMU_WAKEUP_REASON_NONE);
1745
1806
static RunState vmstop_requested = RUN_STATE_MAX;
1746
1807
 
1747
1808
int qemu_shutdown_requested_get(void)
1791
1852
    return r;
1792
1853
}
1793
1854
 
1794
 
static int qemu_wakeup_requested(void)
 
1855
static WakeupReason qemu_wakeup_requested(void)
1795
1856
{
1796
 
    int r = wakeup_requested;
1797
 
    wakeup_requested = 0;
1798
 
    return r;
 
1857
    return wakeup_reason;
1799
1858
}
1800
1859
 
1801
1860
static int qemu_powerdown_requested(void)
1912
1971
        return;
1913
1972
    }
1914
1973
    runstate_set(RUN_STATE_RUNNING);
1915
 
    notifier_list_notify(&wakeup_notifiers, &reason);
1916
 
    wakeup_requested = 1;
 
1974
    wakeup_reason = reason;
1917
1975
    qemu_notify_event();
1918
1976
}
1919
1977
 
2005
2063
        pause_all_vcpus();
2006
2064
        cpu_synchronize_all_states();
2007
2065
        qemu_system_reset(VMRESET_SILENT);
 
2066
        notifier_list_notify(&wakeup_notifiers, &wakeup_reason);
 
2067
        wakeup_reason = QEMU_WAKEUP_REASON_NONE;
2008
2068
        resume_all_vcpus();
2009
2069
        monitor_protocol_event(QEVENT_WAKEUP, NULL);
2010
2070
    }
2656
2716
 
2657
2717
static int configure_accelerator(void)
2658
2718
{
2659
 
    const char *p = NULL;
 
2719
    const char *p;
2660
2720
    char buf[10];
2661
2721
    int i, ret;
2662
2722
    bool accel_initialised = false;
2663
2723
    bool init_failed = false;
2664
2724
 
2665
 
    QemuOptsList *list = qemu_find_opts("machine");
2666
 
    if (!QTAILQ_EMPTY(&list->head)) {
2667
 
        p = qemu_opt_get(QTAILQ_FIRST(&list->head), "accel");
2668
 
    }
2669
 
 
 
2725
    p = qemu_opt_get(qemu_get_machine_opts(), "accel");
2670
2726
    if (p == NULL) {
2671
2727
        /* Use the default "accelerator", tcg */
2672
2728
        p = "tcg";
2856
2912
    const char *icount_option = NULL;
2857
2913
    const char *initrd_filename;
2858
2914
    const char *kernel_filename, *kernel_cmdline;
2859
 
    char boot_devices[33] = "";
 
2915
    const char *boot_order = NULL;
2860
2916
    DisplayState *ds;
2861
2917
    int cyls, heads, secs, translation;
2862
2918
    QemuOpts *hda_opts = NULL, *opts, *machine_opts;
2910
2966
    qemu_add_opts(&qemu_trace_opts);
2911
2967
    qemu_add_opts(&qemu_option_rom_opts);
2912
2968
    qemu_add_opts(&qemu_machine_opts);
 
2969
    qemu_add_opts(&qemu_smp_opts);
2913
2970
    qemu_add_opts(&qemu_boot_opts);
2914
2971
    qemu_add_opts(&qemu_sandbox_opts);
2915
2972
    qemu_add_opts(&qemu_add_fd_opts);
2916
2973
    qemu_add_opts(&qemu_object_opts);
2917
2974
    qemu_add_opts(&qemu_tpmdev_opts);
2918
2975
    qemu_add_opts(&qemu_realtime_opts);
 
2976
    qemu_add_opts(&qemu_msg_opts);
2919
2977
 
2920
2978
    runstate_init();
2921
2979
 
3146
3204
                drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS);
3147
3205
                break;
3148
3206
            case QEMU_OPTION_boot:
3149
 
                {
3150
 
                    static const char * const params[] = {
3151
 
                        "order", "once", "menu",
3152
 
                        "splash", "splash-time",
3153
 
                        "reboot-timeout", "strict", NULL
3154
 
                    };
3155
 
                    char buf[sizeof(boot_devices)];
3156
 
                    char *standard_boot_devices;
3157
 
                    int legacy = 0;
3158
 
 
3159
 
                    if (!strchr(optarg, '=')) {
3160
 
                        legacy = 1;
3161
 
                        pstrcpy(buf, sizeof(buf), optarg);
3162
 
                    } else if (check_params(buf, sizeof(buf), params, optarg) < 0) {
3163
 
                        fprintf(stderr,
3164
 
                                "qemu: unknown boot parameter '%s' in '%s'\n",
3165
 
                                buf, optarg);
3166
 
                        exit(1);
3167
 
                    }
3168
 
 
3169
 
                    if (legacy ||
3170
 
                        get_param_value(buf, sizeof(buf), "order", optarg)) {
3171
 
                        validate_bootdevices(buf);
3172
 
                        pstrcpy(boot_devices, sizeof(boot_devices), buf);
3173
 
                    }
3174
 
                    if (!legacy) {
3175
 
                        if (get_param_value(buf, sizeof(buf),
3176
 
                                            "once", optarg)) {
3177
 
                            validate_bootdevices(buf);
3178
 
                            standard_boot_devices = g_strdup(boot_devices);
3179
 
                            pstrcpy(boot_devices, sizeof(boot_devices), buf);
3180
 
                            qemu_register_reset(restore_boot_devices,
3181
 
                                                standard_boot_devices);
3182
 
                        }
3183
 
                        if (get_param_value(buf, sizeof(buf),
3184
 
                                            "menu", optarg)) {
3185
 
                            if (!strcmp(buf, "on")) {
3186
 
                                boot_menu = 1;
3187
 
                            } else if (!strcmp(buf, "off")) {
3188
 
                                boot_menu = 0;
3189
 
                            } else {
3190
 
                                fprintf(stderr,
3191
 
                                        "qemu: invalid option value '%s'\n",
3192
 
                                        buf);
3193
 
                                exit(1);
3194
 
                            }
3195
 
                        }
3196
 
                        if (get_param_value(buf, sizeof(buf),
3197
 
                                            "strict", optarg)) {
3198
 
                            if (!strcmp(buf, "on")) {
3199
 
                                boot_strict = true;
3200
 
                            } else if (!strcmp(buf, "off")) {
3201
 
                                boot_strict = false;
3202
 
                            } else {
3203
 
                                fprintf(stderr,
3204
 
                                        "qemu: invalid option value '%s'\n",
3205
 
                                        buf);
3206
 
                                exit(1);
3207
 
                            }
3208
 
                        }
3209
 
                        if (!qemu_opts_parse(qemu_find_opts("boot-opts"),
3210
 
                                             optarg, 0)) {
3211
 
                            exit(1);
3212
 
                        }
3213
 
                    }
 
3207
                opts = qemu_opts_parse(qemu_find_opts("boot-opts"), optarg, 1);
 
3208
                if (!opts) {
 
3209
                    exit(1);
3214
3210
                }
3215
3211
                break;
3216
3212
            case QEMU_OPTION_fda:
3380
3376
                    break;
3381
3377
                }
3382
3378
            case QEMU_OPTION_monitor:
3383
 
                monitor_parse(optarg, "readline");
3384
3379
                default_monitor = 0;
 
3380
                if (strncmp(optarg, "none", 4)) {
 
3381
                    monitor_parse(optarg, "readline");
 
3382
                }
3385
3383
                break;
3386
3384
            case QEMU_OPTION_qmp:
3387
3385
                monitor_parse(optarg, "control");
3535
3533
            case QEMU_OPTION_full_screen:
3536
3534
                full_screen = 1;
3537
3535
                break;
3538
 
#ifdef CONFIG_SDL
3539
3536
            case QEMU_OPTION_no_frame:
3540
3537
                no_frame = 1;
3541
3538
                break;
3549
3546
                no_quit = 1;
3550
3547
                break;
3551
3548
            case QEMU_OPTION_sdl:
 
3549
#ifdef CONFIG_SDL
3552
3550
                display_type = DT_SDL;
3553
3551
                break;
3554
3552
#else
3555
 
            case QEMU_OPTION_no_frame:
3556
 
            case QEMU_OPTION_alt_grab:
3557
 
            case QEMU_OPTION_ctrl_grab:
3558
 
            case QEMU_OPTION_no_quit:
3559
 
            case QEMU_OPTION_sdl:
3560
3553
                fprintf(stderr, "SDL support is disabled\n");
3561
3554
                exit(1);
3562
3555
#endif
3641
3634
                }
3642
3635
                break;
3643
3636
            case QEMU_OPTION_smp:
3644
 
                smp_parse(optarg);
3645
 
                if (smp_cpus < 1) {
3646
 
                    fprintf(stderr, "Invalid number of CPUs\n");
3647
 
                    exit(1);
3648
 
                }
3649
 
                if (max_cpus < smp_cpus) {
3650
 
                    fprintf(stderr, "maxcpus must be equal to or greater than "
3651
 
                            "smp\n");
3652
 
                    exit(1);
3653
 
                }
3654
 
                if (max_cpus > 255) {
3655
 
                    fprintf(stderr, "Unsupported number of maxcpus\n");
 
3637
                if (!qemu_opts_parse(qemu_find_opts("smp-opts"), optarg, 1)) {
3656
3638
                    exit(1);
3657
3639
                }
3658
3640
                break;
3888
3870
                }
3889
3871
                configure_realtime(opts);
3890
3872
                break;
 
3873
            case QEMU_OPTION_msg:
 
3874
                opts = qemu_opts_parse(qemu_find_opts("msg"), optarg, 0);
 
3875
                if (!opts) {
 
3876
                    exit(1);
 
3877
                }
 
3878
                configure_msg(opts);
 
3879
                break;
3891
3880
            default:
3892
3881
                os_parse_cmd_args(popt->index, optarg);
3893
3882
            }
3977
3966
    }
3978
3967
#endif
3979
3968
 
3980
 
    /*
3981
 
     * Default to max_cpus = smp_cpus, in case the user doesn't
3982
 
     * specify a max_cpus value.
3983
 
     */
3984
 
    if (!max_cpus)
3985
 
        max_cpus = smp_cpus;
 
3969
    smp_parse(qemu_opts_find(qemu_find_opts("smp-opts"), NULL));
3986
3970
 
3987
3971
    machine->max_cpus = machine->max_cpus ?: 1; /* Default to UP */
3988
3972
    if (smp_cpus > machine->max_cpus) {
4097
4081
#endif
4098
4082
    }
4099
4083
 
 
4084
    if ((no_frame || alt_grab || ctrl_grab) && display_type != DT_SDL) {
 
4085
        fprintf(stderr, "-no-frame, -alt-grab and -ctrl-grab are only valid "
 
4086
                        "for SDL, ignoring option\n");
 
4087
    }
 
4088
    if (no_quit && (display_type != DT_GTK && display_type != DT_SDL)) {
 
4089
        fprintf(stderr, "-no-quit is only valid for GTK and SDL, "
 
4090
                        "ignoring option\n");
 
4091
    }
 
4092
 
4100
4093
#if defined(CONFIG_GTK)
4101
4094
    if (display_type == DT_GTK) {
4102
4095
        early_gtk_display_init();
4136
4129
        qtest_init();
4137
4130
    }
4138
4131
 
4139
 
    machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
4140
 
    if (machine_opts) {
4141
 
        kernel_filename = qemu_opt_get(machine_opts, "kernel");
4142
 
        initrd_filename = qemu_opt_get(machine_opts, "initrd");
4143
 
        kernel_cmdline = qemu_opt_get(machine_opts, "append");
4144
 
    } else {
4145
 
        kernel_filename = initrd_filename = kernel_cmdline = NULL;
 
4132
    machine_opts = qemu_get_machine_opts();
 
4133
    kernel_filename = qemu_opt_get(machine_opts, "kernel");
 
4134
    initrd_filename = qemu_opt_get(machine_opts, "initrd");
 
4135
    kernel_cmdline = qemu_opt_get(machine_opts, "append");
 
4136
 
 
4137
    if (!boot_order) {
 
4138
        boot_order = machine->boot_order;
 
4139
    }
 
4140
    opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL);
 
4141
    if (opts) {
 
4142
        char *normal_boot_order;
 
4143
        const char *order, *once;
 
4144
 
 
4145
        order = qemu_opt_get(opts, "order");
 
4146
        if (order) {
 
4147
            validate_bootdevices(order);
 
4148
            boot_order = order;
 
4149
        }
 
4150
 
 
4151
        once = qemu_opt_get(opts, "once");
 
4152
        if (once) {
 
4153
            validate_bootdevices(once);
 
4154
            normal_boot_order = g_strdup(boot_order);
 
4155
            boot_order = once;
 
4156
            qemu_register_reset(restore_boot_order, normal_boot_order);
 
4157
        }
 
4158
 
 
4159
        boot_menu = qemu_opt_get_bool(opts, "menu", boot_menu);
4146
4160
    }
4147
4161
 
4148
4162
    if (!kernel_cmdline) {
4161
4175
        exit(1);
4162
4176
    }
4163
4177
 
4164
 
    if (!linux_boot && machine_opts && qemu_opt_get(machine_opts, "dtb")) {
 
4178
    if (!linux_boot && qemu_opt_get(machine_opts, "dtb")) {
4165
4179
        fprintf(stderr, "-dtb only allowed with -kernel option\n");
4166
4180
        exit(1);
4167
4181
    }
4309
4323
    qdev_machine_init();
4310
4324
 
4311
4325
    QEMUMachineInitArgs args = { .ram_size = ram_size,
4312
 
                                 .boot_device = (boot_devices[0] == '\0') ?
4313
 
                                                machine->boot_order :
4314
 
                                                boot_devices,
 
4326
                                 .boot_device = boot_order,
4315
4327
                                 .kernel_filename = kernel_filename,
4316
4328
                                 .kernel_cmdline = kernel_cmdline,
4317
4329
                                 .initrd_filename = initrd_filename,
4360
4372
#endif
4361
4373
#if defined(CONFIG_GTK)
4362
4374
    case DT_GTK:
4363
 
        gtk_display_init(ds);
 
4375
        gtk_display_init(ds, full_screen);
4364
4376
        break;
4365
4377
#endif
4366
4378
    default:
4389
4401
    }
4390
4402
#endif
4391
4403
#ifdef CONFIG_SPICE
4392
 
    if (using_spice && !qxl_enabled) {
 
4404
    if (using_spice && !spice_displays) {
4393
4405
        qemu_spice_display_init(ds);
4394
4406
    }
4395
4407
#endif