From 29def10374e810c82ef7e01bcdac0c0e77b42aec Mon Sep 17 00:00:00 2001 From: Andrew Jones 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 Signed-off-by: Miroslav Rezanina Signed-off-by: Danilo Cesar Lemes de Paula 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 (cherry picked from commit a4ceb63bdc5cbac19f5f633ec761b9de0dedb55e) (cherry picked from commit a1f26d85171b4d554225150053700e93ba6eba10) redhat: globally limit the maximum number of CPUs RH-Author: David Hildenbrand 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 RH-Acked-by: Thomas Huth RH-Acked-by: Cornelia Huck 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 Signed-off-by: Miroslav Rezanina redhat: remove manual max_cpus limitations for ppc RH-Author: David Hildenbrand 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 RH-Acked-by: Thomas Huth RH-Acked-by: Cornelia Huck Upstream-status: n/a RH-Author: Andrew Jones 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 RH-Acked-by: Laszlo Ersek RH-Acked-by: Marcelo Tosatti 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. --- 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 f450f25..2d850df 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1869,6 +1869,18 @@ static int kvm_init(MachineState *ms) 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 dd1fadf..7c52255 100644 --- a/vl.c +++ b/vl.c @@ -132,6 +132,8 @@ int main(int argc, char **argv) #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; } +/* 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) { ObjectProperty *prop; @@ -3864,6 +3880,8 @@ int main(int argc, char **argv, char **envp) "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")); -- 1.8.3.1