qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jes Sorensen <jes@sgi.com>
To: Paul Brook <paul@codesourcery.com>
Cc: Anthony Liguori <aliguori@us.ibm.com>, qemu-devel@nongnu.org
Subject: [Qemu-devel] [patch] Introduce per machine based max_cpu variable
Date: Thu, 25 Sep 2008 17:21:05 +0200	[thread overview]
Message-ID: <48DBAC61.9090906@sgi.com> (raw)
In-Reply-To: <200809231404.49340.paul@codesourcery.com>

[-- Attachment #1: Type: text/plain, Size: 1058 bytes --]

Paul Brook wrote:
> On Tuesday 23 September 2008, Jes Sorensen wrote:
>> So what you're saying is that we need to distinguish between number of
>> possible CPUs and how many we allow for a given type of emulation? It
>> seems to me that using MAX_CPUS to be the maximum possible for an
>> architecture is fair and we should then maybe put it into the machine
>> description to set the upper limit for actual runtime ones?
> 
> Something like that, yes.
> 
> Currently there's no real hard limit on the number of CPUs. I'd be nice to 
> keep it that way if possible.

Hi,

Here's an attempt of implementing a per-machine max_cpus variable.
This means developers can limit smp support to match the actual board
sizes. It also makes the static MAX_CPUS check in vl.c obsolete which
I think is a good thing :-)

I think I managed to get the numbers right for all the boards, but my
apologies if I got any of them wrong. It should be easy to fix, as it
will spit out a message explaining why it failed.

Let me know what you think of this approach.

Cheers,
Jes


[-- Attachment #2: 0100-qemu-cpus-per-machine.patch --]
[-- Type: text/plain, Size: 22088 bytes --]

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>

---
 hw/an5206.c        |    9 +++++----
 hw/boards.h        |    3 ++-
 hw/dummy_m68k.c    |    7 ++++---
 hw/etraxfs.c       |    9 +++++----
 hw/gumstix.c       |   18 ++++++++++--------
 hw/integratorcp.c  |    9 +++++----
 hw/mainstone.c     |   11 ++++++-----
 hw/mcf5208.c       |    9 +++++----
 hw/mips_jazz.c     |    2 ++
 hw/mips_malta.c    |    1 +
 hw/mips_mipssim.c  |    1 +
 hw/mips_r4k.c      |    1 +
 hw/musicpal.c      |    9 +++++----
 hw/nseries.c       |   18 ++++++++++--------
 hw/palm.c          |    9 +++++----
 hw/pc.c            |    2 ++
 hw/ppc405_boards.c |    9 +++++----
 hw/ppc_chrp.c      |    9 +++++----
 hw/ppc_oldworld.c  |    9 +++++----
 hw/ppc_prep.c      |    9 +++++----
 hw/r2d.c           |    9 +++++----
 hw/realview.c      |    9 +++++----
 hw/shix.c          |    9 +++++----
 hw/spitz.c         |   36 ++++++++++++++++++++----------------
 hw/stellaris.c     |   18 ++++++++++--------
 hw/sun4m.c         |   12 ++++++++++++
 hw/sun4u.c         |    2 ++
 hw/tosa.c          |    9 +++++----
 hw/versatilepb.c   |   14 ++++++++------
 vl.c               |   16 ++++++++--------
 30 files changed, 169 insertions(+), 119 deletions(-)

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/hw/dummy_m68k.c
===================================================================
--- qemu.orig/hw/dummy_m68k.c
+++ qemu/hw/dummy_m68k.c
@@ -63,7 +63,8 @@ static void dummy_m68k_init(ram_addr_t r
 }
 
 QEMUMachine dummy_m68k_machine = {
-    "dummy",
-    "Dummy board",
-    dummy_m68k_init,
+    .name = "dummy",
+    .desc = "Dummy board",
+    .init = dummy_m68k_init,
+    .max_cpus = 1,
 };
Index: qemu/hw/etraxfs.c
===================================================================
--- qemu.orig/hw/etraxfs.c
+++ qemu/hw/etraxfs.c
@@ -141,8 +141,9 @@ void bareetraxfs_init (ram_addr_t ram_si
 }
 
 QEMUMachine bareetraxfs_machine = {
-    "bareetraxfs",
-    "Bare ETRAX FS board",
-    bareetraxfs_init,
-    0x8000000,
+    .name = "bareetraxfs",
+    .desc = "Bare ETRAX FS board",
+    .init = bareetraxfs_init,
+    .ram_require = 0x8000000,
+    .max_cpus = 1,
 };
Index: qemu/hw/gumstix.c
===================================================================
--- qemu.orig/hw/gumstix.c
+++ qemu/hw/gumstix.c
@@ -122,15 +122,17 @@ static void verdex_init(ram_addr_t ram_s
 }
 
 QEMUMachine connex_machine = {
-    "connex",
-    "Gumstix Connex (PXA255)",
-    connex_init,
-    (0x05000000 + PXA2XX_INTERNAL_SIZE) | RAMSIZE_FIXED,
+    .name = "connex",
+    .desc = "Gumstix Connex (PXA255)",
+    .init = connex_init,
+    .ram_require = (0x05000000 + PXA2XX_INTERNAL_SIZE) | RAMSIZE_FIXED,
+    .max_cpus = 1,
 };
 
 QEMUMachine verdex_machine = {
-    "verdex",
-    "Gumstix Verdex (PXA270)",
-    verdex_init,
-    (0x12000000 + PXA2XX_INTERNAL_SIZE) | RAMSIZE_FIXED,
+    .name = "verdex",
+    .desc = "Gumstix Verdex (PXA270)",
+    .init = verdex_init,
+    .ram_require = (0x12000000 + PXA2XX_INTERNAL_SIZE) | RAMSIZE_FIXED,
+    .max_cpus = 1,
 };
Index: qemu/hw/integratorcp.c
===================================================================
--- qemu.orig/hw/integratorcp.c
+++ qemu/hw/integratorcp.c
@@ -540,8 +540,9 @@ static void integratorcp_init(ram_addr_t
 }
 
 QEMUMachine integratorcp_machine = {
-    "integratorcp",
-    "ARM Integrator/CP (ARM926EJ-S)",
-    integratorcp_init,
-    0x100000,
+    .name = "integratorcp",
+    .desc = "ARM Integrator/CP (ARM926EJ-S)",
+    .init = integratorcp_init,
+    .ram_require = 0x100000,
+    .max_cpus = 1,
 };
Index: qemu/hw/mainstone.c
===================================================================
--- qemu.orig/hw/mainstone.c
+++ qemu/hw/mainstone.c
@@ -144,9 +144,10 @@ static void mainstone_init(ram_addr_t ra
 }
 
 QEMUMachine mainstone2_machine = {
-    "mainstone",
-    "Mainstone II (PXA27x)",
-    mainstone_init,
-    (MAINSTONE_RAM + MAINSTONE_ROM + 2 * MAINSTONE_FLASH +
-     PXA2XX_INTERNAL_SIZE) | RAMSIZE_FIXED,
+    .name = "mainstone",
+    .desc = "Mainstone II (PXA27x)",
+    .init = mainstone_init,
+    .ram_require = (MAINSTONE_RAM + MAINSTONE_ROM + 2 * MAINSTONE_FLASH +
+		    PXA2XX_INTERNAL_SIZE) | RAMSIZE_FIXED,
+    .max_cpus = 1,
 };
Index: qemu/hw/mcf5208.c
===================================================================
--- qemu.orig/hw/mcf5208.c
+++ qemu/hw/mcf5208.c
@@ -305,8 +305,9 @@ static void mcf5208evb_init(ram_addr_t r
 }
 
 QEMUMachine mcf5208evb_machine = {
-    "mcf5208evb",
-    "MCF5206EVB",
-    mcf5208evb_init,
-    16384,
+    .name = "mcf5208evb",
+    .desc = "MCF5206EVB",
+    .init = mcf5208evb_init,
+    .ram_require = 16384,
+    .max_cpus = 1,
 };
Index: qemu/hw/mips_jazz.c
===================================================================
--- qemu.orig/hw/mips_jazz.c
+++ qemu/hw/mips_jazz.c
@@ -277,6 +277,7 @@ QEMUMachine mips_magnum_machine = {
     .desc = "MIPS Magnum",
     .init = mips_magnum_init,
     .ram_require = MAGNUM_BIOS_SIZE + VGA_RAM_SIZE,
+    .max_cpus = 1,
     .nodisk_ok = 1,
 };
 
@@ -285,5 +286,6 @@ QEMUMachine mips_pica61_machine = {
     .desc = "Acer Pica 61",
     .init = mips_pica61_init,
     .ram_require = MAGNUM_BIOS_SIZE + VGA_RAM_SIZE,
+    .max_cpus = 1,
     .nodisk_ok = 1,
 };
Index: qemu/hw/mips_malta.c
===================================================================
--- qemu.orig/hw/mips_malta.c
+++ qemu/hw/mips_malta.c
@@ -950,5 +950,6 @@ QEMUMachine mips_malta_machine = {
     .desc = "MIPS Malta Core LV",
     .init = mips_malta_init,
     .ram_require = VGA_RAM_SIZE + BIOS_SIZE,
+    .max_cpus = 1,
     .nodisk_ok = 1,
 };
Index: qemu/hw/mips_mipssim.c
===================================================================
--- qemu.orig/hw/mips_mipssim.c
+++ qemu/hw/mips_mipssim.c
@@ -195,5 +195,6 @@ QEMUMachine mips_mipssim_machine = {
     .desc = "MIPS MIPSsim platform",
     .init = mips_mipssim_init,
     .ram_require = BIOS_SIZE + VGA_RAM_SIZE /* unused */,
+    .max_cpus = 1,
     .nodisk_ok = 1,
 };
Index: qemu/hw/mips_r4k.c
===================================================================
--- qemu.orig/hw/mips_r4k.c
+++ qemu/hw/mips_r4k.c
@@ -287,5 +287,6 @@ QEMUMachine mips_machine = {
     .desc = "mips r4k platform",
     .init = mips_r4k_init,
     .ram_require = VGA_RAM_SIZE + BIOS_SIZE,
+    .max_cpus = 1,
     .nodisk_ok = 1,
 };
Index: qemu/hw/musicpal.c
===================================================================
--- qemu.orig/hw/musicpal.c
+++ qemu/hw/musicpal.c
@@ -1509,8 +1509,9 @@ static void musicpal_init(ram_addr_t ram
 }
 
 QEMUMachine musicpal_machine = {
-    "musicpal",
-    "Marvell 88w8618 / MusicPal (ARM926EJ-S)",
-    musicpal_init,
-    MP_RAM_DEFAULT_SIZE + MP_SRAM_SIZE + MP_FLASH_SIZE_MAX + RAMSIZE_FIXED
+    .name = "musicpal",
+    .desc = "Marvell 88w8618 / MusicPal (ARM926EJ-S)",
+    .init = musicpal_init,
+    .ram_require = MP_RAM_DEFAULT_SIZE + MP_SRAM_SIZE + MP_FLASH_SIZE_MAX + RAMSIZE_FIXED,
+    .max_cpus = 1,
 };
Index: qemu/hw/nseries.c
===================================================================
--- qemu.orig/hw/nseries.c
+++ qemu/hw/nseries.c
@@ -1392,15 +1392,17 @@ static void n810_init(ram_addr_t ram_siz
 }
 
 QEMUMachine n800_machine = {
-    "n800",
-    "Nokia N800 tablet aka. RX-34 (OMAP2420)",
-    n800_init,
-    (0x08000000 + 0x00010000 + OMAP242X_SRAM_SIZE) | RAMSIZE_FIXED,
+    .name = "n800",
+    .desc = "Nokia N800 tablet aka. RX-34 (OMAP2420)",
+    .init = n800_init,
+    .ram_require = (0x08000000 + 0x00010000 + OMAP242X_SRAM_SIZE) | RAMSIZE_FIXED,
+    .max_cpus = 1,
 };
 
 QEMUMachine n810_machine = {
-    "n810",
-    "Nokia N810 tablet aka. RX-44 (OMAP2420)",
-    n810_init,
-    (0x08000000 + 0x00010000 + OMAP242X_SRAM_SIZE) | RAMSIZE_FIXED,
+    .name = "n810",
+    .desc = "Nokia N810 tablet aka. RX-44 (OMAP2420)",
+    .init = n810_init,
+    .ram_require = (0x08000000 + 0x00010000 + OMAP242X_SRAM_SIZE) | RAMSIZE_FIXED,
+    .max_cpus = 1,
 };
Index: qemu/hw/palm.c
===================================================================
--- qemu.orig/hw/palm.c
+++ qemu/hw/palm.c
@@ -282,8 +282,9 @@ static void palmte_init(ram_addr_t ram_s
 }
 
 QEMUMachine palmte_machine = {
-    "cheetah",
-    "Palm Tungsten|E aka. Cheetah PDA (OMAP310)",
-    palmte_init,
-    (0x02000000 + 0x00800000 + OMAP15XX_SRAM_SIZE) | RAMSIZE_FIXED,
+    .name = "cheetah",
+    .desc = "Palm Tungsten|E aka. Cheetah PDA (OMAP310)",
+    .init = palmte_init,
+    .ram_require = (0x02000000 + 0x00800000 + OMAP15XX_SRAM_SIZE) | RAMSIZE_FIXED,
+    .max_cpus = 1,
 };
Index: qemu/hw/pc.c
===================================================================
--- qemu.orig/hw/pc.c
+++ qemu/hw/pc.c
@@ -1097,6 +1097,7 @@ QEMUMachine pc_machine = {
     .desc = "Standard PC",
     .init = pc_init_pci,
     .ram_require = VGA_RAM_SIZE + PC_MAX_BIOS_SIZE,
+    .max_cpus = 255,
 };
 
 QEMUMachine isapc_machine = {
@@ -1104,4 +1105,5 @@ QEMUMachine isapc_machine = {
     .desc = "ISA-only PC",
     .init = pc_init_isa,
     .ram_require = VGA_RAM_SIZE + PC_MAX_BIOS_SIZE,
+    .max_cpus = 1,
 };
Index: qemu/hw/ppc405_boards.c
===================================================================
--- qemu.orig/hw/ppc405_boards.c
+++ qemu/hw/ppc405_boards.c
@@ -357,10 +357,11 @@ static void ref405ep_init (ram_addr_t ra
 }
 
 QEMUMachine ref405ep_machine = {
-    "ref405ep",
-    "ref405ep",
-    ref405ep_init,
-    (128 * 1024 * 1024 + 4096 + 512 * 1024 + BIOS_SIZE) | RAMSIZE_FIXED,
+    .name = "ref405ep",
+    .desc = "ref405ep",
+    .init = ref405ep_init,
+    .ram_require = (128 * 1024 * 1024 + 4096 + 512 * 1024 + BIOS_SIZE) | RAMSIZE_FIXED,
+    .max_cpus = 1,
 };
 
 /*****************************************************************************/
Index: qemu/hw/ppc_chrp.c
===================================================================
--- qemu.orig/hw/ppc_chrp.c
+++ qemu/hw/ppc_chrp.c
@@ -331,8 +331,9 @@ static void ppc_core99_init (ram_addr_t 
 }
 
 QEMUMachine core99_machine = {
-    "mac99",
-    "Mac99 based PowerMAC",
-    ppc_core99_init,
-    BIOS_SIZE + VGA_RAM_SIZE,
+    .name = "mac99",
+    .desc = "Mac99 based PowerMAC",
+    .init = ppc_core99_init,
+    .ram_require = BIOS_SIZE + VGA_RAM_SIZE,
+    .max_cpus = 1,
 };
Index: qemu/hw/ppc_oldworld.c
===================================================================
--- qemu.orig/hw/ppc_oldworld.c
+++ qemu/hw/ppc_oldworld.c
@@ -366,8 +366,9 @@ static void ppc_heathrow_init (ram_addr_
 }
 
 QEMUMachine heathrow_machine = {
-    "g3bw",
-    "Heathrow based PowerMAC",
-    ppc_heathrow_init,
-    BIOS_SIZE + VGA_RAM_SIZE,
+    .name = "g3bw",
+    .desc = "Heathrow based PowerMAC",
+    .init = ppc_heathrow_init,
+    .ram_require = BIOS_SIZE + VGA_RAM_SIZE,
+    .max_cpus = 1,
 };
Index: qemu/hw/ppc_prep.c
===================================================================
--- qemu.orig/hw/ppc_prep.c
+++ qemu/hw/ppc_prep.c
@@ -760,8 +760,9 @@ static void ppc_prep_init (ram_addr_t ra
 }
 
 QEMUMachine prep_machine = {
-    "prep",
-    "PowerPC PREP platform",
-    ppc_prep_init,
-    BIOS_SIZE + VGA_RAM_SIZE,
+    .name = "prep",
+    .desc = "PowerPC PREP platform",
+    .init = ppc_prep_init,
+    .ram_require = BIOS_SIZE + VGA_RAM_SIZE,
+    .max_cpus = 1,
 };
Index: qemu/hw/r2d.c
===================================================================
--- qemu.orig/hw/r2d.c
+++ qemu/hw/r2d.c
@@ -164,8 +164,9 @@ static void r2d_init(ram_addr_t ram_size
 }
 
 QEMUMachine r2d_machine = {
-    "r2d",
-    "r2d-plus board",
-    r2d_init,
-    SDRAM_SIZE | RAMSIZE_FIXED
+    .name = "r2d",
+    .desc = "r2d-plus board",
+    .init = r2d_init,
+    .ram_require = SDRAM_SIZE | RAMSIZE_FIXED,
+    .max_cpus = 1,
 };
Index: qemu/hw/realview.c
===================================================================
--- qemu.orig/hw/realview.c
+++ qemu/hw/realview.c
@@ -197,8 +197,9 @@ static void realview_init(ram_addr_t ram
 }
 
 QEMUMachine realview_machine = {
-    "realview",
-    "ARM RealView Emulation Baseboard (ARM926EJ-S)",
-    realview_init,
-    0x1000
+    .name = "realview",
+    .desc = "ARM RealView Emulation Baseboard (ARM926EJ-S)",
+    .init = realview_init,
+    .ram_require = 0x1000,
+    .max_cpus = 1,
 };
Index: qemu/hw/shix.c
===================================================================
--- qemu.orig/hw/shix.c
+++ qemu/hw/shix.c
@@ -108,8 +108,9 @@ static void shix_init(ram_addr_t ram_siz
 }
 
 QEMUMachine shix_machine = {
-    "shix",
-    "shix card",
-    shix_init,
-    (0x00004000 + 0x01000000 + 0x01000000) | RAMSIZE_FIXED
+    .name = "shix",
+    .desc = "shix card",
+    .init = shix_init,
+    .ram_require = (0x00004000 + 0x01000000 + 0x01000000) | RAMSIZE_FIXED,
+    .max_cpus = 1,
 };
Index: qemu/hw/spitz.c
===================================================================
--- qemu.orig/hw/spitz.c
+++ qemu/hw/spitz.c
@@ -1010,29 +1010,33 @@ static void terrier_init(ram_addr_t ram_
 }
 
 QEMUMachine akitapda_machine = {
-    "akita",
-    "Akita PDA (PXA270)",
-    akita_init,
-    SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE + RAMSIZE_FIXED,
+    .name = "akita",
+    .desc = "Akita PDA (PXA270)",
+    .init = akita_init,
+    .ram_require = SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE + RAMSIZE_FIXED,
+    .max_cpus = 1,
 };
 
 QEMUMachine spitzpda_machine = {
-    "spitz",
-    "Spitz PDA (PXA270)",
-    spitz_init,
-    SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE + RAMSIZE_FIXED,
+    .name = "spitz",
+    .desc = "Spitz PDA (PXA270)",
+    .init = spitz_init,
+    .ram_require = SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE + RAMSIZE_FIXED,
+    .max_cpus = 1,
 };
 
 QEMUMachine borzoipda_machine = {
-    "borzoi",
-    "Borzoi PDA (PXA270)",
-    borzoi_init,
-    SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE + RAMSIZE_FIXED,
+    .name = "borzoi",
+    .desc = "Borzoi PDA (PXA270)",
+    .init = borzoi_init,
+    .ram_require = SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE + RAMSIZE_FIXED,
+    .max_cpus = 1,
 };
 
 QEMUMachine terrierpda_machine = {
-    "terrier",
-    "Terrier PDA (PXA270)",
-    terrier_init,
-    SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE + RAMSIZE_FIXED,
+    .name = "terrier",
+    .desc = "Terrier PDA (PXA270)",
+    .init = terrier_init,
+    .ram_require = SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE + RAMSIZE_FIXED,
+    .max_cpus = 1,
 };
Index: qemu/hw/stellaris.c
===================================================================
--- qemu.orig/hw/stellaris.c
+++ qemu/hw/stellaris.c
@@ -1413,15 +1413,17 @@ static void lm3s6965evb_init(ram_addr_t 
 }
 
 QEMUMachine lm3s811evb_machine = {
-    "lm3s811evb",
-    "Stellaris LM3S811EVB",
-    lm3s811evb_init,
-    (64 * 1024 + 8 * 1024) | RAMSIZE_FIXED,
+    .name = "lm3s811evb",
+    .desc = "Stellaris LM3S811EVB",
+    .init = lm3s811evb_init,
+    .ram_require = (64 * 1024 + 8 * 1024) | RAMSIZE_FIXED,
+    .max_cpus = 1,
 };
 
 QEMUMachine lm3s6965evb_machine = {
-    "lm3s6965evb",
-    "Stellaris LM3S6965EVB",
-    lm3s6965evb_init,
-    (256 * 1024 + 64 * 1024) | RAMSIZE_FIXED,
+    .name = "lm3s6965evb",
+    .desc = "Stellaris LM3S6965EVB",
+    .init = lm3s6965evb_init,
+    .ram_require = (256 * 1024 + 64 * 1024) | RAMSIZE_FIXED,
+    .max_cpus = 1,
 };
Index: qemu/hw/sun4m.c
===================================================================
--- qemu.orig/hw/sun4m.c
+++ qemu/hw/sun4m.c
@@ -1291,6 +1291,7 @@ QEMUMachine ss5_machine = {
     .desc = "Sun4m platform, SPARCstation 5",
     .init = ss5_init,
     .ram_require = PROM_SIZE_MAX + TCX_SIZE,
+    .max_cpus = 16,
     .nodisk_ok = 1,
 };
 
@@ -1299,6 +1300,7 @@ QEMUMachine ss10_machine = {
     .desc = "Sun4m platform, SPARCstation 10",
     .init = ss10_init,
     .ram_require = PROM_SIZE_MAX + TCX_SIZE,
+    .max_cpus = 16,
     .nodisk_ok = 1,
 };
 
@@ -1307,6 +1309,7 @@ QEMUMachine ss600mp_machine = {
     .desc = "Sun4m platform, SPARCserver 600MP",
     .init = ss600mp_init,
     .ram_require = PROM_SIZE_MAX + TCX_SIZE,
+    .max_cpus = 16,
     .nodisk_ok = 1,
 };
 
@@ -1315,6 +1318,7 @@ QEMUMachine ss20_machine = {
     .desc = "Sun4m platform, SPARCstation 20",
     .init = ss20_init,
     .ram_require = PROM_SIZE_MAX + TCX_SIZE,
+    .max_cpus = 16,
     .nodisk_ok = 1,
 };
 
@@ -1323,6 +1327,7 @@ QEMUMachine ss2_machine = {
     .desc = "Sun4c platform, SPARCstation 2",
     .init = ss2_init,
     .ram_require = PROM_SIZE_MAX + TCX_SIZE,
+    .max_cpus = 16,
     .nodisk_ok = 1,
 };
 
@@ -1331,6 +1336,7 @@ QEMUMachine voyager_machine = {
     .desc = "Sun4m platform, SPARCstation Voyager",
     .init = vger_init,
     .ram_require = PROM_SIZE_MAX + TCX_SIZE,
+    .max_cpus = 16,
     .nodisk_ok = 1,
 };
 
@@ -1339,6 +1345,7 @@ QEMUMachine ss_lx_machine = {
     .desc = "Sun4m platform, SPARCstation LX",
     .init = ss_lx_init,
     .ram_require = PROM_SIZE_MAX + TCX_SIZE,
+    .max_cpus = 16,
     .nodisk_ok = 1,
 };
 
@@ -1347,6 +1354,7 @@ QEMUMachine ss4_machine = {
     .desc = "Sun4m platform, SPARCstation 4",
     .init = ss4_init,
     .ram_require = PROM_SIZE_MAX + TCX_SIZE,
+    .max_cpus = 16,
     .nodisk_ok = 1,
 };
 
@@ -1355,6 +1363,7 @@ QEMUMachine scls_machine = {
     .desc = "Sun4m platform, SPARCClassic",
     .init = scls_init,
     .ram_require = PROM_SIZE_MAX + TCX_SIZE,
+    .max_cpus = 16,
     .nodisk_ok = 1,
 };
 
@@ -1363,6 +1372,7 @@ QEMUMachine sbook_machine = {
     .desc = "Sun4m platform, SPARCbook",
     .init = sbook_init,
     .ram_require = PROM_SIZE_MAX + TCX_SIZE,
+    .max_cpus = 16,
     .nodisk_ok = 1,
 };
 
@@ -1610,6 +1620,7 @@ QEMUMachine ss1000_machine = {
     .desc = "Sun4d platform, SPARCserver 1000",
     .init = ss1000_init,
     .ram_require = PROM_SIZE_MAX + TCX_SIZE,
+    .max_cpus = 16,
     .nodisk_ok = 1,
 };
 
@@ -1618,5 +1629,6 @@ QEMUMachine ss2000_machine = {
     .desc = "Sun4d platform, SPARCcenter 2000",
     .init = ss2000_init,
     .ram_require = PROM_SIZE_MAX + TCX_SIZE,
+    .max_cpus = 16,
     .nodisk_ok = 1,
 };
Index: qemu/hw/sun4u.c
===================================================================
--- qemu.orig/hw/sun4u.c
+++ qemu/hw/sun4u.c
@@ -522,6 +522,7 @@ QEMUMachine sun4u_machine = {
     .desc = "Sun4u platform",
     .init = sun4u_init,
     .ram_require = PROM_SIZE_MAX + VGA_RAM_SIZE,
+    .max_cpus = 16,
     .nodisk_ok = 1,
 };
 
@@ -530,5 +531,6 @@ QEMUMachine sun4v_machine = {
     .desc = "Sun4v platform",
     .init = sun4v_init,
     .ram_require = PROM_SIZE_MAX + VGA_RAM_SIZE,
+    .max_cpus = 16,
     .nodisk_ok = 1,
 };
Index: qemu/hw/tosa.c
===================================================================
--- qemu.orig/hw/tosa.c
+++ qemu/hw/tosa.c
@@ -119,8 +119,9 @@ static void tosa_init(ram_addr_t ram_siz
 }
 
 QEMUMachine tosapda_machine = {
-    "tosa",
-    "Tosa PDA (PXA255)",
-    tosa_init,
-    TOSA_RAM + TOSA_ROM + PXA2XX_INTERNAL_SIZE + RAMSIZE_FIXED,
+    .name = "tosa",
+    .desc = "Tosa PDA (PXA255)",
+    .init = tosa_init,
+    .ram_require = TOSA_RAM + TOSA_ROM + PXA2XX_INTERNAL_SIZE + RAMSIZE_FIXED,
+    .max_cpus = 1,
 };
Index: qemu/hw/versatilepb.c
===================================================================
--- qemu.orig/hw/versatilepb.c
+++ qemu/hw/versatilepb.c
@@ -316,13 +316,15 @@ static void vab_init(ram_addr_t ram_size
 }
 
 QEMUMachine versatilepb_machine = {
-    "versatilepb",
-    "ARM Versatile/PB (ARM926EJ-S)",
-    vpb_init,
+    .name = "versatilepb",
+    .desc = "ARM Versatile/PB (ARM926EJ-S)",
+    .init = vpb_init,
+    .max_cpus = 1,
 };
 
 QEMUMachine versatileab_machine = {
-    "versatileab",
-    "ARM Versatile/AB (ARM926EJ-S)",
-    vab_init,
+    .name = "versatileab",
+    .desc = "ARM Versatile/AB (ARM926EJ-S)",
+    .init = vab_init,
+    .max_cpus = 1,
 };
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);
+    }
+
     if (nographic) {
        if (serial_device_index == 0)
            serial_devices[0] = "stdio";

  parent reply	other threads:[~2008-09-25 15:21 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-23 11:44 [Qemu-devel] [patch] move MAX_CPUS to cpu.h Jes Sorensen
2008-09-23 12:08 ` Paul Brook
2008-09-23 12:10   ` Jes Sorensen
2008-09-23 12:50     ` Paul Brook
2008-09-23 12:53       ` Jes Sorensen
2008-09-23 13:04         ` Paul Brook
2008-09-23 13:10           ` Jes Sorensen
2008-09-25 15:21           ` Jes Sorensen [this message]
2008-09-30 14:47             ` [Qemu-devel] [patch] Introduce per machine based max_cpu variable Anthony Liguori
2008-09-30 15:06               ` Jes Sorensen
2008-09-30 15:18                 ` Anthony Liguori
2008-10-01 13:22                   ` Jes Sorensen
2008-09-30 15:19               ` Jes Sorensen
2008-10-02 15:45             ` Paul Brook
2008-10-03  9:40               ` Jes Sorensen
2008-09-23 14:13       ` [Qemu-devel] [patch] move MAX_CPUS to cpu.h M. Warner Losh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48DBAC61.9090906@sgi.com \
    --to=jes@sgi.com \
    --cc=aliguori@us.ibm.com \
    --cc=paul@codesourcery.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).