Blame SOURCES/0016-use-recommended-max-vcpu-count.patch

1bdc94
From 0abcd4ae8344b523f2b462a182fddf181d2b2fa5 Mon Sep 17 00:00:00 2001
4a2fec
From: Andrew Jones <drjones@redhat.com>
4a2fec
Date: Tue, 21 Jan 2014 10:46:52 +0100
4a2fec
Subject: use recommended max vcpu count
4a2fec
4a2fec
RH-Author: Andrew Jones <drjones@redhat.com>
4a2fec
Message-id: <1390301212-15344-1-git-send-email-drjones@redhat.com>
4a2fec
Patchwork-id: 56862
4a2fec
O-Subject: [RHEL7.0 qemu-kvm PATCH v6] use recommended max vcpu count
4a2fec
Bugzilla: 998708
4a2fec
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
4a2fec
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
4a2fec
RH-Acked-by: Marcelo Tosatti <mtosatti@redhat.com>
4a2fec
4a2fec
The recommended vcpu max limit (KVM_CAP_NR_VCPUS) should be used instead
4a2fec
of the actual max vcpu limit (KVM_CAP_MAX_VCPUS) to give an error.
4a2fec
1bdc94
This commit matches the limit to current KVM_CAP_NR_VCPUS value.
1bdc94
1bdc94
Rebase notes (2.11.0):
1bdc94
- Update commit log
1bdc94
1bdc94
Merged patches 2.12.0:
1bdc94
- 6553300 redhat: globally limit the maximum number of CPUs
1bdc94
- 8453db7 redhat: remove manual max_cpus limitations for ppc
1bdc94
1bdc94
Merged patches (2.11.0):
1bdc94
- fdeef3c1c7 RHEL: Set vcpus hard limit to 240 for Power
1bdc94
- 0584216921 Match POWER max cpus to x86
4a2fec
4a2fec
Signed-off-by: Andrew Jones <drjones@redhat.com>
4a2fec
(cherry picked from commit a4ceb63bdc5cbac19f5f633ec761b9de0dedb55e)
1bdc94
(cherry picked from commit a1f26d85171b4d554225150053700e93ba6eba10)
1bdc94
(cherry picked from commit 00b09fb8ae2fa23abfaba4e89f7daa1ba0ef9ec5)
1bdc94
(cherry picked from commit bd420a814a24c56d1ff1564d92f36219106ef81b)
1bdc94
(cherry picked from commit 79b73eacc15f2c06587734c6259b49d911327369)
4a2fec
---
1bdc94
 accel/kvm/kvm-all.c | 12 ++++++++++++
1bdc94
 vl.c                | 23 +++++++++++++++++++++++
1bdc94
 2 files changed, 35 insertions(+)
4a2fec
4a2fec
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
1bdc94
index ffee68e..3f1c06e 100644
4a2fec
--- a/accel/kvm/kvm-all.c
4a2fec
+++ b/accel/kvm/kvm-all.c
1bdc94
@@ -1587,6 +1587,18 @@ static int kvm_init(MachineState *ms)
4a2fec
     soft_vcpus_limit = kvm_recommended_vcpus(s);
4a2fec
     hard_vcpus_limit = kvm_max_vcpus(s);
4a2fec
 
1bdc94
+#ifdef HOST_PPC64
1bdc94
+    /*
1bdc94
+     * On POWER, the kernel advertises a soft limit based on the
1bdc94
+     * number of CPU threads on the host.  We want to allow exceeding
1bdc94
+     * this for testing purposes, so we don't want to set hard limit
1bdc94
+     * to soft limit as on x86.
1bdc94
+     */
1bdc94
+#else
4a2fec
+    /* RHEL doesn't support nr_vcpus > soft_vcpus_limit */
4a2fec
+    hard_vcpus_limit = soft_vcpus_limit;
1bdc94
+#endif
4a2fec
+
4a2fec
     while (nc->name) {
4a2fec
         if (nc->num > soft_vcpus_limit) {
1bdc94
             warn_report("Number of %s cpus requested (%d) exceeds "
1bdc94
diff --git a/vl.c b/vl.c
1bdc94
index cbd6bcc..f3acab3 100644
1bdc94
--- a/vl.c
1bdc94
+++ b/vl.c
1bdc94
@@ -135,6 +135,12 @@ int main(int argc, char **argv)
1bdc94
 #define MAX_VIRTIO_CONSOLES 1
1bdc94
 #define MAX_SCLP_CONSOLES 1
1bdc94
 
1bdc94
+#if defined(CONFIG_RHV)
1bdc94
+#define RHEL_MAX_CPUS 384
1bdc94
+#else
1bdc94
+#define RHEL_MAX_CPUS 240
1bdc94
+#endif
1bdc94
+
1bdc94
 static const char *data_dir[16];
1bdc94
 static int data_dir_idx;
1bdc94
 const char *bios_name = NULL;
1bdc94
@@ -1520,6 +1526,20 @@ MachineClass *find_default_machine(void)
1bdc94
     return mc;
1bdc94
 }
1bdc94
 
1bdc94
+/* Maximum number of CPUs limited for Red Hat Enterprise Linux */
1bdc94
+static void limit_max_cpus_in_machines(void)
1bdc94
+{
1bdc94
+    GSList *el, *machines = object_class_get_list(TYPE_MACHINE, false);
1bdc94
+
1bdc94
+    for (el = machines; el; el = el->next) {
1bdc94
+        MachineClass *mc = el->data;
1bdc94
+
1bdc94
+        if (mc->max_cpus > RHEL_MAX_CPUS) {
1bdc94
+            mc->max_cpus = RHEL_MAX_CPUS;
1bdc94
+        }
1bdc94
+    }
1bdc94
+}
1bdc94
+
1bdc94
 MachineInfoList *qmp_query_machines(Error **errp)
1bdc94
 {
1bdc94
     GSList *el, *machines = object_class_get_list(TYPE_MACHINE, false);
1bdc94
@@ -4084,6 +4104,9 @@ int main(int argc, char **argv, char **envp)
1bdc94
 
1bdc94
     replay_configure(icount_opts);
1bdc94
 
1bdc94
+    /* Maximum number of CPUs limited for Red Hat Enterprise Linux */
1bdc94
+    limit_max_cpus_in_machines();
1bdc94
+
1bdc94
     machine_class = select_machine();
1bdc94
 
1bdc94
     set_memory_options(&ram_slots, &maxram_size, machine_class);
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec