1408
static void smp_parse(const char *optarg)
1432
static QemuOptsList qemu_smp_opts = {
1434
.implied_opt_name = "cpus",
1435
.merge_lists = true,
1436
.head = QTAILQ_HEAD_INITIALIZER(qemu_smp_opts.head),
1440
.type = QEMU_OPT_NUMBER,
1443
.type = QEMU_OPT_NUMBER,
1446
.type = QEMU_OPT_NUMBER,
1449
.type = QEMU_OPT_NUMBER,
1452
.type = QEMU_OPT_NUMBER,
1454
{ /*End of list */ }
1458
static void smp_parse(QemuOpts *opts)
1410
int smp, sockets = 0, threads = 0, cores = 0;
1414
smp = strtoul(optarg, &endptr, 10);
1415
if (endptr != optarg) {
1416
if (*endptr == ',') {
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);
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;
1435
smp = cores * threads * sockets;
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);
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);
1473
cpus = cores * threads * sockets;
1442
threads = smp / (cores * sockets);
1477
threads = threads > 0 ? threads : 1;
1478
cores = cpus / (sockets * threads);
1480
threads = cpus / (cores * sockets);
1484
max_cpus = qemu_opt_get_number(opts, "maxcpus", 0);
1487
smp_cores = cores > 0 ? cores : 1;
1488
smp_threads = threads > 0 ? threads : 1;
1446
smp_cores = cores > 0 ? cores : 1;
1447
smp_threads = threads > 0 ? threads : 1;
1492
if (max_cpus == 0) {
1449
1493
max_cpus = smp_cpus;
1496
if (max_cpus > 255) {
1497
fprintf(stderr, "Unsupported number of maxcpus\n");
1500
if (max_cpus < smp_cpus) {
1501
fprintf(stderr, "maxcpus must be equal to or greater than smp\n");
1452
1507
static void configure_realtime(QemuOpts *opts)
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;
1747
1808
int qemu_shutdown_requested_get(void)
2657
2717
static int configure_accelerator(void)
2659
const char *p = NULL;
2662
2722
bool accel_initialised = false;
2663
2723
bool init_failed = false;
2665
QemuOptsList *list = qemu_find_opts("machine");
2666
if (!QTAILQ_EMPTY(&list->head)) {
2667
p = qemu_opt_get(QTAILQ_FIRST(&list->head), "accel");
2725
p = qemu_opt_get(qemu_get_machine_opts(), "accel");
2670
2726
if (p == NULL) {
2671
2727
/* Use the default "accelerator", 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);
2920
2978
runstate_init();
3146
3204
drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS);
3148
3206
case QEMU_OPTION_boot:
3150
static const char * const params[] = {
3151
"order", "once", "menu",
3152
"splash", "splash-time",
3153
"reboot-timeout", "strict", NULL
3155
char buf[sizeof(boot_devices)];
3156
char *standard_boot_devices;
3159
if (!strchr(optarg, '=')) {
3161
pstrcpy(buf, sizeof(buf), optarg);
3162
} else if (check_params(buf, sizeof(buf), params, optarg) < 0) {
3164
"qemu: unknown boot parameter '%s' in '%s'\n",
3170
get_param_value(buf, sizeof(buf), "order", optarg)) {
3171
validate_bootdevices(buf);
3172
pstrcpy(boot_devices, sizeof(boot_devices), buf);
3175
if (get_param_value(buf, sizeof(buf),
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);
3183
if (get_param_value(buf, sizeof(buf),
3185
if (!strcmp(buf, "on")) {
3187
} else if (!strcmp(buf, "off")) {
3191
"qemu: invalid option value '%s'\n",
3196
if (get_param_value(buf, sizeof(buf),
3197
"strict", optarg)) {
3198
if (!strcmp(buf, "on")) {
3200
} else if (!strcmp(buf, "off")) {
3201
boot_strict = false;
3204
"qemu: invalid option value '%s'\n",
3209
if (!qemu_opts_parse(qemu_find_opts("boot-opts"),
3207
opts = qemu_opts_parse(qemu_find_opts("boot-opts"), optarg, 1);
3216
3212
case QEMU_OPTION_fda:
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");
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");
4100
4093
#if defined(CONFIG_GTK)
4101
4094
if (display_type == DT_GTK) {
4102
4095
early_gtk_display_init();
4139
machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
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");
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");
4138
boot_order = machine->boot_order;
4140
opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL);
4142
char *normal_boot_order;
4143
const char *order, *once;
4145
order = qemu_opt_get(opts, "order");
4147
validate_bootdevices(order);
4151
once = qemu_opt_get(opts, "once");
4153
validate_bootdevices(once);
4154
normal_boot_order = g_strdup(boot_order);
4156
qemu_register_reset(restore_boot_order, normal_boot_order);
4159
boot_menu = qemu_opt_get_bool(opts, "menu", boot_menu);
4148
4162
if (!kernel_cmdline) {