qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: riegamaths@gmail.com
To: qemu-devel <qemu-devel@nongnu.org>
Cc: qemu-trivial <qemu-trivial@nongnu.org>,
	"Andreas Färber" <andreas.faerber@web.de>,
	"Anthony Liguori" <aliguori@us.ibm.com>,
	"Dunrong Huang" <riegamaths@gmail.com>,
	"Stefan Hajnoczi" <stefanha@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH v2] vl.c: Fix max_cpus
Date: Wed, 25 Jul 2012 19:11:51 +0800	[thread overview]
Message-ID: <1343214711-24336-1-git-send-email-riegamaths@gmail.com> (raw)

From: Dunrong Huang <riegamaths@gmail.com>

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 <riegamaths@gmail.com>
---
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

             reply	other threads:[~2012-07-25 11:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-25 11:11 riegamaths [this message]
2012-07-30 16:39 ` [Qemu-devel] [PATCH v2] vl.c: Fix max_cpus Peter Maydell
2012-07-30 16:40 ` Stefan Hajnoczi
2012-07-30 16:50   ` Dunrong Huang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1343214711-24336-1-git-send-email-riegamaths@gmail.com \
    --to=riegamaths@gmail.com \
    --cc=aliguori@us.ibm.com \
    --cc=andreas.faerber@web.de \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=stefanha@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).