cryptospore / rpms / qemu-kvm

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