From patchwork Wed Jul 25 11:11:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: dunrong huang X-Patchwork-Id: 173136 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 493FD2C008A for ; Wed, 25 Jul 2012 21:11:56 +1000 (EST) Received: from localhost ([::1]:52139 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StzVS-0000tm-VV for incoming@patchwork.ozlabs.org; Wed, 25 Jul 2012 07:11:54 -0400 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 Received: from mail-yx0-f173.google.com ([209.85.213.173]:34995) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StzVH-0004GS-Bg; Wed, 25 Jul 2012 07:11:43 -0400 Received: by yenl1 with SMTP id l1so540474yen.4 for ; Wed, 25 Jul 2012 04:11:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=japWjcgA92m0nFyCH0sgFPb/BZDlqUZhcyUu3TDDJr0=; b=egc40vCu7DSayuY/5QmJJEjZ5YgL7ypVWItz3O96XOKbiZD0Es+eDHdWtPBSHosKeZ fnCkUqV3nB6Fc8Zr+uP2JWZ0Ql0dQx0p7VC9W5DAA9l4Zynz9k7gagpylcU5fXB1k1wH TQQagi9eqsjBCVltplRz02NKj+JOaBBGh9zpGrzG6cFnvATOFs8XvjQZAZYHmziITqoL EtwfowEHmK+t//Yw3K8p/5liLI/8u0F192NNfKMkbCKs/cXYQQwQ/Y+qGyKV+PaMzbno TGcU5Hvv677bmssZVHtIS1MXVHycuXenAAJjDNQfTn9OHPw7UXDa7YPpTJ/dUKLjPmoH uyqA== Received: by 10.66.81.232 with SMTP id d8mr11932067pay.66.1343214702105; Wed, 25 Jul 2012 04:11:42 -0700 (PDT) Received: from localhost.localdomain ([111.196.220.100]) by mx.google.com with ESMTPS id nh8sm14184850pbc.60.2012.07.25.04.11.36 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 25 Jul 2012 04:11:41 -0700 (PDT) From: riegamaths@gmail.com To: qemu-devel Date: Wed, 25 Jul 2012 19:11:51 +0800 Message-Id: <1343214711-24336-1-git-send-email-riegamaths@gmail.com> X-Mailer: git-send-email 1.7.8.6 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.213.173 Cc: qemu-trivial , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Anthony Liguori , Dunrong Huang , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH v2] vl.c: Fix max_cpus X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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");