From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:41011) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StzVM-0000tW-6K for qemu-devel@nongnu.org; Wed, 25 Jul 2012 07:11:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1StzVH-0004Gi-Es for qemu-devel@nongnu.org; Wed, 25 Jul 2012 07:11:48 -0400 From: riegamaths@gmail.com Date: Wed, 25 Jul 2012 19:11:51 +0800 Message-Id: <1343214711-24336-1-git-send-email-riegamaths@gmail.com> Subject: [Qemu-devel] [PATCH v2] vl.c: Fix max_cpus List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel Cc: qemu-trivial , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Anthony Liguori , Dunrong Huang , Stefan Hajnoczi From: Dunrong Huang The VCPU count limit in kernel now is 254, defined by KVM_MAX_VCPUS in kernel's header files. But the count limit in QEMU is 255, so QEMU will failed to start if user passes "-enable-kvm" and "-smp 255" to it. Exit QEMU with an error if KVM is enabled and number of SMP cpus requested exceeds KVM_MAX_VCPUS. Signed-off-by: Dunrong Huang --- v1 -> v2: Checking if the number of smp cpus requested exceeds KVM limit count if and only if kvm is enabled. vl.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/vl.c b/vl.c index 8904db1..cdd1c96 100644 --- a/vl.c +++ b/vl.c @@ -169,6 +169,11 @@ int main(int argc, char **argv) #define MAX_VIRTIO_CONSOLES 1 +/* KVM_MAX_VCPUS defined in kernel's header files */ +#ifndef KVM_MAX_VCPUS +#define KVM_MAX_VCPUS 254 +#endif + static const char *data_dir; const char *bios_name = NULL; enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB; @@ -3348,6 +3353,12 @@ int main(int argc, char **argv, char **envp) configure_accelerator(); + if (kvm_enabled() && smp_cpus > KVM_MAX_VCPUS) { + fprintf(stderr, "Number of SMP cpus requested (%d) exceeds max cpus " + "supported by KVM (%d)\n", smp_cpus, KVM_MAX_VCPUS); + exit(1); + } + qemu_init_cpu_loop(); if (qemu_init_main_loop()) { fprintf(stderr, "qemu_init_main_loop failed\n"); -- 1.7.8.6