902636
From c9c3cf721b0e9e359418f64c2a5121c3f8b5d27a Mon Sep 17 00:00:00 2001
26ba25
From: Andrew Jones <drjones@redhat.com>
26ba25
Date: Tue, 21 Jan 2014 10:46:52 +0100
26ba25
Subject: globally limit the maximum number of CPUs
26ba25
26ba25
We now globally limit the number of VCPUs.
26ba25
Especially, there is no way one can specify more than
26ba25
max_cpus VCPUs for a VM.
26ba25
26ba25
This allows us the restore the ppc max_cpus limitation to the upstream
26ba25
default and minimize the ppc hack in kvm-all.c.
26ba25
26ba25
Signed-off-by: David Hildenbrand <david@redhat.com>
26ba25
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
26ba25
Signed-off-by: Danilo Cesar Lemes de Paula <ddepaula@redhat.com>
26ba25
26ba25
Rebase notes (2.11.0):
26ba25
- Removed CONFIG_RHV reference
26ba25
- Update commit log
26ba25
26ba25
Merged patches (2.11.0):
26ba25
- 92fef14623 redhat: remove manual max_cpus limitations for ppc
26ba25
- bb722e9eff redhat: globally limit the maximum number of CPUs
26ba25
- fdeef3c1c7 RHEL: Set vcpus hard limit to 240 for Power
26ba25
- 0584216921 Match POWER max cpus to x86
26ba25
26ba25
Signed-off-by: Andrew Jones <drjones@redhat.com>
26ba25
(cherry picked from commit a4ceb63bdc5cbac19f5f633ec761b9de0dedb55e)
26ba25
(cherry picked from commit a1f26d85171b4d554225150053700e93ba6eba10)
26ba25
26ba25
redhat: globally limit the maximum number of CPUs
26ba25
26ba25
RH-Author: David Hildenbrand <david@redhat.com>
26ba25
Message-id: <20180109103253.24517-2-david@redhat.com>
26ba25
Patchwork-id: 78531
26ba25
O-Subject: [RHEL-7.5 qemu-kvm-ma PATCH v2 1/2] redhat: globally limit the maximum number of CPUs
26ba25
Bugzilla: 1527449
26ba25
RH-Acked-by: David Gibson <dgibson@redhat.com>
26ba25
RH-Acked-by: Thomas Huth <thuth@redhat.com>
26ba25
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
26ba25
26ba25
Upstream-status: n/a
26ba25
26ba25
For RHEL, we support 240, for RHV up to 384 VCPUs. Let's limit this
26ba25
globally instead of fixing up all machines. This way, we can easily
26ba25
change (increase) the product specific levels later.
26ba25
26ba25
Signed-off-by: David Hildenbrand <david@redhat.com>
26ba25
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
26ba25
26ba25
redhat: remove manual max_cpus limitations for ppc
26ba25
26ba25
RH-Author: David Hildenbrand <david@redhat.com>
26ba25
Message-id: <20180109103253.24517-3-david@redhat.com>
26ba25
Patchwork-id: 78532
26ba25
O-Subject: [RHEL-7.5 qemu-kvm-ma PATCH v2 2/2] redhat: remove manual max_cpus limitations for ppc
26ba25
Bugzilla: 1527449
26ba25
RH-Acked-by: David Gibson <dgibson@redhat.com>
26ba25
RH-Acked-by: Thomas Huth <thuth@redhat.com>
26ba25
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
26ba25
26ba25
Upstream-status: n/a
26ba25
26ba25
RH-Author: Andrew Jones <drjones@redhat.com>
26ba25
Message-id: <1390301212-15344-1-git-send-email-drjones@redhat.com>
26ba25
Patchwork-id: 56862
26ba25
O-Subject: [RHEL7.0 qemu-kvm PATCH v6] use recommended max vcpu count
26ba25
Bugzilla: 998708
26ba25
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
26ba25
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
26ba25
RH-Acked-by: Marcelo Tosatti <mtosatti@redhat.com>
26ba25
26ba25
The recommended vcpu max limit (KVM_CAP_NR_VCPUS) should be used instead
26ba25
of the actual max vcpu limit (KVM_CAP_MAX_VCPUS) to give an error.
26ba25
26ba25
This commit matches the limit to current KVM_CAP_NR_VCPUS value.
902636
902636
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
26ba25
---
26ba25
 accel/kvm/kvm-all.c | 12 ++++++++++++
902636
 vl.c                | 18 ++++++++++++++++++
902636
 2 files changed, 30 insertions(+)
26ba25
26ba25
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
902636
index ca00daa2f5..dc3ed7f04e 100644
26ba25
--- a/accel/kvm/kvm-all.c
26ba25
+++ b/accel/kvm/kvm-all.c
902636
@@ -1943,6 +1943,18 @@ static int kvm_init(MachineState *ms)
26ba25
     soft_vcpus_limit = kvm_recommended_vcpus(s);
26ba25
     hard_vcpus_limit = kvm_max_vcpus(s);
26ba25
 
26ba25
+#ifdef HOST_PPC64
26ba25
+    /*
26ba25
+     * On POWER, the kernel advertises a soft limit based on the
26ba25
+     * number of CPU threads on the host.  We want to allow exceeding
26ba25
+     * this for testing purposes, so we don't want to set hard limit
26ba25
+     * to soft limit as on x86.
26ba25
+     */
26ba25
+#else
26ba25
+    /* RHEL doesn't support nr_vcpus > soft_vcpus_limit */
26ba25
+    hard_vcpus_limit = soft_vcpus_limit;
26ba25
+#endif
26ba25
+
26ba25
     while (nc->name) {
26ba25
         if (nc->num > soft_vcpus_limit) {
26ba25
             warn_report("Number of %s cpus requested (%d) exceeds "
26ba25
diff --git a/vl.c b/vl.c
902636
index 9f3e7e7733..1550aa2aaa 100644
26ba25
--- a/vl.c
26ba25
+++ b/vl.c
902636
@@ -134,6 +134,8 @@ int main(int argc, char **argv)
902636
 
26ba25
 #define MAX_VIRTIO_CONSOLES 1
26ba25
 
26ba25
+#define RHEL_MAX_CPUS 384
26ba25
+
26ba25
 static const char *data_dir[16];
26ba25
 static int data_dir_idx;
26ba25
 const char *bios_name = NULL;
902636
@@ -1339,6 +1341,20 @@ static MachineClass *find_default_machine(GSList *machines)
902636
     return NULL;
26ba25
 }
26ba25
 
26ba25
+/* Maximum number of CPUs limited for Red Hat Enterprise Linux */
26ba25
+static void limit_max_cpus_in_machines(void)
26ba25
+{
26ba25
+    GSList *el, *machines = object_class_get_list(TYPE_MACHINE, false);
26ba25
+
26ba25
+    for (el = machines; el; el = el->next) {
26ba25
+        MachineClass *mc = el->data;
26ba25
+
26ba25
+        if (mc->max_cpus > RHEL_MAX_CPUS) {
26ba25
+            mc->max_cpus = RHEL_MAX_CPUS;
26ba25
+        }
26ba25
+    }
26ba25
+}
26ba25
+
902636
 static int machine_help_func(QemuOpts *opts, MachineState *machine)
26ba25
 {
902636
     ObjectProperty *prop;
902636
@@ -3857,6 +3873,8 @@ int main(int argc, char **argv, char **envp)
902636
                      "mutually exclusive");
902636
         exit(EXIT_FAILURE);
902636
     }
26ba25
+    /* Maximum number of CPUs limited for Red Hat Enterprise Linux */
26ba25
+    limit_max_cpus_in_machines();
26ba25
 
902636
     configure_rtc(qemu_find_opts_singleton("rtc"));
902636
 
26ba25
-- 
902636
2.21.0
26ba25