qemu-kvm/0014-globally-limit-the-maximum-number-of-CPUs.patch

153 lines
5.0 KiB
Diff
Raw Normal View History

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