Introduce a max_cpus per-machine variable, allowing individual boards
to limit it's number of CPUs. Check requested number of CPUs in setup
code and exit if it exceeds the supported number for the machine.
This also renders the static MAX_CPUS check obsolete, so remove this
from vl.c.
Signed-off-by: Jes Sorensen <address@hidden>
Index: qemu/hw/an5206.c
===================================================================
--- qemu.orig/hw/an5206.c
+++ qemu/hw/an5206.c
@@ -88,8 +88,9 @@ static void an5206_init(ram_addr_t ram_s
}
QEMUMachine an5206_machine = {
- "an5206",
- "Arnewsh 5206",
- an5206_init,
- 512,
+ .name = "an5206",
+ .desc = "Arnewsh 5206",
+ .init = an5206_init,
+ .ram_require = 512,
+ .max_cpus = 1,
};
Index: qemu/hw/boards.h
===================================================================
--- qemu.orig/hw/boards.h
+++ qemu/hw/boards.h
@@ -16,7 +16,8 @@ typedef struct QEMUMachine {
QEMUMachineInitFunc *init;
#define RAMSIZE_FIXED (1 << 0)
ram_addr_t ram_require;
- int nodisk_ok;
+ short max_cpus;
+ char nodisk_ok;
struct QEMUMachine *next;
} QEMUMachine;
Index: qemu/vl.c
===================================================================
--- qemu.orig/vl.c
+++ qemu/vl.c
@@ -209,13 +209,6 @@ int usb_enabled = 0;
static VLANState *first_vlan;
int smp_cpus = 1;
const char *vnc_display;
-#if defined(TARGET_SPARC)
-#define MAX_CPUS 16
-#elif defined(TARGET_I386)
-#define MAX_CPUS 255
-#else
-#define MAX_CPUS 1
-#endif
int acpi_enabled = 1;
int fd_bootchk = 1;
int no_reboot = 0;
@@ -8772,7 +8765,7 @@ int main(int argc, char **argv)
break;
case QEMU_OPTION_smp:
smp_cpus = atoi(optarg);
- if (smp_cpus < 1 || smp_cpus > MAX_CPUS) {
+ if (smp_cpus < 1) {
fprintf(stderr, "Invalid number of CPUs\n");
exit(1);
}
@@ -8889,6 +8882,13 @@ int main(int argc, char **argv)
}
}
+ if (smp_cpus > machine->max_cpus) {
+ fprintf(stderr, "Number of SMP cpus requested (%d), exceeds max cpus "
+ "supported by machine `%s' (%d)\n", smp_cpus, machine->name,
+ machine->max_cpus);
+ exit(-1);