Commit 6be68d7eb9037fa3b8ef18901e5c02c120463efd
Committed by
Anthony Liguori
1 parent
96c1606b
Introduce -smp , maxcpus= flag to specify maximum number of CPUS.
Follow on patch will use it to determine the size of the MADT and other BIOS tables. Signed-off-by: Jes Sorensen <jes@sgi.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing
5 changed files
with
33 additions
and
2 deletions
hw/fw_cfg.c
| ... | ... | @@ -279,6 +279,7 @@ void *fw_cfg_init(uint32_t ctl_port, uint32_t data_port, |
| 279 | 279 | fw_cfg_add_bytes(s, FW_CFG_UUID, qemu_uuid, 16); |
| 280 | 280 | fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)(display_type == DT_NOGRAPHIC)); |
| 281 | 281 | fw_cfg_add_i16(s, FW_CFG_NB_CPUS, (uint16_t)smp_cpus); |
| 282 | + fw_cfg_add_i16(s, FW_CFG_MAX_CPUS, (uint16_t)max_cpus); | |
| 282 | 283 | fw_cfg_add_i16(s, FW_CFG_BOOT_MENU, (uint16_t)boot_menu); |
| 283 | 284 | |
| 284 | 285 | register_savevm("fw_cfg", -1, 1, fw_cfg_save, fw_cfg_load, s); | ... | ... |
hw/fw_cfg.h
qemu-options.hx
| ... | ... | @@ -39,7 +39,10 @@ Select CPU model (-cpu ? for list and additional feature selection) |
| 39 | 39 | ETEXI |
| 40 | 40 | |
| 41 | 41 | DEF("smp", HAS_ARG, QEMU_OPTION_smp, |
| 42 | - "-smp n set the number of CPUs to 'n' [default=1]\n") | |
| 42 | + "-smp n[,maxcpus=cpus]\n" | |
| 43 | + " set the number of CPUs to 'n' [default=1]\n" | |
| 44 | + " maxcpus= maximum number of total cpus, including\n" | |
| 45 | + " offline CPUs for hotplug etc.\n") | |
| 43 | 46 | STEXI |
| 44 | 47 | @item -smp @var{n} |
| 45 | 48 | Simulate an SMP system with @var{n} CPUs. On the PC target, up to 255 | ... | ... |
sysemu.h
vl.c
| ... | ... | @@ -222,6 +222,7 @@ int rtc_td_hack = 0; |
| 222 | 222 | int usb_enabled = 0; |
| 223 | 223 | int singlestep = 0; |
| 224 | 224 | int smp_cpus = 1; |
| 225 | +int max_cpus = 0; | |
| 225 | 226 | const char *vnc_display; |
| 226 | 227 | int acpi_enabled = 1; |
| 227 | 228 | int no_hpet = 0; |
| ... | ... | @@ -5453,12 +5454,29 @@ int main(int argc, char **argv, char **envp) |
| 5453 | 5454 | add_device_config(DEV_GENERIC, optarg); |
| 5454 | 5455 | break; |
| 5455 | 5456 | case QEMU_OPTION_smp: |
| 5456 | - smp_cpus = atoi(optarg); | |
| 5457 | + { | |
| 5458 | + char *p; | |
| 5459 | + char option[128]; | |
| 5460 | + smp_cpus = strtol(optarg, &p, 10); | |
| 5457 | 5461 | if (smp_cpus < 1) { |
| 5458 | 5462 | fprintf(stderr, "Invalid number of CPUs\n"); |
| 5459 | 5463 | exit(1); |
| 5460 | 5464 | } |
| 5465 | + if (*p++ != ',') | |
| 5466 | + break; | |
| 5467 | + if (get_param_value(option, 128, "maxcpus", p)) | |
| 5468 | + max_cpus = strtol(option, NULL, 0); | |
| 5469 | + if (max_cpus < smp_cpus) { | |
| 5470 | + fprintf(stderr, "maxcpus must be equal to or greater than " | |
| 5471 | + "smp\n"); | |
| 5472 | + exit(1); | |
| 5473 | + } | |
| 5474 | + if (max_cpus > 255) { | |
| 5475 | + fprintf(stderr, "Unsupported number of maxcpus\n"); | |
| 5476 | + exit(1); | |
| 5477 | + } | |
| 5461 | 5478 | break; |
| 5479 | + } | |
| 5462 | 5480 | case QEMU_OPTION_vnc: |
| 5463 | 5481 | display_type = DT_VNC; |
| 5464 | 5482 | vnc_display = optarg; |
| ... | ... | @@ -5639,6 +5657,13 @@ int main(int argc, char **argv, char **envp) |
| 5639 | 5657 | } |
| 5640 | 5658 | #endif |
| 5641 | 5659 | |
| 5660 | + /* | |
| 5661 | + * Default to max_cpus = smp_cpus, in case the user doesn't | |
| 5662 | + * specify a max_cpus value. | |
| 5663 | + */ | |
| 5664 | + if (!max_cpus) | |
| 5665 | + max_cpus = smp_cpus; | |
| 5666 | + | |
| 5642 | 5667 | machine->max_cpus = machine->max_cpus ?: 1; /* Default to UP */ |
| 5643 | 5668 | if (smp_cpus > machine->max_cpus) { |
| 5644 | 5669 | fprintf(stderr, "Number of SMP cpus requested (%d), exceeds max cpus " | ... | ... |