qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: qemu-devel@nongnu.org
Cc: Anthony Liguori <aliguori@us.ibm.com>,
	Paul Brook <paul@codesourcery.com>
Subject: Re: [Qemu-devel] [patch] Introduce per machine based max_cpu variable
Date: Tue, 30 Sep 2008 09:47:28 -0500	[thread overview]
Message-ID: <48E23C00.2030309@codemonkey.ws> (raw)
In-Reply-To: <48DBAC61.9090906@sgi.com>

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

  reply	other threads:[~2008-09-30 14:48 UTC|newest]

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

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=48E23C00.2030309@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=aliguori@us.ibm.com \
    --cc=paul@codesourcery.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

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

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