Commit-ID: 5ccc7a3dd93b1f814b653cba9dac5a373443c861 Gitweb: http://git.kernel.org/tip/5ccc7a3dd93b1f814b653cba9dac5a373443c861 Author: Sasha Levin <levinsasha928@xxxxxxxxx> AuthorDate: Wed, 18 May 2011 22:56:24 +0300 Committer: Pekka Enberg <penberg@xxxxxxxxxx> CommitDate: Thu, 19 May 2011 22:11:20 +0300 kvm tools: Default guest cpu count to host cpu count If user haven't specified cpu count for the guest, use the amount of online cpus on the host. Tested-by: Asias He <asias.hejun@xxxxxxxxx> Signed-off-by: Sasha Levin <levinsasha928@xxxxxxxxx> Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx> --- 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 8379a52..c01517f 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>]", @@ -410,6 +410,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); @@ -440,7 +442,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) @@ -576,7 +580,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++) { -- To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html