qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] vl.c: Fix max_cpus
@ 2012-07-25 11:11 riegamaths
  2012-07-30 16:39 ` Peter Maydell
  2012-07-30 16:40 ` Stefan Hajnoczi
  0 siblings, 2 replies; 4+ messages in thread
From: riegamaths @ 2012-07-25 11:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Andreas Färber, Anthony Liguori, Dunrong Huang,
	Stefan Hajnoczi

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-07-30 16:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-25 11:11 [Qemu-devel] [PATCH v2] vl.c: Fix max_cpus riegamaths
2012-07-30 16:39 ` Peter Maydell
2012-07-30 16:40 ` Stefan Hajnoczi
2012-07-30 16:50   ` Dunrong Huang

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).