* [Qemu-devel] [patch] move MAX_CPUS to cpu.h
@ 2008-09-23 11:44 Jes Sorensen
2008-09-23 12:08 ` Paul Brook
0 siblings, 1 reply; 16+ messages in thread
From: Jes Sorensen @ 2008-09-23 11:44 UTC (permalink / raw)
To: Anthony Liguori, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 152 bytes --]
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
[-- Attachment #2: 1000-qemu-move-max-cpus.patch --]
[-- Type: text/plain, Size: 4046 bytes --]
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.
Signed-off-by: Jes Sorensen <jes@sgi.com>
---
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(-)
Index: qemu/hw/ppc_mac.h
===================================================================
--- qemu.orig/hw/ppc_mac.h
+++ qemu/hw/ppc_mac.h
@@ -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
Index: qemu/target-alpha/cpu.h
===================================================================
--- qemu.orig/target-alpha/cpu.h
+++ qemu/target-alpha/cpu.h
@@ -25,6 +25,8 @@
#define TARGET_LONG_BITS 64
+#define MAX_CPUS 1
+
#include "cpu-defs.h"
#include <setjmp.h>
Index: qemu/target-arm/cpu.h
===================================================================
--- qemu.orig/target-arm/cpu.h
+++ qemu/target-arm/cpu.h
@@ -22,6 +22,8 @@
#define TARGET_LONG_BITS 32
+#define MAX_CPUS 1
+
#define ELF_MACHINE EM_ARM
#include "cpu-defs.h"
Index: qemu/target-cris/cpu.h
===================================================================
--- qemu.orig/target-cris/cpu.h
+++ qemu/target-cris/cpu.h
@@ -23,6 +23,8 @@
#define TARGET_LONG_BITS 32
+#define MAX_CPUS 1
+
#include "cpu-defs.h"
#define TARGET_HAS_ICE 1
Index: qemu/target-i386/cpu.h
===================================================================
--- qemu.orig/target-i386/cpu.h
+++ qemu/target-i386/cpu.h
@@ -22,6 +22,8 @@
#include "config.h"
+#define MAX_CPUS 255
+
#ifdef TARGET_X86_64
#define TARGET_LONG_BITS 64
#else
Index: qemu/target-m68k/cpu.h
===================================================================
--- qemu.orig/target-m68k/cpu.h
+++ qemu/target-m68k/cpu.h
@@ -23,6 +23,8 @@
#define TARGET_LONG_BITS 32
+#define MAX_CPUS 1
+
#include "cpu-defs.h"
#include "softfloat.h"
Index: qemu/target-mips/cpu.h
===================================================================
--- qemu.orig/target-mips/cpu.h
+++ qemu/target-mips/cpu.h
@@ -3,6 +3,8 @@
#define TARGET_HAS_ICE 1
+#define MAX_CPUS 1
+
#define ELF_MACHINE EM_MIPS
#include "config.h"
Index: qemu/target-ppc/cpu.h
===================================================================
--- qemu.orig/target-ppc/cpu.h
+++ qemu/target-ppc/cpu.h
@@ -23,6 +23,8 @@
#include "config.h"
#include <inttypes.h>
+#define MAX_CPUS 1
+
//#define PPC_EMULATE_32BITS_HYPV
#if defined (TARGET_PPC64)
Index: qemu/target-sh4/cpu.h
===================================================================
--- qemu.orig/target-sh4/cpu.h
+++ qemu/target-sh4/cpu.h
@@ -22,6 +22,8 @@
#include "config.h"
+#define MAX_CPUS 1
+
#define TARGET_LONG_BITS 32
#define TARGET_HAS_ICE 1
Index: qemu/target-sparc/cpu.h
===================================================================
--- qemu.orig/target-sparc/cpu.h
+++ qemu/target-sparc/cpu.h
@@ -3,6 +3,8 @@
#include "config.h"
+#define MAX_CPUS 16
+
#if !defined(TARGET_SPARC64)
#define TARGET_LONG_BITS 32
#define TARGET_FPREGS 32
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;
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [patch] move MAX_CPUS to cpu.h
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
0 siblings, 1 reply; 16+ messages in thread
From: Paul Brook @ 2008-09-23 12:08 UTC (permalink / raw)
To: qemu-devel; +Cc: Anthony Liguori, Jes Sorensen
On Tuesday 23 September 2008, Jes Sorensen wrote:
> Index: qemu/target-arm/cpu.h
> ===================================================================
> --- qemu.orig/target-arm/cpu.h
> +++ qemu/target-arm/cpu.h
> +#define MAX_CPUS 1
Anything using the value to allocate per-cpu structures will be wrong.
Paul
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [patch] move MAX_CPUS to cpu.h
2008-09-23 12:08 ` Paul Brook
@ 2008-09-23 12:10 ` Jes Sorensen
2008-09-23 12:50 ` Paul Brook
0 siblings, 1 reply; 16+ messages in thread
From: Jes Sorensen @ 2008-09-23 12:10 UTC (permalink / raw)
To: qemu-devel; +Cc: Anthony Liguori, Paul Brook
>>>>> "Paul" == Paul Brook <paul@codesourcery.com> writes:
Paul> On Tuesday 23 September 2008, Jes Sorensen wrote:
>> Index: qemu/target-arm/cpu.h
>> ===================================================================
>> --- qemu.orig/target-arm/cpu.h +++ qemu/target-arm/cpu.h +#define
>> MAX_CPUS 1
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
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [patch] move MAX_CPUS to cpu.h
2008-09-23 12:10 ` Jes Sorensen
@ 2008-09-23 12:50 ` Paul Brook
2008-09-23 12:53 ` Jes Sorensen
2008-09-23 14:13 ` [Qemu-devel] [patch] move MAX_CPUS to cpu.h M. Warner Losh
0 siblings, 2 replies; 16+ messages in thread
From: Paul Brook @ 2008-09-23 12:50 UTC (permalink / raw)
To: Jes Sorensen; +Cc: Anthony Liguori, qemu-devel
On Tuesday 23 September 2008, Jes Sorensen wrote:
> >>>>> "Paul" == Paul Brook <paul@codesourcery.com> writes:
>
> Paul> On Tuesday 23 September 2008, Jes Sorensen wrote:
> >> Index: qemu/target-arm/cpu.h
> >> ===================================================================
> >> --- qemu.orig/target-arm/cpu.h +++ qemu/target-arm/cpu.h +#define
> >> MAX_CPUS 1
>
> 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
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [patch] move MAX_CPUS to cpu.h
2008-09-23 12:50 ` Paul Brook
@ 2008-09-23 12:53 ` Jes Sorensen
2008-09-23 13:04 ` Paul Brook
2008-09-23 14:13 ` [Qemu-devel] [patch] move MAX_CPUS to cpu.h M. Warner Losh
1 sibling, 1 reply; 16+ messages in thread
From: Jes Sorensen @ 2008-09-23 12:53 UTC (permalink / raw)
To: Paul Brook; +Cc: Anthony Liguori, qemu-devel
Paul Brook wrote:
> On Tuesday 23 September 2008, Jes Sorensen wrote:
>> 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
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [patch] move MAX_CPUS to cpu.h
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 ` [Qemu-devel] [patch] Introduce per machine based max_cpu variable Jes Sorensen
0 siblings, 2 replies; 16+ messages in thread
From: Paul Brook @ 2008-09-23 13:04 UTC (permalink / raw)
To: Jes Sorensen; +Cc: Anthony Liguori, qemu-devel
On Tuesday 23 September 2008, Jes Sorensen wrote:
> Paul Brook wrote:
> > On Tuesday 23 September 2008, Jes Sorensen wrote:
> >> 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?
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
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [patch] move MAX_CPUS to cpu.h
2008-09-23 13:04 ` Paul Brook
@ 2008-09-23 13:10 ` Jes Sorensen
2008-09-25 15:21 ` [Qemu-devel] [patch] Introduce per machine based max_cpu variable Jes Sorensen
1 sibling, 0 replies; 16+ messages in thread
From: Jes Sorensen @ 2008-09-23 13:10 UTC (permalink / raw)
To: Paul Brook; +Cc: Anthony Liguori, qemu-devel
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.
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
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [patch] move MAX_CPUS to cpu.h
2008-09-23 12:50 ` Paul Brook
2008-09-23 12:53 ` Jes Sorensen
@ 2008-09-23 14:13 ` M. Warner Losh
1 sibling, 0 replies; 16+ messages in thread
From: M. Warner Losh @ 2008-09-23 14:13 UTC (permalink / raw)
To: qemu-devel, paul; +Cc: aliguori, jes
In message: <200809231350.34178.paul@codesourcery.com>
Paul Brook <paul@codesourcery.com> 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
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Qemu-devel] [patch] Introduce per machine based max_cpu variable
2008-09-23 13:04 ` Paul Brook
2008-09-23 13:10 ` Jes Sorensen
@ 2008-09-25 15:21 ` Jes Sorensen
2008-09-30 14:47 ` Anthony Liguori
2008-10-02 15:45 ` Paul Brook
1 sibling, 2 replies; 16+ messages in thread
From: Jes Sorensen @ 2008-09-25 15:21 UTC (permalink / raw)
To: Paul Brook; +Cc: Anthony Liguori, qemu-devel
[-- 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";
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [patch] Introduce per machine based max_cpu variable
2008-09-25 15:21 ` [Qemu-devel] [patch] Introduce per machine based max_cpu variable Jes Sorensen
@ 2008-09-30 14:47 ` Anthony Liguori
2008-09-30 15:06 ` Jes Sorensen
2008-09-30 15:19 ` Jes Sorensen
2008-10-02 15:45 ` Paul Brook
1 sibling, 2 replies; 16+ messages in thread
From: Anthony Liguori @ 2008-09-30 14:47 UTC (permalink / raw)
To: qemu-devel; +Cc: Anthony Liguori, Paul Brook
Jes Sorensen wrote:
> 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>
>
> 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,
> };
>
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.
> 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;
>
Just use int and please don't change nodisk_ok to char.
> 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);
>
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
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [patch] Introduce per machine based max_cpu variable
2008-09-30 14:47 ` Anthony Liguori
@ 2008-09-30 15:06 ` Jes Sorensen
2008-09-30 15:18 ` Anthony Liguori
2008-09-30 15:19 ` Jes Sorensen
1 sibling, 1 reply; 16+ messages in thread
From: Jes Sorensen @ 2008-09-30 15:06 UTC (permalink / raw)
To: qemu-devel; +Cc: Anthony Liguori, Paul Brook
>>>>> "Anthony" == Anthony Liguori <anthony@codemonkey.ws> 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_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, };
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.
>> 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;
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
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [patch] Introduce per machine based max_cpu variable
2008-09-30 15:06 ` Jes Sorensen
@ 2008-09-30 15:18 ` Anthony Liguori
2008-10-01 13:22 ` Jes Sorensen
0 siblings, 1 reply; 16+ messages in thread
From: Anthony Liguori @ 2008-09-30 15:18 UTC (permalink / raw)
To: qemu-devel; +Cc: Paul Brook
Jes Sorensen wrote:
>>> 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, };
>>>
>
> 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.
>
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
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [patch] Introduce per machine based max_cpu variable
2008-09-30 14:47 ` Anthony Liguori
2008-09-30 15:06 ` Jes Sorensen
@ 2008-09-30 15:19 ` Jes Sorensen
1 sibling, 0 replies; 16+ messages in thread
From: Jes Sorensen @ 2008-09-30 15:19 UTC (permalink / raw)
To: qemu-devel; +Cc: Anthony Liguori, jes, Paul Brook
[-- Attachment #1: Type: text/plain, Size: 372 bytes --]
Hi,
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
[-- Attachment #2: 0100-qemu-cpus-per-machine.patch --]
[-- Type: text/plain, Size: 21659 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 | 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(-)
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
@@ -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;
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
@@ -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,
};
Index: qemu/hw/mips_malta.c
===================================================================
--- qemu.orig/hw/mips_malta.c
+++ qemu/hw/mips_malta.c
@@ -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,
};
Index: qemu/hw/mips_mipssim.c
===================================================================
--- qemu.orig/hw/mips_mipssim.c
+++ qemu/hw/mips_mipssim.c
@@ -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,
};
Index: qemu/hw/mips_r4k.c
===================================================================
--- qemu.orig/hw/mips_r4k.c
+++ qemu/hw/mips_r4k.c
@@ -288,4 +288,5 @@ QEMUMachine mips_machine = {
.init = mips_r4k_init,
.ram_require = VGA_RAM_SIZE + BIOS_SIZE,
.nodisk_ok = 1,
+ .max_cpus = 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
@@ -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,
};
Index: qemu/hw/sun4u.c
===================================================================
--- qemu.orig/hw/sun4u.c
+++ qemu/hw/sun4u.c
@@ -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,
};
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";
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [patch] Introduce per machine based max_cpu variable
2008-09-30 15:18 ` Anthony Liguori
@ 2008-10-01 13:22 ` Jes Sorensen
0 siblings, 0 replies; 16+ messages in thread
From: Jes Sorensen @ 2008-10-01 13:22 UTC (permalink / raw)
To: qemu-devel; +Cc: jes, Paul Brook
>>>>> "Anthony" == Anthony Liguori <anthony@codemonkey.ws> 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
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [patch] Introduce per machine based max_cpu variable
2008-09-25 15:21 ` [Qemu-devel] [patch] Introduce per machine based max_cpu variable Jes Sorensen
2008-09-30 14:47 ` Anthony Liguori
@ 2008-10-02 15:45 ` Paul Brook
2008-10-03 9:40 ` Jes Sorensen
1 sibling, 1 reply; 16+ messages in thread
From: Paul Brook @ 2008-10-02 15:45 UTC (permalink / raw)
To: qemu-devel; +Cc: Anthony Liguori, Jes Sorensen
> 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 :-)
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
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [patch] Introduce per machine based max_cpu variable
2008-10-02 15:45 ` Paul Brook
@ 2008-10-03 9:40 ` Jes Sorensen
0 siblings, 0 replies; 16+ messages in thread
From: Jes Sorensen @ 2008-10-03 9:40 UTC (permalink / raw)
To: Paul Brook; +Cc: Anthony Liguori, qemu-devel
Paul Brook wrote:
>> 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 :-)
>
> 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
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2008-10-03 9:41 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [Qemu-devel] [patch] Introduce per machine based max_cpu variable Jes Sorensen
2008-09-30 14:47 ` 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
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).