Commit b2097003ecad43a34851e57969eadf74181d0080

Authored by aliguori
1 parent 4b32e168

machine struct - specify max_cpus at the per machine level (Jes Sorensen)

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 <jes@sgi.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5443 c046a42c-6fe2-441c-8c8c-71466251a162
hw/an5206.c
... ... @@ -92,4 +92,5 @@ QEMUMachine an5206_machine = {
92 92 .desc = "Arnewsh 5206",
93 93 .init = an5206_init,
94 94 .ram_require = 512,
  95 + .max_cpus = 1,
95 96 };
... ...
hw/boards.h
... ... @@ -18,6 +18,7 @@ typedef struct QEMUMachine {
18 18 ram_addr_t ram_require;
19 19 int nodisk_ok;
20 20 int use_scsi;
  21 + int max_cpus;
21 22 struct QEMUMachine *next;
22 23 } QEMUMachine;
23 24  
... ...
hw/dummy_m68k.c
... ... @@ -66,4 +66,5 @@ QEMUMachine dummy_m68k_machine = {
66 66 .name = "dummy",
67 67 .desc = "Dummy board",
68 68 .init = dummy_m68k_init,
  69 + .max_cpus = 1,
69 70 };
... ...
hw/etraxfs.c
... ... @@ -145,4 +145,5 @@ QEMUMachine bareetraxfs_machine = {
145 145 .desc = "Bare ETRAX FS board",
146 146 .init = bareetraxfs_init,
147 147 .ram_require = 0x8000000,
  148 + .max_cpus = 1,
148 149 };
... ...
hw/gumstix.c
... ... @@ -126,6 +126,7 @@ QEMUMachine connex_machine = {
126 126 .desc = "Gumstix Connex (PXA255)",
127 127 .init = connex_init,
128 128 .ram_require = (0x05000000 + PXA2XX_INTERNAL_SIZE) | RAMSIZE_FIXED,
  129 + .max_cpus = 1,
129 130 };
130 131  
131 132 QEMUMachine verdex_machine = {
... ... @@ -133,4 +134,5 @@ QEMUMachine verdex_machine = {
133 134 .desc = "Gumstix Verdex (PXA270)",
134 135 .init = verdex_init,
135 136 .ram_require = (0x12000000 + PXA2XX_INTERNAL_SIZE) | RAMSIZE_FIXED,
  137 + .max_cpus = 1,
136 138 };
... ...
hw/integratorcp.c
... ... @@ -544,4 +544,5 @@ QEMUMachine integratorcp_machine = {
544 544 .desc = "ARM Integrator/CP (ARM926EJ-S)",
545 545 .init = integratorcp_init,
546 546 .ram_require = 0x100000,
  547 + .max_cpus = 1,
547 548 };
... ...
hw/mainstone.c
... ... @@ -149,4 +149,5 @@ QEMUMachine mainstone2_machine = {
149 149 .init = mainstone_init,
150 150 .ram_require = (MAINSTONE_RAM + MAINSTONE_ROM + 2 * MAINSTONE_FLASH +
151 151 PXA2XX_INTERNAL_SIZE) | RAMSIZE_FIXED,
  152 + .max_cpus = 1,
152 153 };
... ...
hw/mcf5208.c
... ... @@ -309,4 +309,5 @@ QEMUMachine mcf5208evb_machine = {
309 309 .desc = "MCF5206EVB",
310 310 .init = mcf5208evb_init,
311 311 .ram_require = 16384,
  312 + .max_cpus = 1,
312 313 };
... ...
hw/mips_jazz.c
... ... @@ -278,6 +278,7 @@ QEMUMachine mips_magnum_machine = {
278 278 .init = mips_magnum_init,
279 279 .ram_require = MAGNUM_BIOS_SIZE + VGA_RAM_SIZE,
280 280 .nodisk_ok = 1,
  281 + .max_cpus = 1,
281 282 };
282 283  
283 284 QEMUMachine mips_pica61_machine = {
... ... @@ -286,4 +287,5 @@ QEMUMachine mips_pica61_machine = {
286 287 .init = mips_pica61_init,
287 288 .ram_require = MAGNUM_BIOS_SIZE + VGA_RAM_SIZE,
288 289 .nodisk_ok = 1,
  290 + .max_cpus = 1,
289 291 };
... ...
hw/mips_malta.c
... ... @@ -950,4 +950,5 @@ QEMUMachine mips_malta_machine = {
950 950 .init = mips_malta_init,
951 951 .ram_require = VGA_RAM_SIZE + BIOS_SIZE,
952 952 .nodisk_ok = 1,
  953 + .max_cpus = 1,
953 954 };
... ...
hw/mips_mipssim.c
... ... @@ -196,4 +196,5 @@ QEMUMachine mips_mipssim_machine = {
196 196 .init = mips_mipssim_init,
197 197 .ram_require = BIOS_SIZE + VGA_RAM_SIZE /* unused */,
198 198 .nodisk_ok = 1,
  199 + .max_cpus = 1,
199 200 };
... ...
hw/mips_r4k.c
... ... @@ -287,4 +287,5 @@ QEMUMachine mips_machine = {
287 287 .init = mips_r4k_init,
288 288 .ram_require = VGA_RAM_SIZE + BIOS_SIZE,
289 289 .nodisk_ok = 1,
  290 + .max_cpus = 1,
290 291 };
... ...
hw/musicpal.c
... ... @@ -1513,4 +1513,5 @@ QEMUMachine musicpal_machine = {
1513 1513 .desc = "Marvell 88w8618 / MusicPal (ARM926EJ-S)",
1514 1514 .init = musicpal_init,
1515 1515 .ram_require = MP_RAM_DEFAULT_SIZE + MP_SRAM_SIZE + MP_FLASH_SIZE_MAX + RAMSIZE_FIXED,
  1516 + .max_cpus = 1,
1516 1517 };
... ...
hw/nseries.c
... ... @@ -1408,6 +1408,7 @@ QEMUMachine n800_machine = {
1408 1408 .desc = "Nokia N800 tablet aka. RX-34 (OMAP2420)",
1409 1409 .init = n800_init,
1410 1410 .ram_require = (0x08000000 + 0x00010000 + OMAP242X_SRAM_SIZE) | RAMSIZE_FIXED,
  1411 + .max_cpus = 1,
1411 1412 };
1412 1413  
1413 1414 QEMUMachine n810_machine = {
... ... @@ -1415,4 +1416,5 @@ QEMUMachine n810_machine = {
1415 1416 .desc = "Nokia N810 tablet aka. RX-44 (OMAP2420)",
1416 1417 .init = n810_init,
1417 1418 .ram_require = (0x08000000 + 0x00010000 + OMAP242X_SRAM_SIZE) | RAMSIZE_FIXED,
  1419 + .max_cpus = 1,
1418 1420 };
... ...
hw/palm.c
... ... @@ -286,4 +286,5 @@ QEMUMachine palmte_machine = {
286 286 .desc = "Palm Tungsten|E aka. Cheetah PDA (OMAP310)",
287 287 .init = palmte_init,
288 288 .ram_require = (0x02000000 + 0x00800000 + OMAP15XX_SRAM_SIZE) | RAMSIZE_FIXED,
  289 + .max_cpus = 1,
289 290 };
... ...
... ... @@ -1097,6 +1097,7 @@ QEMUMachine pc_machine = {
1097 1097 .desc = "Standard PC",
1098 1098 .init = pc_init_pci,
1099 1099 .ram_require = VGA_RAM_SIZE + PC_MAX_BIOS_SIZE,
  1100 + .max_cpus = 255,
1100 1101 };
1101 1102  
1102 1103 QEMUMachine isapc_machine = {
... ... @@ -1104,4 +1105,5 @@ QEMUMachine isapc_machine = {
1104 1105 .desc = "ISA-only PC",
1105 1106 .init = pc_init_isa,
1106 1107 .ram_require = VGA_RAM_SIZE + PC_MAX_BIOS_SIZE,
  1108 + .max_cpus = 1,
1107 1109 };
... ...
hw/ppc405_boards.c
... ... @@ -359,6 +359,7 @@ QEMUMachine ref405ep_machine = {
359 359 .desc = "ref405ep",
360 360 .init = ref405ep_init,
361 361 .ram_require = (128 * 1024 * 1024 + 4096 + 512 * 1024 + BIOS_SIZE) | RAMSIZE_FIXED,
  362 + .max_cpus = 1,
362 363 };
363 364  
364 365 /*****************************************************************************/
... ...
hw/ppc_chrp.c
... ... @@ -335,4 +335,5 @@ QEMUMachine core99_machine = {
335 335 .desc = "Mac99 based PowerMAC",
336 336 .init = ppc_core99_init,
337 337 .ram_require = BIOS_SIZE + VGA_RAM_SIZE,
  338 + .max_cpus = 1,
338 339 };
... ...
hw/ppc_oldworld.c
... ... @@ -370,4 +370,5 @@ QEMUMachine heathrow_machine = {
370 370 .desc = "Heathrow based PowerMAC",
371 371 .init = ppc_heathrow_init,
372 372 .ram_require = BIOS_SIZE + VGA_RAM_SIZE,
  373 + .max_cpus = 1,
373 374 };
... ...
hw/ppc_prep.c
... ... @@ -762,4 +762,5 @@ QEMUMachine prep_machine = {
762 762 .desc = "PowerPC PREP platform",
763 763 .init = ppc_prep_init,
764 764 .ram_require = BIOS_SIZE + VGA_RAM_SIZE,
  765 + .max_cpus = 1,
765 766 };
... ...
hw/r2d.c
... ... @@ -168,4 +168,5 @@ QEMUMachine r2d_machine = {
168 168 .desc = "r2d-plus board",
169 169 .init = r2d_init,
170 170 .ram_require = SDRAM_SIZE | RAMSIZE_FIXED,
  171 + .max_cpus = 1,
171 172 };
... ...
hw/realview.c
... ... @@ -202,4 +202,5 @@ QEMUMachine realview_machine = {
202 202 .init = realview_init,
203 203 .ram_require = 0x1000,
204 204 .use_scsi = 1,
  205 + .max_cpus = 1,
205 206 };
... ...
hw/shix.c
... ... @@ -112,4 +112,5 @@ QEMUMachine shix_machine = {
112 112 .desc = "shix card",
113 113 .init = shix_init,
114 114 .ram_require = (0x00004000 + 0x01000000 + 0x01000000) | RAMSIZE_FIXED,
  115 + .max_cpus = 1,
115 116 };
... ...
hw/spitz.c
... ... @@ -1014,6 +1014,7 @@ QEMUMachine akitapda_machine = {
1014 1014 .desc = "Akita PDA (PXA270)",
1015 1015 .init = akita_init,
1016 1016 .ram_require = SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE + RAMSIZE_FIXED,
  1017 + .max_cpus = 1,
1017 1018 };
1018 1019  
1019 1020 QEMUMachine spitzpda_machine = {
... ... @@ -1021,6 +1022,7 @@ QEMUMachine spitzpda_machine = {
1021 1022 .desc = "Spitz PDA (PXA270)",
1022 1023 .init = spitz_init,
1023 1024 .ram_require = SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE + RAMSIZE_FIXED,
  1025 + .max_cpus = 1,
1024 1026 };
1025 1027  
1026 1028 QEMUMachine borzoipda_machine = {
... ... @@ -1028,6 +1030,7 @@ QEMUMachine borzoipda_machine = {
1028 1030 .desc = "Borzoi PDA (PXA270)",
1029 1031 .init = borzoi_init,
1030 1032 .ram_require = SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE + RAMSIZE_FIXED,
  1033 + .max_cpus = 1,
1031 1034 };
1032 1035  
1033 1036 QEMUMachine terrierpda_machine = {
... ... @@ -1035,4 +1038,5 @@ QEMUMachine terrierpda_machine = {
1035 1038 .desc = "Terrier PDA (PXA270)",
1036 1039 .init = terrier_init,
1037 1040 .ram_require = SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE + RAMSIZE_FIXED,
  1041 + .max_cpus = 1,
1038 1042 };
... ...
hw/stellaris.c
... ... @@ -1417,6 +1417,7 @@ QEMUMachine lm3s811evb_machine = {
1417 1417 .desc = "Stellaris LM3S811EVB",
1418 1418 .init = lm3s811evb_init,
1419 1419 .ram_require = (64 * 1024 + 8 * 1024) | RAMSIZE_FIXED,
  1420 + .max_cpus = 1,
1420 1421 };
1421 1422  
1422 1423 QEMUMachine lm3s6965evb_machine = {
... ... @@ -1424,4 +1425,5 @@ QEMUMachine lm3s6965evb_machine = {
1424 1425 .desc = "Stellaris LM3S6965EVB",
1425 1426 .init = lm3s6965evb_init,
1426 1427 .ram_require = (256 * 1024 + 64 * 1024) | RAMSIZE_FIXED,
  1428 + .max_cpus = 1,
1427 1429 };
... ...
hw/sun4m.c
... ... @@ -1291,6 +1291,7 @@ QEMUMachine ss5_machine = {
1291 1291 .ram_require = PROM_SIZE_MAX + TCX_SIZE,
1292 1292 .nodisk_ok = 1,
1293 1293 .use_scsi = 1,
  1294 + .max_cpus = 16,
1294 1295 };
1295 1296  
1296 1297 QEMUMachine ss10_machine = {
... ... @@ -1300,6 +1301,7 @@ QEMUMachine ss10_machine = {
1300 1301 .ram_require = PROM_SIZE_MAX + TCX_SIZE,
1301 1302 .nodisk_ok = 1,
1302 1303 .use_scsi = 1,
  1304 + .max_cpus = 16,
1303 1305 };
1304 1306  
1305 1307 QEMUMachine ss600mp_machine = {
... ... @@ -1309,6 +1311,7 @@ QEMUMachine ss600mp_machine = {
1309 1311 .ram_require = PROM_SIZE_MAX + TCX_SIZE,
1310 1312 .nodisk_ok = 1,
1311 1313 .use_scsi = 1,
  1314 + .max_cpus = 16,
1312 1315 };
1313 1316  
1314 1317 QEMUMachine ss20_machine = {
... ... @@ -1318,6 +1321,7 @@ QEMUMachine ss20_machine = {
1318 1321 .ram_require = PROM_SIZE_MAX + TCX_SIZE,
1319 1322 .nodisk_ok = 1,
1320 1323 .use_scsi = 1,
  1324 + .max_cpus = 16,
1321 1325 };
1322 1326  
1323 1327 QEMUMachine ss2_machine = {
... ... @@ -1327,6 +1331,7 @@ QEMUMachine ss2_machine = {
1327 1331 .ram_require = PROM_SIZE_MAX + TCX_SIZE,
1328 1332 .nodisk_ok = 1,
1329 1333 .use_scsi = 1,
  1334 + .max_cpus = 16,
1330 1335 };
1331 1336  
1332 1337 QEMUMachine voyager_machine = {
... ... @@ -1336,6 +1341,7 @@ QEMUMachine voyager_machine = {
1336 1341 .ram_require = PROM_SIZE_MAX + TCX_SIZE,
1337 1342 .nodisk_ok = 1,
1338 1343 .use_scsi = 1,
  1344 + .max_cpus = 16,
1339 1345 };
1340 1346  
1341 1347 QEMUMachine ss_lx_machine = {
... ... @@ -1345,6 +1351,7 @@ QEMUMachine ss_lx_machine = {
1345 1351 .ram_require = PROM_SIZE_MAX + TCX_SIZE,
1346 1352 .nodisk_ok = 1,
1347 1353 .use_scsi = 1,
  1354 + .max_cpus = 16,
1348 1355 };
1349 1356  
1350 1357 QEMUMachine ss4_machine = {
... ... @@ -1354,6 +1361,7 @@ QEMUMachine ss4_machine = {
1354 1361 .ram_require = PROM_SIZE_MAX + TCX_SIZE,
1355 1362 .nodisk_ok = 1,
1356 1363 .use_scsi = 1,
  1364 + .max_cpus = 16,
1357 1365 };
1358 1366  
1359 1367 QEMUMachine scls_machine = {
... ... @@ -1363,6 +1371,7 @@ QEMUMachine scls_machine = {
1363 1371 .ram_require = PROM_SIZE_MAX + TCX_SIZE,
1364 1372 .nodisk_ok = 1,
1365 1373 .use_scsi = 1,
  1374 + .max_cpus = 16,
1366 1375 };
1367 1376  
1368 1377 QEMUMachine sbook_machine = {
... ... @@ -1372,6 +1381,7 @@ QEMUMachine sbook_machine = {
1372 1381 .ram_require = PROM_SIZE_MAX + TCX_SIZE,
1373 1382 .nodisk_ok = 1,
1374 1383 .use_scsi = 1,
  1384 + .max_cpus = 16,
1375 1385 };
1376 1386  
1377 1387 static const struct sun4d_hwdef sun4d_hwdefs[] = {
... ... @@ -1620,6 +1630,7 @@ QEMUMachine ss1000_machine = {
1620 1630 .ram_require = PROM_SIZE_MAX + TCX_SIZE,
1621 1631 .nodisk_ok = 1,
1622 1632 .use_scsi = 1,
  1633 + .max_cpus = 16,
1623 1634 };
1624 1635  
1625 1636 QEMUMachine ss2000_machine = {
... ... @@ -1629,4 +1640,5 @@ QEMUMachine ss2000_machine = {
1629 1640 .ram_require = PROM_SIZE_MAX + TCX_SIZE,
1630 1641 .nodisk_ok = 1,
1631 1642 .use_scsi = 1,
  1643 + .max_cpus = 16,
1632 1644 };
... ...
hw/sun4u.c
... ... @@ -589,6 +589,7 @@ QEMUMachine sun4u_machine = {
589 589 .init = sun4u_init,
590 590 .ram_require = PROM_SIZE_MAX + VGA_RAM_SIZE,
591 591 .nodisk_ok = 1,
  592 + .max_cpus = 16,
592 593 };
593 594  
594 595 QEMUMachine sun4v_machine = {
... ... @@ -597,6 +598,7 @@ QEMUMachine sun4v_machine = {
597 598 .init = sun4v_init,
598 599 .ram_require = PROM_SIZE_MAX + VGA_RAM_SIZE,
599 600 .nodisk_ok = 1,
  601 + .max_cpus = 16,
600 602 };
601 603  
602 604 QEMUMachine niagara_machine = {
... ... @@ -605,4 +607,5 @@ QEMUMachine niagara_machine = {
605 607 .init = niagara_init,
606 608 .ram_require = PROM_SIZE_MAX + VGA_RAM_SIZE,
607 609 .nodisk_ok = 1,
  610 + .max_cpus = 16,
608 611 };
... ...
hw/tosa.c
... ... @@ -123,4 +123,5 @@ QEMUMachine tosapda_machine = {
123 123 .desc = "Tosa PDA (PXA255)",
124 124 .init = tosa_init,
125 125 .ram_require = TOSA_RAM + TOSA_ROM + PXA2XX_INTERNAL_SIZE + RAMSIZE_FIXED,
  126 + .max_cpus = 1,
126 127 };
... ...
hw/versatilepb.c
... ... @@ -320,6 +320,7 @@ QEMUMachine versatilepb_machine = {
320 320 .desc = "ARM Versatile/PB (ARM926EJ-S)",
321 321 .init = vpb_init,
322 322 .use_scsi = 1,
  323 + .max_cpus = 1,
323 324 };
324 325  
325 326 QEMUMachine versatileab_machine = {
... ... @@ -327,4 +328,5 @@ QEMUMachine versatileab_machine = {
327 328 .desc = "ARM Versatile/AB (ARM926EJ-S)",
328 329 .init = vab_init,
329 330 .use_scsi = 1,
  331 + .max_cpus = 1,
330 332 };
... ...
... ... @@ -213,13 +213,6 @@ int usb_enabled = 0;
213 213 static VLANState *first_vlan;
214 214 int smp_cpus = 1;
215 215 const char *vnc_display;
216   -#if defined(TARGET_SPARC)
217   -#define MAX_CPUS 16
218   -#elif defined(TARGET_I386)
219   -#define MAX_CPUS 255
220   -#else
221   -#define MAX_CPUS 1
222   -#endif
223 216 int acpi_enabled = 1;
224 217 int fd_bootchk = 1;
225 218 int no_reboot = 0;
... ... @@ -9195,7 +9188,7 @@ int main(int argc, char **argv)
9195 9188 break;
9196 9189 case QEMU_OPTION_smp:
9197 9190 smp_cpus = atoi(optarg);
9198   - if (smp_cpus < 1 || smp_cpus > MAX_CPUS) {
  9191 + if (smp_cpus < 1) {
9199 9192 fprintf(stderr, "Invalid number of CPUs\n");
9200 9193 exit(1);
9201 9194 }
... ... @@ -9312,6 +9305,13 @@ int main(int argc, char **argv)
9312 9305 }
9313 9306 }
9314 9307  
  9308 + if (smp_cpus > machine->max_cpus) {
  9309 + fprintf(stderr, "Number of SMP cpus requested (%d), exceeds max cpus "
  9310 + "supported by machine `%s' (%d)\n", smp_cpus, machine->name,
  9311 + machine->max_cpus);
  9312 + exit(1);
  9313 + }
  9314 +
9315 9315 if (nographic) {
9316 9316 if (serial_device_index == 0)
9317 9317 serial_devices[0] = "stdio";
... ...