From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KkgWj-00054v-5n for qemu-devel@nongnu.org; Tue, 30 Sep 2008 10:48:37 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KkgWg-00054J-I3 for qemu-devel@nongnu.org; Tue, 30 Sep 2008 10:48:36 -0400 Received: from [199.232.76.173] (port=54738 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KkgWg-00054G-Fr for qemu-devel@nongnu.org; Tue, 30 Sep 2008 10:48:34 -0400 Received: from mail-gx0-f19.google.com ([209.85.217.19]:63138) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KkgWg-0008RG-2X for qemu-devel@nongnu.org; Tue, 30 Sep 2008 10:48:34 -0400 Received: by gxk12 with SMTP id 12so12788705gxk.10 for ; Tue, 30 Sep 2008 07:48:33 -0700 (PDT) Message-ID: <48E23C00.2030309@codemonkey.ws> Date: Tue, 30 Sep 2008 09:47:28 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [patch] Introduce per machine based max_cpu variable References: <48D8D694.1000609@sgi.com> <200809231350.34178.paul@codesourcery.com> <48D8E6CA.9040802@sgi.com> <200809231404.49340.paul@codesourcery.com> <48DBAC61.9090906@sgi.com> In-Reply-To: <48DBAC61.9090906@sgi.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 > > 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