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)
2654
2714
static int configure_accelerator(void)
2656
const char *p = NULL;
2659
2719
bool accel_initialised = false;
2660
2720
bool init_failed = false;
2662
QemuOptsList *list = qemu_find_opts("machine");
2663
if (!QTAILQ_EMPTY(&list->head)) {
2664
p = qemu_opt_get(QTAILQ_FIRST(&list->head), "accel");
2722
p = qemu_opt_get(qemu_get_machine_opts(), "accel");
2667
2723
if (p == NULL) {
2668
2724
/* Use the default "accelerator", tcg */
2853
2909
const char *icount_option = NULL;
2854
2910
const char *initrd_filename;
2855
2911
const char *kernel_filename, *kernel_cmdline;
2856
char boot_devices[33] = "";
2912
const char *boot_order = NULL;
2857
2913
DisplayState *ds;
2858
2914
int cyls, heads, secs, translation;
2859
2915
QemuOpts *hda_opts = NULL, *opts, *machine_opts;
2907
2963
qemu_add_opts(&qemu_trace_opts);
2908
2964
qemu_add_opts(&qemu_option_rom_opts);
2909
2965
qemu_add_opts(&qemu_machine_opts);
2966
qemu_add_opts(&qemu_smp_opts);
2910
2967
qemu_add_opts(&qemu_boot_opts);
2911
2968
qemu_add_opts(&qemu_sandbox_opts);
2912
2969
qemu_add_opts(&qemu_add_fd_opts);
2913
2970
qemu_add_opts(&qemu_object_opts);
2914
2971
qemu_add_opts(&qemu_tpmdev_opts);
2915
2972
qemu_add_opts(&qemu_realtime_opts);
2973
qemu_add_opts(&qemu_msg_opts);
2917
2975
runstate_init();
3143
3201
drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS);
3145
3203
case QEMU_OPTION_boot:
3147
static const char * const params[] = {
3148
"order", "once", "menu",
3149
"splash", "splash-time",
3150
"reboot-timeout", "strict", NULL
3152
char buf[sizeof(boot_devices)];
3153
char *standard_boot_devices;
3156
if (!strchr(optarg, '=')) {
3158
pstrcpy(buf, sizeof(buf), optarg);
3159
} else if (check_params(buf, sizeof(buf), params, optarg) < 0) {
3161
"qemu: unknown boot parameter '%s' in '%s'\n",
3167
get_param_value(buf, sizeof(buf), "order", optarg)) {
3168
validate_bootdevices(buf);
3169
pstrcpy(boot_devices, sizeof(boot_devices), buf);
3172
if (get_param_value(buf, sizeof(buf),
3174
validate_bootdevices(buf);
3175
standard_boot_devices = g_strdup(boot_devices);
3176
pstrcpy(boot_devices, sizeof(boot_devices), buf);
3177
qemu_register_reset(restore_boot_devices,
3178
standard_boot_devices);
3180
if (get_param_value(buf, sizeof(buf),
3182
if (!strcmp(buf, "on")) {
3184
} else if (!strcmp(buf, "off")) {
3188
"qemu: invalid option value '%s'\n",
3193
if (get_param_value(buf, sizeof(buf),
3194
"strict", optarg)) {
3195
if (!strcmp(buf, "on")) {
3197
} else if (!strcmp(buf, "off")) {
3198
boot_strict = false;
3201
"qemu: invalid option value '%s'\n",
3206
if (!qemu_opts_parse(qemu_find_opts("boot-opts"),
3204
opts = qemu_opts_parse(qemu_find_opts("boot-opts"), optarg, 1);
3213
3209
case QEMU_OPTION_fda:
4080
if ((no_frame || alt_grab || ctrl_grab) && display_type != DT_SDL) {
4081
fprintf(stderr, "-no-frame, -alt-grab and -ctrl-grab are only valid "
4082
"for SDL, ignoring option\n");
4084
if (no_quit && (display_type != DT_GTK && display_type != DT_SDL)) {
4085
fprintf(stderr, "-no-quit is only valid for GTK and SDL, "
4086
"ignoring option\n");
4096
4089
#if defined(CONFIG_GTK)
4097
4090
if (display_type == DT_GTK) {
4098
4091
early_gtk_display_init();
4135
machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
4137
kernel_filename = qemu_opt_get(machine_opts, "kernel");
4138
initrd_filename = qemu_opt_get(machine_opts, "initrd");
4139
kernel_cmdline = qemu_opt_get(machine_opts, "append");
4141
kernel_filename = initrd_filename = kernel_cmdline = NULL;
4128
machine_opts = qemu_get_machine_opts();
4129
kernel_filename = qemu_opt_get(machine_opts, "kernel");
4130
initrd_filename = qemu_opt_get(machine_opts, "initrd");
4131
kernel_cmdline = qemu_opt_get(machine_opts, "append");
4134
boot_order = machine->boot_order;
4136
opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL);
4138
char *normal_boot_order;
4139
const char *order, *once;
4141
order = qemu_opt_get(opts, "order");
4143
validate_bootdevices(order);
4147
once = qemu_opt_get(opts, "once");
4149
validate_bootdevices(once);
4150
normal_boot_order = g_strdup(boot_order);
4152
qemu_register_reset(restore_boot_order, normal_boot_order);
4155
boot_menu = qemu_opt_get_bool(opts, "menu", boot_menu);
4144
4158
if (!kernel_cmdline) {