From patchwork Wed May 18 19:56:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 794992 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4IJufuh017554 for ; Wed, 18 May 2011 19:56:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751883Ab1ERT4i (ORCPT ); Wed, 18 May 2011 15:56:38 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:44095 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751527Ab1ERT4i (ORCPT ); Wed, 18 May 2011 15:56:38 -0400 Received: by wya21 with SMTP id 21so1464443wya.19 for ; Wed, 18 May 2011 12:56:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer; bh=9kuH9afzXQIQWD+g1d586i90AtSFv2LtjGHYpq4GK50=; b=w4xbrby6/VbORHib/NKQIJWVP72lY8KGizC0A5d0pDpGj6u9on9IDFjhcUgHCXZjb4 Ghkg8Hx4fly2MoYgpUcph15MxUZkcu8IIdhZDCOetSE3bakFwEzhwWH1z9ZyyRGnUueh kjUyZhRtTDkQyjvLCC9L8wZjAVPwscNpYGUyU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=pBrAsu7BQSi4gVFz4JBxJAAzgOsp+Fr3Xd30j6RC03TzIVAtzS/c63Ma/xIgTHJoyi X86YJpqW6EDTX1CTxrbUqYA2bfFU6iMaA35TJe/MancWX6/9rGUrD5zUzE4E6M/tln9l bRylxhQfcTY50q9X4k064Nh12JIyerL+lwgz8= Received: by 10.227.37.22 with SMTP id v22mr2267795wbd.27.1305748596406; Wed, 18 May 2011 12:56:36 -0700 (PDT) Received: from localhost.localdomain (bzq-79-179-206-38.red.bezeqint.net [79.179.206.38]) by mx.google.com with ESMTPS id ed10sm1171719wbb.15.2011.05.18.12.56.34 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 18 May 2011 12:56:35 -0700 (PDT) From: Sasha Levin To: penberg@kernel.org Cc: mingo@elte.hu, asias.hejun@gmail.com, gorcunov@gmail.com, prasadjoshi124@gmail.com, kvm@vger.kernel.org, Sasha Levin Subject: [PATCH] kvm tools: Default guest cpu count to host cpu count Date: Wed, 18 May 2011 22:56:24 +0300 Message-Id: <1305748584-9411-1-git-send-email-levinsasha928@gmail.com> X-Mailer: git-send-email 1.7.5.rc3 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 18 May 2011 19:56:42 +0000 (UTC) If user haven't specified cpu count for the guest, use the amount of online cpus on the host. Signed-off-by: Sasha Levin Tested-by: Asias He --- 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++) {