1405
static void smp_parse(const char *optarg)
1429
static QemuOptsList qemu_smp_opts = {
1431
.implied_opt_name = "cpus",
1432
.merge_lists = true,
1433
.head = QTAILQ_HEAD_INITIALIZER(qemu_smp_opts.head),
1437
.type = QEMU_OPT_NUMBER,
1440
.type = QEMU_OPT_NUMBER,
1443
.type = QEMU_OPT_NUMBER,
1446
.type = QEMU_OPT_NUMBER,
1449
.type = QEMU_OPT_NUMBER,
1451
{ /*End of list */ }
1455
static void smp_parse(QemuOpts *opts)
1407
int smp, sockets = 0, threads = 0, cores = 0;
1411
smp = strtoul(optarg, &endptr, 10);
1412
if (endptr != optarg) {
1413
if (*endptr == ',') {
1417
if (get_param_value(option, 128, "sockets", endptr) != 0)
1418
sockets = strtoull(option, NULL, 10);
1419
if (get_param_value(option, 128, "cores", endptr) != 0)
1420
cores = strtoull(option, NULL, 10);
1421
if (get_param_value(option, 128, "threads", endptr) != 0)
1422
threads = strtoull(option, NULL, 10);
1423
if (get_param_value(option, 128, "maxcpus", endptr) != 0)
1424
max_cpus = strtoull(option, NULL, 10);
1426
/* compute missing values, prefer sockets over cores over threads */
1427
if (smp == 0 || sockets == 0) {
1428
sockets = sockets > 0 ? sockets : 1;
1429
cores = cores > 0 ? cores : 1;
1430
threads = threads > 0 ? threads : 1;
1432
smp = cores * threads * sockets;
1459
unsigned cpus = qemu_opt_get_number(opts, "cpus", 0);
1460
unsigned sockets = qemu_opt_get_number(opts, "sockets", 0);
1461
unsigned cores = qemu_opt_get_number(opts, "cores", 0);
1462
unsigned threads = qemu_opt_get_number(opts, "threads", 0);
1464
/* compute missing values, prefer sockets over cores over threads */
1465
if (cpus == 0 || sockets == 0) {
1466
sockets = sockets > 0 ? sockets : 1;
1467
cores = cores > 0 ? cores : 1;
1436
1468
threads = threads > 0 ? threads : 1;
1437
cores = smp / (sockets * threads);
1470
cpus = cores * threads * sockets;
1439
threads = smp / (cores * sockets);
1474
threads = threads > 0 ? threads : 1;
1475
cores = cpus / (sockets * threads);
1477
threads = cpus / (cores * sockets);
1481
max_cpus = qemu_opt_get_number(opts, "maxcpus", 0);
1484
smp_cores = cores > 0 ? cores : 1;
1485
smp_threads = threads > 0 ? threads : 1;
1443
smp_cores = cores > 0 ? cores : 1;
1444
smp_threads = threads > 0 ? threads : 1;
1489
if (max_cpus == 0) {
1446
1490
max_cpus = smp_cpus;
1493
if (max_cpus > 255) {
1494
fprintf(stderr, "Unsupported number of maxcpus\n");
1497
if (max_cpus < smp_cpus) {
1498
fprintf(stderr, "maxcpus must be equal to or greater than smp\n");
1449
1504
static void configure_realtime(QemuOpts *opts)
1731
1792
static int powerdown_requested;
1732
1793
static int debug_requested;
1733
1794
static int suspend_requested;
1734
static int wakeup_requested;
1795
static WakeupReason wakeup_reason;
1735
1796
static NotifierList powerdown_notifiers =
1736
1797
NOTIFIER_LIST_INITIALIZER(powerdown_notifiers);
1737
1798
static NotifierList suspend_notifiers =
1738
1799
NOTIFIER_LIST_INITIALIZER(suspend_notifiers);
1739
1800
static NotifierList wakeup_notifiers =
1740
1801
NOTIFIER_LIST_INITIALIZER(wakeup_notifiers);
1741
static uint32_t wakeup_reason_mask = ~0;
1802
static uint32_t wakeup_reason_mask = ~(1 << QEMU_WAKEUP_REASON_NONE);
1742
1803
static RunState vmstop_requested = RUN_STATE_MAX;
1744
1805
int qemu_shutdown_requested_get(void)
2643
2703
static int configure_accelerator(void)
2645
const char *p = NULL;
2648
2708
bool accel_initialised = false;
2649
2709
bool init_failed = false;
2651
QemuOptsList *list = qemu_find_opts("machine");
2652
if (!QTAILQ_EMPTY(&list->head)) {
2653
p = qemu_opt_get(QTAILQ_FIRST(&list->head), "accel");
2711
p = qemu_opt_get(qemu_get_machine_opts(), "accel");
2656
2712
if (p == NULL) {
2657
2713
/* Use the default "accelerator", tcg */
2842
2898
const char *icount_option = NULL;
2843
2899
const char *initrd_filename;
2844
2900
const char *kernel_filename, *kernel_cmdline;
2845
char boot_devices[33] = "";
2901
const char *boot_order = NULL;
2846
2902
DisplayState *ds;
2847
2903
int cyls, heads, secs, translation;
2848
2904
QemuOpts *hda_opts = NULL, *opts, *machine_opts;
2896
2952
qemu_add_opts(&qemu_trace_opts);
2897
2953
qemu_add_opts(&qemu_option_rom_opts);
2898
2954
qemu_add_opts(&qemu_machine_opts);
2955
qemu_add_opts(&qemu_smp_opts);
2899
2956
qemu_add_opts(&qemu_boot_opts);
2900
2957
qemu_add_opts(&qemu_sandbox_opts);
2901
2958
qemu_add_opts(&qemu_add_fd_opts);
2902
2959
qemu_add_opts(&qemu_object_opts);
2903
2960
qemu_add_opts(&qemu_tpmdev_opts);
2904
2961
qemu_add_opts(&qemu_realtime_opts);
2962
qemu_add_opts(&qemu_msg_opts);
2906
2964
runstate_init();
3132
3190
drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS);
3134
3192
case QEMU_OPTION_boot:
3136
static const char * const params[] = {
3137
"order", "once", "menu",
3138
"splash", "splash-time",
3139
"reboot-timeout", "strict", NULL
3141
char buf[sizeof(boot_devices)];
3142
char *standard_boot_devices;
3145
if (!strchr(optarg, '=')) {
3147
pstrcpy(buf, sizeof(buf), optarg);
3148
} else if (check_params(buf, sizeof(buf), params, optarg) < 0) {
3150
"qemu: unknown boot parameter '%s' in '%s'\n",
3156
get_param_value(buf, sizeof(buf), "order", optarg)) {
3157
validate_bootdevices(buf);
3158
pstrcpy(boot_devices, sizeof(boot_devices), buf);
3161
if (get_param_value(buf, sizeof(buf),
3163
validate_bootdevices(buf);
3164
standard_boot_devices = g_strdup(boot_devices);
3165
pstrcpy(boot_devices, sizeof(boot_devices), buf);
3166
qemu_register_reset(restore_boot_devices,
3167
standard_boot_devices);
3169
if (get_param_value(buf, sizeof(buf),
3171
if (!strcmp(buf, "on")) {
3173
} else if (!strcmp(buf, "off")) {
3177
"qemu: invalid option value '%s'\n",
3182
if (get_param_value(buf, sizeof(buf),
3183
"strict", optarg)) {
3184
if (!strcmp(buf, "on")) {
3186
} else if (!strcmp(buf, "off")) {
3187
boot_strict = false;
3190
"qemu: invalid option value '%s'\n",
3195
if (!qemu_opts_parse(qemu_find_opts("boot-opts"),
3193
opts = qemu_opts_parse(qemu_find_opts("boot-opts"), optarg, 1);
3202
3198
case QEMU_OPTION_fda:
4069
if ((no_frame || alt_grab || ctrl_grab) && display_type != DT_SDL) {
4070
fprintf(stderr, "-no-frame, -alt-grab and -ctrl-grab are only valid "
4071
"for SDL, ignoring option\n");
4073
if (no_quit && (display_type != DT_GTK && display_type != DT_SDL)) {
4074
fprintf(stderr, "-no-quit is only valid for GTK and SDL, "
4075
"ignoring option\n");
4085
4078
#if defined(CONFIG_GTK)
4086
4079
if (display_type == DT_GTK) {
4087
4080
early_gtk_display_init();
4124
machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
4126
kernel_filename = qemu_opt_get(machine_opts, "kernel");
4127
initrd_filename = qemu_opt_get(machine_opts, "initrd");
4128
kernel_cmdline = qemu_opt_get(machine_opts, "append");
4130
kernel_filename = initrd_filename = kernel_cmdline = NULL;
4117
machine_opts = qemu_get_machine_opts();
4118
kernel_filename = qemu_opt_get(machine_opts, "kernel");
4119
initrd_filename = qemu_opt_get(machine_opts, "initrd");
4120
kernel_cmdline = qemu_opt_get(machine_opts, "append");
4123
boot_order = machine->boot_order;
4125
opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL);
4127
char *normal_boot_order;
4128
const char *order, *once;
4130
order = qemu_opt_get(opts, "order");
4132
validate_bootdevices(order);
4136
once = qemu_opt_get(opts, "once");
4138
validate_bootdevices(once);
4139
normal_boot_order = g_strdup(boot_order);
4141
qemu_register_reset(restore_boot_order, normal_boot_order);
4144
boot_menu = qemu_opt_get_bool(opts, "menu", boot_menu);
4133
4147
if (!kernel_cmdline) {