From mboxrd@z Thu Jan 1 00:00:00 1970 From: Asias He Subject: Re: [PATCH] kvm tools: Default guest cpu count to host cpu count Date: Thu, 19 May 2011 18:35:57 +0800 Message-ID: <4DD4F28D.9090307@gmail.com> References: <1305748584-9411-1-git-send-email-levinsasha928@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: penberg@kernel.org, mingo@elte.hu, gorcunov@gmail.com, prasadjoshi124@gmail.com, kvm@vger.kernel.org To: Sasha Levin Return-path: Received: from mail-pw0-f46.google.com ([209.85.160.46]:52606 "EHLO mail-pw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752771Ab1ESKhT (ORCPT ); Thu, 19 May 2011 06:37:19 -0400 Received: by pwi15 with SMTP id 15so1166206pwi.19 for ; Thu, 19 May 2011 03:37:18 -0700 (PDT) In-Reply-To: <1305748584-9411-1-git-send-email-levinsasha928@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: On 05/19/2011 03:56 AM, 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 > --- > 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 [] []", > @@ -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); > > 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++) { Looks good to me. Tested-by: Asias He -- Best Regards, Asias He