Revision dc6b1c09 vl.c
b/vl.c | ||
---|---|---|
217 | 217 |
int singlestep = 0; |
218 | 218 |
int smp_cpus = 1; |
219 | 219 |
int max_cpus = 0; |
220 |
int smp_cores = 1; |
|
221 |
int smp_threads = 1; |
|
220 | 222 |
const char *vnc_display; |
221 | 223 |
int acpi_enabled = 1; |
222 | 224 |
int no_hpet = 0; |
... | ... | |
2356 | 2358 |
return; |
2357 | 2359 |
} |
2358 | 2360 |
|
2361 |
static void smp_parse(const char *optarg) |
|
2362 |
{ |
|
2363 |
int smp, sockets = 0, threads = 0, cores = 0; |
|
2364 |
char *endptr; |
|
2365 |
char option[128]; |
|
2366 |
|
|
2367 |
smp = strtoul(optarg, &endptr, 10); |
|
2368 |
if (endptr != optarg) { |
|
2369 |
if (*endptr == ',') { |
|
2370 |
endptr++; |
|
2371 |
} |
|
2372 |
} |
|
2373 |
if (get_param_value(option, 128, "sockets", endptr) != 0) |
|
2374 |
sockets = strtoull(option, NULL, 10); |
|
2375 |
if (get_param_value(option, 128, "cores", endptr) != 0) |
|
2376 |
cores = strtoull(option, NULL, 10); |
|
2377 |
if (get_param_value(option, 128, "threads", endptr) != 0) |
|
2378 |
threads = strtoull(option, NULL, 10); |
|
2379 |
if (get_param_value(option, 128, "maxcpus", endptr) != 0) |
|
2380 |
max_cpus = strtoull(option, NULL, 10); |
|
2381 |
|
|
2382 |
/* compute missing values, prefer sockets over cores over threads */ |
|
2383 |
if (smp == 0 || sockets == 0) { |
|
2384 |
sockets = sockets > 0 ? sockets : 1; |
|
2385 |
cores = cores > 0 ? cores : 1; |
|
2386 |
threads = threads > 0 ? threads : 1; |
|
2387 |
if (smp == 0) { |
|
2388 |
smp = cores * threads * sockets; |
|
2389 |
} else { |
|
2390 |
sockets = smp / (cores * threads); |
|
2391 |
} |
|
2392 |
} else { |
|
2393 |
if (cores == 0) { |
|
2394 |
threads = threads > 0 ? threads : 1; |
|
2395 |
cores = smp / (sockets * threads); |
|
2396 |
} else { |
|
2397 |
if (sockets == 0) { |
|
2398 |
sockets = smp / (cores * threads); |
|
2399 |
} else { |
|
2400 |
threads = smp / (cores * sockets); |
|
2401 |
} |
|
2402 |
} |
|
2403 |
} |
|
2404 |
smp_cpus = smp; |
|
2405 |
smp_cores = cores > 0 ? cores : 1; |
|
2406 |
smp_threads = threads > 0 ? threads : 1; |
|
2407 |
if (max_cpus == 0) |
|
2408 |
max_cpus = smp_cpus; |
|
2409 |
} |
|
2410 |
|
|
2359 | 2411 |
/***********************************************************/ |
2360 | 2412 |
/* USB devices */ |
2361 | 2413 |
|
... | ... | |
3565 | 3617 |
|
3566 | 3618 |
if (kvm_enabled()) |
3567 | 3619 |
kvm_init_vcpu(env); |
3620 |
env->nr_cores = smp_cores; |
|
3621 |
env->nr_threads = smp_threads; |
|
3568 | 3622 |
return; |
3569 | 3623 |
} |
3570 | 3624 |
|
... | ... | |
3888 | 3942 |
kvm_start_vcpu(env); |
3889 | 3943 |
else |
3890 | 3944 |
tcg_init_vcpu(env); |
3945 |
env->nr_cores = smp_cores; |
|
3946 |
env->nr_threads = smp_threads; |
|
3891 | 3947 |
} |
3892 | 3948 |
|
3893 | 3949 |
void qemu_notify_event(void) |
... | ... | |
5374 | 5430 |
} |
5375 | 5431 |
break; |
5376 | 5432 |
case QEMU_OPTION_smp: |
5377 |
{ |
|
5378 |
char *p; |
|
5379 |
char option[128]; |
|
5380 |
smp_cpus = strtol(optarg, &p, 10); |
|
5433 |
smp_parse(optarg); |
|
5381 | 5434 |
if (smp_cpus < 1) { |
5382 | 5435 |
fprintf(stderr, "Invalid number of CPUs\n"); |
5383 | 5436 |
exit(1); |
5384 | 5437 |
} |
5385 |
if (*p++ != ',') |
|
5386 |
break; |
|
5387 |
if (get_param_value(option, 128, "maxcpus", p)) |
|
5388 |
max_cpus = strtol(option, NULL, 0); |
|
5389 | 5438 |
if (max_cpus < smp_cpus) { |
5390 | 5439 |
fprintf(stderr, "maxcpus must be equal to or greater than " |
5391 | 5440 |
"smp\n"); |
... | ... | |
5396 | 5445 |
exit(1); |
5397 | 5446 |
} |
5398 | 5447 |
break; |
5399 |
} |
|
5400 | 5448 |
case QEMU_OPTION_vnc: |
5401 | 5449 |
display_type = DT_VNC; |
5402 | 5450 |
vnc_display = optarg; |
Also available in: Unified diff