public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Sasha Levin <levinsasha928@gmail.com>
Cc: penberg@kernel.org, mingo@elte.hu, asias.hejun@gmail.com,
	gorcunov@gmail.com, prasadjoshi124@gmail.com,
	kvm@vger.kernel.org
Subject: Re: [PATCH] kvm tools: Default guest cpu count to host cpu count
Date: Thu, 19 May 2011 13:04:07 -0600	[thread overview]
Message-ID: <4DD569A7.6050608@gmail.com> (raw)
In-Reply-To: <1305748584-9411-1-git-send-email-levinsasha928@gmail.com>



On 05/18/11 13:56, Sasha Levin wrote:
> If user haven't specified cpu count for the guest, use
> the amount of online cpus on the host.
> 
> Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
> ---
>  tools/kvm/kvm-run.c |    9 ++++++---
>  1 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/kvm/kvm-run.c b/tools/kvm/kvm-run.c
> index 63181bf..1517264 100644
> --- a/tools/kvm/kvm-run.c
> +++ b/tools/kvm/kvm-run.c
> @@ -70,7 +70,7 @@ extern int  active_console;
>  
>  bool do_debug_print = false;
>  
> -static int nrcpus = 1;
> +static int nrcpus;
>  
>  static const char * const run_usage[] = {
>  	"kvm run [<options>] [<kernel image>]",
> @@ -409,6 +409,8 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
>  	signal(SIGQUIT, handle_sigquit);
>  	signal(SIGUSR1, handle_sigusr1);
>  
> +	nr_online_cpus = sysconf(_SC_NPROCESSORS_ONLN);
> +
>  	while (argc != 0) {
>  		argc = parse_options(argc, argv, options, run_usage,
>  				PARSE_OPT_STOP_AT_NON_OPTION);
> @@ -439,7 +441,9 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
>  
>  	vmlinux_filename = find_vmlinux();
>  
> -	if (nrcpus < 1 || nrcpus > KVM_NR_CPUS)
> +	if (nrcpus == 0)
> +		nrcpus = nr_online_cpus;
> +	else if (nrcpus < 1 || nrcpus > KVM_NR_CPUS)
>  		die("Number of CPUs %d is out of [1;%d] range", nrcpus, KVM_NR_CPUS);

What prevents nr_online_cpus from being greater than KVM_NR_CPUS? Since
that latter is a #define, might want to change 'else if' to if there.

David



>  
>  	if (!ram_size)
> @@ -575,7 +579,6 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
>  
>  	kvm__init_ram(kvm);
>  
> -	nr_online_cpus = sysconf(_SC_NPROCESSORS_ONLN);
>  	thread_pool__init(nr_online_cpus);
>  
>  	for (i = 0; i < nrcpus; i++) {

  parent reply	other threads:[~2011-05-19 19:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-18 19:56 [PATCH] kvm tools: Default guest cpu count to host cpu count Sasha Levin
2011-05-18 19:59 ` Cyrill Gorcunov
2011-05-19 10:35 ` Asias He
2011-05-19 19:04 ` David Ahern [this message]
2011-05-19 19:08   ` Cyrill Gorcunov
2011-05-19 20:00     ` Cyrill Gorcunov

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=4DD569A7.6050608@gmail.com \
    --to=dsahern@gmail.com \
    --cc=asias.hejun@gmail.com \
    --cc=gorcunov@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=levinsasha928@gmail.com \
    --cc=mingo@elte.hu \
    --cc=penberg@kernel.org \
    --cc=prasadjoshi124@gmail.com \
    /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