qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Pavel Dovgalyuk <pavel.dovgalyuk@ispras.ru>,
	qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>
Cc: pbonzini@redhat.com, rth@twiddle.net
Subject: Re: [PATCH] cpus: verify that number of created cpus do not exceed smp params
Date: Fri, 23 Oct 2020 10:10:06 +0200	[thread overview]
Message-ID: <8a4ef7ec-47e8-909b-d724-f3db2ca69379@redhat.com> (raw)
In-Reply-To: <160343848141.8350.10469322440262034340.stgit@pasha-ThinkPad-X280>

On 10/23/20 9:34 AM, Pavel Dovgalyuk 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) {
> +        fprintf(stderr, "Machine definition error: trying to create too many CPUs\n");
> +        exit(1);

Shouldn't this be an assert()?

> +    }
> +
>       cpu->nr_cores = ms->smp.cores;
>       cpu->nr_threads =  ms->smp.threads;
>       cpu->stopped = true;
> 
> 



  reply	other threads:[~2020-10-23  8:13 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é [this message]
2020-10-23  8:16   ` Pavel Dovgalyuk
2020-10-23 17:06 ` Igor Mammedov

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=8a4ef7ec-47e8-909b-d724-f3db2ca69379@redhat.com \
    --to=philmd@redhat.com \
    --cc=armbru@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 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).