495e37
From 354c9ce982e566ddb3c724a57252986dcb7c36db Mon Sep 17 00:00:00 2001
495e37
From: Andrew Jones <drjones@redhat.com>
495e37
Date: Tue, 21 Jan 2014 10:46:52 +0100
495e37
Subject: globally limit the maximum number of CPUs
495e37
495e37
We now globally limit the number of VCPUs.
495e37
Especially, there is no way one can specify more than
495e37
max_cpus VCPUs for a VM.
495e37
495e37
This allows us the restore the ppc max_cpus limitation to the upstream
495e37
default and minimize the ppc hack in kvm-all.c.
495e37
495e37
Signed-off-by: David Hildenbrand <david@redhat.com>
495e37
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
495e37
Signed-off-by: Danilo Cesar Lemes de Paula <ddepaula@redhat.com>
495e37
---
495e37
 accel/kvm/kvm-all.c | 12 ++++++++++++
495e37
 1 file changed, 12 insertions(+)
495e37
495e37
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
495e37
index eecd8031cf..8f2a53438f 100644
495e37
--- a/accel/kvm/kvm-all.c
495e37
+++ b/accel/kvm/kvm-all.c
495e37
@@ -2423,6 +2423,18 @@ static int kvm_init(MachineState *ms)
495e37
     soft_vcpus_limit = kvm_recommended_vcpus(s);
495e37
     hard_vcpus_limit = kvm_max_vcpus(s);
495e37
 
495e37
+#ifdef HOST_PPC64
495e37
+    /*
495e37
+     * On POWER, the kernel advertises a soft limit based on the
495e37
+     * number of CPU threads on the host.  We want to allow exceeding
495e37
+     * this for testing purposes, so we don't want to set hard limit
495e37
+     * to soft limit as on x86.
495e37
+     */
495e37
+#else
495e37
+    /* RHEL doesn't support nr_vcpus > soft_vcpus_limit */
495e37
+    hard_vcpus_limit = soft_vcpus_limit;
495e37
+#endif
495e37
+
495e37
     while (nc->name) {
495e37
         if (nc->num > soft_vcpus_limit) {
495e37
             warn_report("Number of %s cpus requested (%d) exceeds "
495e37
-- 
495e37
2.27.0
495e37