move MAX_CPUS to cpu.h
PATCH 1/1 move MAX_CPUS to cpu.h
Hi,
In order to allow for other structs to be sized based on MAX_CPUS and get rid of some ifdef clutter, I'd like to suggest this patch.
Cheers,
Jes
Move definition of MAX_CPUS from vl.c to architecture specific cpu.h header file. This reduces #ifdef clutter and allows for other files to define array sizes based on MAX_CPUS, which is needed for KVM and probably other places.
--- hw/ppc_mac.h | 3 --- target-alpha/cpu.h | 2 ++ target-arm/cpu.h | 2 ++ target-cris/cpu.h | 2 ++ target-i386/cpu.h | 2 ++ target-m68k/cpu.h | 2 ++ target-mips/cpu.h | 2 ++ target-ppc/cpu.h | 2 ++ target-sh4/cpu.h | 2 ++ target-sparc/cpu.h | 2 ++ vl.c | 7 ------- 11 files changed, 18 insertions(+), 10 deletions(-)
hw/ppc_mac.h +0 -3
@@ -25,9 +25,6 @@#if !defined(__PPC_MAC_H__)#define __PPC_MAC_H__ -/* SMP is not enabled, for now */ -#define MAX_CPUS 1 -#define BIOS_FILENAME "ppc_rom.bin"#define VGABIOS_FILENAME "video.x"#define NVRAM_SIZE 0x2000
target-alpha/cpu.h +2 -0
@@ -25,6 +25,8 @@#define TARGET_LONG_BITS 64 +#define MAX_CPUS 1 +#include "cpu-defs.h" #include <setjmp.h>
target-arm/cpu.h +2 -0
@@ -22,6 +22,8 @@#define TARGET_LONG_BITS 32 +#define MAX_CPUS 1 +#define ELF_MACHINE EM_ARM#include "cpu-defs.h"
target-cris/cpu.h +2 -0
@@ -23,6 +23,8 @@#define TARGET_LONG_BITS 32 +#define MAX_CPUS 1 +#include "cpu-defs.h" #define TARGET_HAS_ICE 1
target-i386/cpu.h +2 -0
@@ -22,6 +22,8 @@#include "config.h" +#define MAX_CPUS 255 +#ifdef TARGET_X86_64 #define TARGET_LONG_BITS 64#else
target-m68k/cpu.h +2 -0
@@ -23,6 +23,8 @@#define TARGET_LONG_BITS 32 +#define MAX_CPUS 1 +#include "cpu-defs.h" #include "softfloat.h"
target-mips/cpu.h +2 -0
@@ -3,6 +3,8 @@#define TARGET_HAS_ICE 1 +#define MAX_CPUS 1 +#define ELF_MACHINE EM_MIPS#include "config.h"
target-ppc/cpu.h +2 -0
@@ -23,6 +23,8 @@#include "config.h" #include <inttypes.h> +#define MAX_CPUS 1 +//#define PPC_EMULATE_32BITS_HYPV #if defined (TARGET_PPC64 )
target-sh4/cpu.h +2 -0
@@ -22,6 +22,8 @@#include "config.h" +#define MAX_CPUS 1 +#define TARGET_LONG_BITS 32#define TARGET_HAS_ICE 1
target-sparc/cpu.h +2 -0
@@ -3,6 +3,8 @@#include "config.h" +#define MAX_CPUS 16 +#if !defined(TARGET_SPARC64 )#define TARGET_LONG_BITS 32#define TARGET_FPREGS 32
vl.c +0 -7
@@ -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 ;
target-arm/cpu.h
Quoted 5 lines · Jes Sorensen
Index:
qemu/target-arm/cpu.h
===================================================================target-arm/cpu.h +1
-0+#define MAX_CPUS 1
Anything using the value to allocate per-cpu structures will be wrong.
Paul
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Paul" == Paul Brook <[email protected]> writes:
Quoted 4 lines · Jes Sorensen
Quoted 4 lines
Index:
qemu/target-arm/cpu.h
===================================================================
---qemu.orig/target-arm/cpu.h+++qemu/target-arm/cpu.h+#defineMAX_CPUS1
Paul> Anything using the value to allocate per-cpu structures will be Paul> wrong.
What do you mean? There's plenty places where you will want to only allocate enough space for the number of cpus you want to support.
Jes
Quoted 8 lines · Jes Sorensen
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Paul" == Paul Brook <[email protected]> writes:
Quoted 4 lines · Jes Sorensen
Quoted 4 lines
Index:
qemu/target-arm/cpu.h
===================================================================
---qemu.orig/target-arm/cpu.h+++qemu/target-arm/cpu.h+#defineMAX_CPUS1
Quoted 5 lines
Paul> Anything using the value to allocate per-cpu structures will be Paul> wrong.
What do you mean? There's plenty places where you will want to only allocate enough space for the number of cpus you want to support.
Some ARM boards have 4 cpus, they just don't use the -smp option.
Paul
Quoted 8 lines · Paul Brook
Quoted 5 lines · Jes Sorensen
Paul> Anything using the value to allocate per-cpu structures will be Paul> wrong.
What do you mean? There's plenty places where you will want to only allocate enough space for the number of cpus you want to support.
Some ARM boards have 4 cpus, they just don't use the -smp option.
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?
Cheers,
Jes
Quoted 8 lines · Jes Sorensen
Quoted 7 lines · Paul Brook
Quoted 5 lines · Jes Sorensen
Paul> Anything using the value to allocate per-cpu structures will be Paul> wrong.
What do you mean? There's plenty places where you will want to only allocate enough space for the number of cpus you want to support.
Quoted 7 lines
Quoted 1 line
Some ARM boards have 4 cpus, they just don't use the -smp option.
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_CPUSto 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.
Paul
Quoted 10 lines · Paul Brook
Quoted 5 lines · Jes Sorensen
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_CPUSto 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.
Hmmmm I'll take a look and see what I can come up with. The machine struct seems the right place for the runtime limit I think.
I think realistically speaking there will be hard limits on CPUs, but we can put them at reasonable limits (most people, except for me, would probably not complain being capped at 256 :-). It's of course possible to completely get rid of long term, but there could be issues with runtime allocation cost in hot paths.
Cheers,
Jes
In message: <[email protected]>
Paul Brook <[email protected]> writes:
: Some ARM boards have 4 cpus, they just don't use the -smp option.
Speaking of multiple CPUs and embedded architectures...
Is anybody working on any freescale PowerPC emulation, including their newer multicore CPUs like the 8572?
Warner
PATCH 1/1 Introduce per machine based max_cpu variable
In reply to Paul BrookQuoted 10 lines · Paul Brook
Quoted 5 lines · Jes Sorensen
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_CPUSto 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
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.
--- 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(-)
hw/an5206.c +5 -4
@@ -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 , };
hw/boards.h +2 -1
@@ -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;
hw/dummy_m68k.c +4 -3
@@ -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 , };
hw/etraxfs.c +5 -4
@@ -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 , };
hw/gumstix.c +10 -8
@@ -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 , };
hw/integratorcp.c +5 -4
@@ -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 , };
hw/mainstone.c +6 -5
@@ -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 , };
hw/mcf5208.c +5 -4
@@ -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 , };
hw/mips_jazz.c +2 -0
@@ -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, };
hw/mips_malta.c +1 -0
@@ -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, };
hw/mips_mipssim.c +1 -0
@@ -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, };
hw/mips_r4k.c +1 -0
@@ -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, };
hw/musicpal.c +5 -4
@@ -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 , };
hw/nseries.c +10 -8
@@ -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 , };
hw/palm.c +5 -4
@@ -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 , };
hw/pc.c +2 -0
@@ -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, };
hw/ppc405_boards.c +5 -4
@@ -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 , };/*****************************************************************************/
hw/ppc_chrp.c +5 -4
@@ -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 , };
hw/ppc_oldworld.c +5 -4
@@ -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 , };
hw/ppc_prep.c +5 -4
@@ -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 , };
hw/r2d.c +5 -4
@@ -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 , };
hw/realview.c +5 -4
@@ -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 , };
hw/shix.c +5 -4
@@ -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 , };
hw/spitz.c +20 -16
@@ -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 , };
hw/stellaris.c +10 -8
@@ -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 , };
hw/sun4m.c +12 -0
@@ -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, };
hw/sun4u.c +2 -0
@@ -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, };
hw/tosa.c +5 -4
@@ -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 , };
hw/versatilepb.c +8 -6
@@ -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 , };
vl.c +8 -8
@@ -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" ;
Re: [Qemu-devel] [patch] Introduce per machine based max_cpu variable
Quoted 18 lines · Jes Sorensen
Introduce a
max_cpusper-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 staticMAX_CPUScheck obsolete, so remove this fromvl.c.Signed-off-by Jes Sorensen <[email protected]>Index:
qemu/hw/an5206.c
===================================================================hw/an5206.c +0
-0@@ -88,8 +88,9 @@ static void an5206_init(ram_addr_t ram_s }QEMUMachine an5206_machine = {
hw/an5206.c static void an5206_init(ram_addr_t ram_s · line 96
Quoted 10 lines
hw/an5206.c +5
-4-"an5206" , -"Arnewsh 5206" , - an5206_init, - 512, + .name = "an5206", + .desc = "Arnewsh 5206", + .init = an5206_init, + .ram_require = 512, + .max_cpus = 1, };
Your change would be greatly simplified if you defined max_cpus to be such that it was the maximum number of vcpus - 1.
Then the default value of 0 would be sufficient for most machine types.
Quoted 5 lines
Index:
qemu/hw/boards.h
===================================================================
hw/boards.h typedef struct QEMUMachine { · line 23
Quoted 9 lines
hw/boards.h +2
-1@@ -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;
Just use int and please don't change nodisk_ok to char.
Quoted 28 lines
Index:
qemu/vl.c
===================================================================vl.c +1
-8@@ -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 ); }
vl.c int main(int argc, char **argv) · line 8890
Quoted 9 lines
vl.c +5
-0@@ -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 );
exit() should be passed something between 0 and 255. WEXITSTATUS always returns the least significant 8 bits so the result will always be 0..255. Moreover, by convention in QEMU we usually exit(1), not exit(-1).
Regards,
Anthony Liguori
Re: [Qemu-devel] [patch] Introduce per machine based max_cpu variable
Quoted 9 lines
Quoted 9 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Anthony" == Anthony Liguori <[email protected]> writes:
Index:
qemu/hw/an5206.c
===================================================================
---qemu.orig/hw/an5206.c+++qemu/hw/an5206.c@@ -88,8 +88,9 @@ static void an5206_init(ram_addr_tram_s} QEMUMachinean5206_machine= { - "an5206", - "Arnewsh 5206", -an5206_init, - 512, + .name = "an5206", + .desc = "Arnewsh 5206", + .init =an5206_init, + .ram_require = 512, + .max_cpus = 1, };
Anthony> Your change would be greatly simplified if you defined Anthony> max_cpus to be such that it was the maximum number of vcpus - Anthony> 1.
Anthony> Then the default value of 0 would be sufficient for most Anthony> machine types.
Hi Anthony,
I thought about this, but I think it's a really bad idea. It will cause confusion over time and I think it is quite reasonable to require all machines to define the maximum number of CPUs they support. Thats why I defined the error message so it was quite easy for anyone to fixup in case I got one of them wrong.
I really think it's better to do this right than hack it.
One option would be to spit out an error asking people to fix zero into '1' and then let zero mean 1 for a while, but I don't think it's worth the overhead.
Quoted 7 lines
Quoted 7 lines
Index:
qemu/hw/boards.h
===================================================================
---qemu.orig/hw/boards.h+++qemu/hw/boards.h@@ -16,7 +16,8 @@ typedef struct QEMUMachine { QEMUMachineInitFunc *init; #defineRAMSIZE_FIXED(1 << 0)ram_addr_tram_require; - intnodisk_ok; + shortmax_cpus; + charnodisk_ok; struct QEMUMachine *next; } QEMUMachine;
Anthony> Just use int and please don't change nodisk_ok to char.
I did this to avoid making the structure grow. nodisk_ok is just a true/false flag and I think even SGI has no plans to grow beyond 16 bit CPU count numbers.
I don't mind keeping both as int, I just thought it was silly to waste the space for zero gain. Anyway, I'll make the change to the patch.
Anthony> exit() should be passed something between 0 and 255. Anthony> WEXITSTATUS always returns the least significant 8 bits so Anthony> the result will always be 0..255. Moreover, by convention in Anthony> QEMU we usually exit(1), not exit(-1).
I'll fix this - I am 99.999% sure I copied the exit(-1) from somewhere else in the code though :-)
cheers,
Jes
Re: [Qemu-devel] [patch] Introduce per machine based max_cpu variable
In reply to Anthony LiguoriHi,
Here's an updated version of the patch. I have changed it to use int for nodisk_ok and max_cpus as you requested and changed the exit() to use exit(1) instead.
I will still argue that it is more correct to require all machines to specify the number of max_cpus. It really should be easy to fix up any possible case I messed up (which I hope I didn't).
Cheers,
Jes
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.
--- hw/an5206.c | 9 +++++---- hw/boards.h | 1 + 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, 168 insertions(+), 118 deletions(-)
hw/an5206.c +5 -4
@@ -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 , };
hw/boards.h +1 -0
@@ -17,6 +17,7 @@ typedef struct QEMUMachine {#define RAMSIZE_FIXED (1 << 0)ram_addr_t ram_require;int nodisk_ok; +int max_cpus;struct QEMUMachine *next; } QEMUMachine;
hw/dummy_m68k.c +4 -3
@@ -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 , };
hw/etraxfs.c +5 -4
@@ -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 , };
hw/gumstix.c +10 -8
@@ -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 , };
hw/integratorcp.c +5 -4
@@ -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 , };
hw/mainstone.c +6 -5
@@ -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 , };
hw/mcf5208.c +5 -4
@@ -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 , };
hw/mips_jazz.c +2 -0
@@ -278,6 +278,7 @@ QEMUMachine mips_magnum_machine = { .init = mips_magnum_init, .ram_require = MAGNUM_BIOS_SIZE + VGA_RAM_SIZE, .nodisk_ok = 1, + .max_cpus = 1, };QEMUMachine mips_pica61_machine = {
@@ -286,4 +287,5 @@ QEMUMachine mips_pica61_machine = { .init = mips_pica61_init, .ram_require = MAGNUM_BIOS_SIZE + VGA_RAM_SIZE, .nodisk_ok = 1, + .max_cpus = 1, };
hw/mips_malta.c +1 -0
@@ -951,4 +951,5 @@ QEMUMachine mips_malta_machine = { .init = mips_malta_init, .ram_require = VGA_RAM_SIZE + BIOS_SIZE, .nodisk_ok = 1, + .max_cpus = 1, };
hw/mips_mipssim.c +1 -0
@@ -196,4 +196,5 @@ QEMUMachine mips_mipssim_machine = { .init = mips_mipssim_init, .ram_require = BIOS_SIZE + VGA_RAM_SIZE /* unused */, .nodisk_ok = 1, + .max_cpus = 1, };
hw/mips_r4k.c +1 -0
@@ -288,4 +288,5 @@ QEMUMachine mips_machine = { .init = mips_r4k_init, .ram_require = VGA_RAM_SIZE + BIOS_SIZE, .nodisk_ok = 1, + .max_cpus = 1, };
hw/musicpal.c +5 -4
@@ -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 , };
hw/nseries.c +10 -8
@@ -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 , };
hw/palm.c +5 -4
@@ -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 , };
hw/pc.c +2 -0
@@ -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, };
hw/ppc405_boards.c +5 -4
@@ -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 , };/*****************************************************************************/
hw/ppc_chrp.c +5 -4
@@ -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 , };
hw/ppc_oldworld.c +5 -4
@@ -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 , };
hw/ppc_prep.c +5 -4
@@ -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 , };
hw/r2d.c +5 -4
@@ -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 , };
hw/realview.c +5 -4
@@ -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 , };
hw/shix.c +5 -4
@@ -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 , };
hw/spitz.c +20 -16
@@ -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 , };
hw/stellaris.c +10 -8
@@ -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 , };
hw/sun4m.c +12 -0
@@ -1292,6 +1292,7 @@ QEMUMachine ss5_machine = { .init = ss5_init, .ram_require = PROM_SIZE_MAX + TCX_SIZE, .nodisk_ok = 1, + .max_cpus = 16, };QEMUMachine ss10_machine = {
@@ -1300,6 +1301,7 @@ QEMUMachine ss10_machine = { .init = ss10_init, .ram_require = PROM_SIZE_MAX + TCX_SIZE, .nodisk_ok = 1, + .max_cpus = 16, };QEMUMachine ss600mp_machine = {
@@ -1308,6 +1310,7 @@ QEMUMachine ss600mp_machine = { .init = ss600mp_init, .ram_require = PROM_SIZE_MAX + TCX_SIZE, .nodisk_ok = 1, + .max_cpus = 16, };QEMUMachine ss20_machine = {
@@ -1316,6 +1319,7 @@ QEMUMachine ss20_machine = { .init = ss20_init, .ram_require = PROM_SIZE_MAX + TCX_SIZE, .nodisk_ok = 1, + .max_cpus = 16, };QEMUMachine ss2_machine = {
@@ -1324,6 +1328,7 @@ QEMUMachine ss2_machine = { .init = ss2_init, .ram_require = PROM_SIZE_MAX + TCX_SIZE, .nodisk_ok = 1, + .max_cpus = 16, };QEMUMachine voyager_machine = {
@@ -1332,6 +1337,7 @@ QEMUMachine voyager_machine = { .init = vger_init, .ram_require = PROM_SIZE_MAX + TCX_SIZE, .nodisk_ok = 1, + .max_cpus = 16, };QEMUMachine ss_lx_machine = {
@@ -1340,6 +1346,7 @@ QEMUMachine ss_lx_machine = { .init = ss_lx_init, .ram_require = PROM_SIZE_MAX + TCX_SIZE, .nodisk_ok = 1, + .max_cpus = 16, };QEMUMachine ss4_machine = {
@@ -1348,6 +1355,7 @@ QEMUMachine ss4_machine = { .init = ss4_init, .ram_require = PROM_SIZE_MAX + TCX_SIZE, .nodisk_ok = 1, + .max_cpus = 16, };QEMUMachine scls_machine = {
@@ -1356,6 +1364,7 @@ QEMUMachine scls_machine = { .init = scls_init, .ram_require = PROM_SIZE_MAX + TCX_SIZE, .nodisk_ok = 1, + .max_cpus = 16, };QEMUMachine sbook_machine = {
@@ -1364,6 +1373,7 @@ QEMUMachine sbook_machine = { .init = sbook_init, .ram_require = PROM_SIZE_MAX + TCX_SIZE, .nodisk_ok = 1, + .max_cpus = 16, };static const struct sun4d_hwdef sun4d_hwdefs[] = {
@@ -1611,6 +1621,7 @@ QEMUMachine ss1000_machine = { .init = ss1000_init, .ram_require = PROM_SIZE_MAX + TCX_SIZE, .nodisk_ok = 1, + .max_cpus = 16, };QEMUMachine ss2000_machine = {
@@ -1619,4 +1630,5 @@ QEMUMachine ss2000_machine = { .init = ss2000_init, .ram_require = PROM_SIZE_MAX + TCX_SIZE, .nodisk_ok = 1, + .max_cpus = 16, };
hw/sun4u.c +2 -0
@@ -523,6 +523,7 @@ QEMUMachine sun4u_machine = { .init = sun4u_init, .ram_require = PROM_SIZE_MAX + VGA_RAM_SIZE, .nodisk_ok = 1, + .max_cpus = 16, };QEMUMachine sun4v_machine = {
@@ -531,4 +532,5 @@ QEMUMachine sun4v_machine = { .init = sun4v_init, .ram_require = PROM_SIZE_MAX + VGA_RAM_SIZE, .nodisk_ok = 1, + .max_cpus = 16, };
hw/tosa.c +5 -4
@@ -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 , };
hw/versatilepb.c +8 -6
@@ -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 , };
vl.c +8 -8
@@ -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" ;
Re: [Qemu-devel] [patch] Introduce per machine based max_cpu variable
In reply to Jes SorensenQuoted 18 lines · Jes Sorensen
Quoted 8 lines
Quoted 8 lines
Index:
qemu/hw/an5206.c
===================================================================
---qemu.orig/hw/an5206.c+++qemu/hw/an5206.c@@ -88,8 +88,9 @@ static void an5206_init(ram_addr_tram_s} QEMUMachinean5206_machine= { - "an5206", - "Arnewsh 5206", -an5206_init, - 512, + .name = "an5206", + .desc = "Arnewsh 5206", + .init =an5206_init, + .ram_require = 512, + .max_cpus = 1, };Anthony> Your change would be greatly simplified if you defined Anthony>
max_cpusto be such that it was the maximum number of vcpus - Anthony> 1.Anthony> Then the default value of 0 would be sufficient for most Anthony> machine types.
Hi Anthony,
Quoted 8 lines
I thought about this, but I think it's a really bad idea. It will cause confusion over time and I think it is quite reasonable to require all machines to define the maximum number of CPUs they support. Thats why I defined the error message so it was quite easy for anyone to fixup in case I got one of them wrong.
I really think it's better to do this right than hack it.
If it were 'max_cpu' then the meaning is pretty clear. On a UP system, the max_cpu is 0.
You could also make it max_aps which makes it even more clear. A UP system doesn't have any APs.
The other option is to have max_cpus == 0 be equivalent to max_cpus == 1. But don't print anything. Basically, I don't like the idea of modifying every machine definition when they all have almost the exact same value for the field.
Regards,
Anthony Liguori
Re: [Qemu-devel] [patch] Introduce per machine based max_cpu variable
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Anthony" == Anthony Liguori <[email protected]> writes:
Anthony> If it were 'max_cpu' then the meaning is pretty clear. On a Anthony> UP system, the max_cpu is 0.
Well it depends on how you calculate it, it is meant as max_nr_cpus which IMHO is the most clear. If you prefer, I can rename it to that. Most users will think in terms of 'number of cpus to enable' rather than the highest logical cpu number.
Anthony> You could also make it max_aps which makes it even more Anthony> clear. A UP system doesn't have any APs.
What do you mean by AP?
Anthony> The other option is to have max_cpus == 0 be equivalent to Anthony> max_cpus == 1. But don't print anything. Basically, I don't Anthony> like the idea of modifying every machine definition when they Anthony> all have almost the exact same value for the field.
I really don't understand this - the code as it is today is really inconsistent. What my patch does is simply to make it explicit what it does and make it consistent. I have taken great care to do it in a way, so if in the unlikely situation it breaks an existing behavior, it will be very clear what is wrong and how to fix it. I'll even be willing to put my name in there and volunteer to fix it up for people if this actually happens :-)
Cheers,
Jes
Re: [Qemu-devel] [patch] Introduce per machine based max_cpu variable
In reply to Jes SorensenQuoted 4 lines
Here's an attempt of implementing a per-machine
max_cpusvariable. This means developers can limit smp support to match the actual board sizes. It also makes the staticMAX_CPUScheck invl.cobsolete which I think is a good thing :-)
This looks reasonable, but is still not an ideal solution. It is an improvement over what we currently have, so I'm not going to object to it being applied.
The maximum number of CPUs may be a property of the CPU, not the board. Especially in the embedded world it's becoming common to have multicore CPUs connected to dumb single socket systems/boards.
IMHO max_cpus should be the actual number of cpus, not N-1 as has been suggested elsewhere in this thread. It may be ok to accept max_cpus==0 as a special case meaning max_cpus==1 to avoid having to change all the machine descriptions. Probably less confusing to just make all the changes you suggested though.
Paul
Re: [Qemu-devel] [patch] Introduce per machine based max_cpu variable
Quoted 8 lines · Paul Brook
Quoted 4 lines
Here's an attempt of implementing a per-machine
max_cpusvariable. This means developers can limit smp support to match the actual board sizes. It also makes the staticMAX_CPUScheck invl.cobsolete which I think is a good thing :-)This looks reasonable, but is still not an ideal solution. It is an improvement over what we currently have, so I'm not going to object to it being applied.
The maximum number of CPUs may be a property of the CPU, not the board. Especially in the embedded world it's becoming common to have multicore CPUs connected to dumb single socket systems/boards.
Hi Paul,
Thanks for the feedback.
I don't think this patch will conflict with what you describe. I think eventually we will want to have flags that allow the user to specify the number of sockets and cores per socket to handle this. However I don't know how far the QEMU system emulation layer is from being able to actually simulate this.
Cheers,
Jes