All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: Pavel Dovgalyuk <pavel.dovgalyuk@ispras.ru>
Cc: pbonzini@redhat.com, David Gibson <dgibson@redhat.com>,
	qemu-devel@nongnu.org, rth@twiddle.net
Subject: Re: [PATCH] cpus: verify that number of created cpus do not exceed smp params
Date: Fri, 23 Oct 2020 19:06:43 +0200	[thread overview]
Message-ID: <20201023190643.06db22f7@redhat.com> (raw)
In-Reply-To: <160343848141.8350.10469322440262034340.stgit@pasha-ThinkPad-X280>

On Fri, 23 Oct 2020 10:34:41 +0300
Pavel Dovgalyuk <pavel.dovgalyuk@ispras.ru> wrote:

> Machine definitions may miss some vCPU-related parameters.
> E.g., xlnx-versal-virt missed min_cpus and it was set to 1 by default.
> This allowed using -smp 1 command line argument. But the machine
> still created 2 vCPUs and passed all checks.
> This patch adds one more check that does not allow creating
> extra cpus that exceed the values specified in machine/smp.
> 
> Signed-off-by: Pavel Dovgalyuk <pavel.dovgalyuk@ispras.ru>
> ---
>  0 files changed
> 
> diff --git a/softmmu/cpus.c b/softmmu/cpus.c
> index 47cceddd80..da74794e09 100644
> --- a/softmmu/cpus.c
> +++ b/softmmu/cpus.c
> @@ -603,6 +603,11 @@ void qemu_init_vcpu(CPUState *cpu)
>  {
>      MachineState *ms = MACHINE(qdev_get_machine());
>  
> +    if (cpu->cpu_index >= ms->smp.cpus) {
looks like for such machines we need MachineClass:min_cpus + setting it in affected machines
and corresponding check in smp_parse(), instead of terminating from qemu_init_vcpu();


> +        fprintf(stderr, "Machine definition error: trying to create too many CPUs\n");
> +        exit(1);
> +    }
> +
>      cpu->nr_cores = ms->smp.cores;
>      cpu->nr_threads =  ms->smp.threads;
>      cpu->stopped = true;
> 
> 



      parent reply	other threads:[~2020-10-23 17:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-23  7:34 [PATCH] cpus: verify that number of created cpus do not exceed smp params Pavel Dovgalyuk
2020-10-23  8:10 ` Philippe Mathieu-Daudé
2020-10-23  8:16   ` Pavel Dovgalyuk
2020-10-23 17:06 ` Igor Mammedov [this message]

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=20201023190643.06db22f7@redhat.com \
    --to=imammedo@redhat.com \
    --cc=dgibson@redhat.com \
    --cc=pavel.dovgalyuk@ispras.ru \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.