From 6be68d7eb9037fa3b8ef18901e5c02c120463efd Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Thu, 23 Jul 2009 17:03:42 +0200 Subject: 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 Signed-off-by: Anthony Liguori --- vl.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'vl.c') diff --git a/vl.c b/vl.c index 2cff5a936c..2152f6ae53 100644 --- a/vl.c +++ b/vl.c @@ -222,6 +222,7 @@ int rtc_td_hack = 0; int usb_enabled = 0; int singlestep = 0; int smp_cpus = 1; +int max_cpus = 0; const char *vnc_display; int acpi_enabled = 1; int no_hpet = 0; @@ -5453,12 +5454,29 @@ int main(int argc, char **argv, char **envp) add_device_config(DEV_GENERIC, optarg); break; case QEMU_OPTION_smp: - smp_cpus = atoi(optarg); + { + char *p; + char option[128]; + smp_cpus = strtol(optarg, &p, 10); if (smp_cpus < 1) { fprintf(stderr, "Invalid number of CPUs\n"); exit(1); } + if (*p++ != ',') + break; + if (get_param_value(option, 128, "maxcpus", p)) + max_cpus = strtol(option, NULL, 0); + if (max_cpus < smp_cpus) { + fprintf(stderr, "maxcpus must be equal to or greater than " + "smp\n"); + exit(1); + } + if (max_cpus > 255) { + fprintf(stderr, "Unsupported number of maxcpus\n"); + exit(1); + } break; + } case QEMU_OPTION_vnc: display_type = DT_VNC; vnc_display = optarg; @@ -5639,6 +5657,13 @@ int main(int argc, char **argv, char **envp) } #endif + /* + * Default to max_cpus = smp_cpus, in case the user doesn't + * specify a max_cpus value. + */ + if (!max_cpus) + max_cpus = smp_cpus; + machine->max_cpus = machine->max_cpus ?: 1; /* Default to UP */ if (smp_cpus > machine->max_cpus) { fprintf(stderr, "Number of SMP cpus requested (%d), exceeds max cpus " -- cgit v1.2.3