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,6 +279,7 @@ void *fw_cfg_init(uint32_t ctl_port, uint32_t data_port, | ||
279 | fw_cfg_add_bytes(s, FW_CFG_UUID, qemu_uuid, 16); | 279 | fw_cfg_add_bytes(s, FW_CFG_UUID, qemu_uuid, 16); |
280 | fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)(display_type == DT_NOGRAPHIC)); | 280 | fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)(display_type == DT_NOGRAPHIC)); |
281 | fw_cfg_add_i16(s, FW_CFG_NB_CPUS, (uint16_t)smp_cpus); | 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 | fw_cfg_add_i16(s, FW_CFG_BOOT_MENU, (uint16_t)boot_menu); | 283 | fw_cfg_add_i16(s, FW_CFG_BOOT_MENU, (uint16_t)boot_menu); |
283 | 284 | ||
284 | register_savevm("fw_cfg", -1, 1, fw_cfg_save, fw_cfg_load, s); | 285 | register_savevm("fw_cfg", -1, 1, fw_cfg_save, fw_cfg_load, s); |
hw/fw_cfg.h
@@ -16,6 +16,7 @@ | @@ -16,6 +16,7 @@ | ||
16 | #define FW_CFG_BOOT_DEVICE 0x0c | 16 | #define FW_CFG_BOOT_DEVICE 0x0c |
17 | #define FW_CFG_NUMA 0x0d | 17 | #define FW_CFG_NUMA 0x0d |
18 | #define FW_CFG_BOOT_MENU 0x0e | 18 | #define FW_CFG_BOOT_MENU 0x0e |
19 | +#define FW_CFG_MAX_CPUS 0x0f | ||
19 | #define FW_CFG_MAX_ENTRY 0x10 | 20 | #define FW_CFG_MAX_ENTRY 0x10 |
20 | 21 | ||
21 | #define FW_CFG_WRITE_CHANNEL 0x4000 | 22 | #define FW_CFG_WRITE_CHANNEL 0x4000 |
qemu-options.hx
@@ -39,7 +39,10 @@ Select CPU model (-cpu ? for list and additional feature selection) | @@ -39,7 +39,10 @@ Select CPU model (-cpu ? for list and additional feature selection) | ||
39 | ETEXI | 39 | ETEXI |
40 | 40 | ||
41 | DEF("smp", HAS_ARG, QEMU_OPTION_smp, | 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 | STEXI | 46 | STEXI |
44 | @item -smp @var{n} | 47 | @item -smp @var{n} |
45 | Simulate an SMP system with @var{n} CPUs. On the PC target, up to 255 | 48 | Simulate an SMP system with @var{n} CPUs. On the PC target, up to 255 |
sysemu.h
@@ -121,6 +121,7 @@ extern int usb_enabled; | @@ -121,6 +121,7 @@ extern int usb_enabled; | ||
121 | extern int virtio_balloon; | 121 | extern int virtio_balloon; |
122 | extern const char *virtio_balloon_devaddr; | 122 | extern const char *virtio_balloon_devaddr; |
123 | extern int smp_cpus; | 123 | extern int smp_cpus; |
124 | +extern int max_cpus; | ||
124 | extern int cursor_hide; | 125 | extern int cursor_hide; |
125 | extern int graphic_rotate; | 126 | extern int graphic_rotate; |
126 | extern int no_quit; | 127 | extern int no_quit; |
vl.c
@@ -222,6 +222,7 @@ int rtc_td_hack = 0; | @@ -222,6 +222,7 @@ int rtc_td_hack = 0; | ||
222 | int usb_enabled = 0; | 222 | int usb_enabled = 0; |
223 | int singlestep = 0; | 223 | int singlestep = 0; |
224 | int smp_cpus = 1; | 224 | int smp_cpus = 1; |
225 | +int max_cpus = 0; | ||
225 | const char *vnc_display; | 226 | const char *vnc_display; |
226 | int acpi_enabled = 1; | 227 | int acpi_enabled = 1; |
227 | int no_hpet = 0; | 228 | int no_hpet = 0; |
@@ -5453,12 +5454,29 @@ int main(int argc, char **argv, char **envp) | @@ -5453,12 +5454,29 @@ int main(int argc, char **argv, char **envp) | ||
5453 | add_device_config(DEV_GENERIC, optarg); | 5454 | add_device_config(DEV_GENERIC, optarg); |
5454 | break; | 5455 | break; |
5455 | case QEMU_OPTION_smp: | 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 | if (smp_cpus < 1) { | 5461 | if (smp_cpus < 1) { |
5458 | fprintf(stderr, "Invalid number of CPUs\n"); | 5462 | fprintf(stderr, "Invalid number of CPUs\n"); |
5459 | exit(1); | 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 | break; | 5478 | break; |
5479 | + } | ||
5462 | case QEMU_OPTION_vnc: | 5480 | case QEMU_OPTION_vnc: |
5463 | display_type = DT_VNC; | 5481 | display_type = DT_VNC; |
5464 | vnc_display = optarg; | 5482 | vnc_display = optarg; |
@@ -5639,6 +5657,13 @@ int main(int argc, char **argv, char **envp) | @@ -5639,6 +5657,13 @@ int main(int argc, char **argv, char **envp) | ||
5639 | } | 5657 | } |
5640 | #endif | 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 | machine->max_cpus = machine->max_cpus ?: 1; /* Default to UP */ | 5667 | machine->max_cpus = machine->max_cpus ?: 1; /* Default to UP */ |
5643 | if (smp_cpus > machine->max_cpus) { | 5668 | if (smp_cpus > machine->max_cpus) { |
5644 | fprintf(stderr, "Number of SMP cpus requested (%d), exceeds max cpus " | 5669 | fprintf(stderr, "Number of SMP cpus requested (%d), exceeds max cpus " |