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