Blame SOURCES/kvm-redhat-globally-limit-the-maximum-number-of-CPUs.patch

9bac43
From bb722e9effd08ea9d64091914c6f09d061017cad Mon Sep 17 00:00:00 2001
9bac43
From: David Hildenbrand <david@redhat.com>
9bac43
Date: Tue, 9 Jan 2018 10:32:52 +0100
9bac43
Subject: [PATCH 02/12] redhat: globally limit the maximum number of CPUs
9bac43
9bac43
RH-Author: David Hildenbrand <david@redhat.com>
9bac43
Message-id: <20180109103253.24517-2-david@redhat.com>
9bac43
Patchwork-id: 78531
9bac43
O-Subject: [RHEL-7.5 qemu-kvm-ma PATCH v2 1/2] redhat: globally limit the maximum number of CPUs
9bac43
Bugzilla: 1527449
9bac43
RH-Acked-by: David Gibson <dgibson@redhat.com>
9bac43
RH-Acked-by: Thomas Huth <thuth@redhat.com>
9bac43
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
9bac43
9bac43
Upstream-status: n/a
9bac43
9bac43
For RHEL, we support 240, for RHV up to 384 VCPUs. Let's limit this
9bac43
globally instead of fixing up all machines. This way, we can easily
9bac43
change (increase) the product specific levels later.
9bac43
9bac43
Signed-off-by: David Hildenbrand <david@redhat.com>
9bac43
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9bac43
---
9bac43
 vl.c | 23 +++++++++++++++++++++++
9bac43
 1 file changed, 23 insertions(+)
9bac43
9bac43
diff --git a/vl.c b/vl.c
9bac43
index bef5ae3..90b542f 100644
9bac43
--- a/vl.c
9bac43
+++ b/vl.c
9bac43
@@ -135,6 +135,12 @@ int main(int argc, char **argv)
9bac43
 #define MAX_VIRTIO_CONSOLES 1
9bac43
 #define MAX_SCLP_CONSOLES 1
9bac43
 
9bac43
+#if defined(CONFIG_RHV)
9bac43
+#define RHEL_MAX_CPUS 384
9bac43
+#else
9bac43
+#define RHEL_MAX_CPUS 240
9bac43
+#endif
9bac43
+
9bac43
 static const char *data_dir[16];
9bac43
 static int data_dir_idx;
9bac43
 const char *bios_name = NULL;
9bac43
@@ -1501,6 +1507,20 @@ MachineClass *find_default_machine(void)
9bac43
     return mc;
9bac43
 }
9bac43
 
9bac43
+/* Maximum number of CPUs limited for Red Hat Enterprise Linux */
9bac43
+static void limit_max_cpus_in_machines(void)
9bac43
+{
9bac43
+    GSList *el, *machines = object_class_get_list(TYPE_MACHINE, false);
9bac43
+
9bac43
+    for (el = machines; el; el = el->next) {
9bac43
+        MachineClass *mc = el->data;
9bac43
+
9bac43
+        if (mc->max_cpus > RHEL_MAX_CPUS) {
9bac43
+            mc->max_cpus = RHEL_MAX_CPUS;
9bac43
+        }
9bac43
+    }
9bac43
+}
9bac43
+
9bac43
 MachineInfoList *qmp_query_machines(Error **errp)
9bac43
 {
9bac43
     GSList *el, *machines = object_class_get_list(TYPE_MACHINE, false);
9bac43
@@ -4130,6 +4150,9 @@ int main(int argc, char **argv, char **envp)
9bac43
 
9bac43
     replay_configure(icount_opts);
9bac43
 
9bac43
+    /* Maximum number of CPUs limited for Red Hat Enterprise Linux */
9bac43
+    limit_max_cpus_in_machines();
9bac43
+
9bac43
     machine_class = select_machine();
9bac43
 
9bac43
     set_memory_options(&ram_slots, &maxram_size, machine_class);
9bac43
-- 
9bac43
1.8.3.1
9bac43