cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-vl-Don-t-silently-change-topology-when-all-smp-optio.patch

619821
From 1f9218a32773bb616f65f581f3a6b22699b2f6be Mon Sep 17 00:00:00 2001
619821
From: Eduardo Habkost <ehabkost@redhat.com>
619821
Date: Tue, 27 Dec 2016 20:43:20 +0100
619821
Subject: [PATCH 2/4] vl: Don't silently change topology when all -smp options
619821
 were set
619821
619821
RH-Author: Eduardo Habkost <ehabkost@redhat.com>
619821
Message-id: <1482871400-24971-1-git-send-email-ehabkost@redhat.com>
619821
Patchwork-id: 73103
619821
O-Subject: [RHEL-7.4 qemu-kvm PATCH] vl: Don't silently change topology when all -smp options were set
619821
Bugzilla: 1375507
619821
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
619821
RH-Acked-by: Andrew Jones <drjones@redhat.com>
619821
RH-Acked-by: David Hildenbrand <david@redhat.com>
619821
619821
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1375507
619821
619821
QEMU tries to change the "threads" option even if it was explicitly set
619821
in the command-line, and it shouldn't do that.
619821
619821
The right thing to do when all options (cpus, sockets, cores, threds)
619821
are explicitly set is to sanity check them and abort in case they don't
619821
make sense (i.e. when sockets*cores*threads < cpus).
619821
619821
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
619821
Reviewed-by: Andrew Jones <drjones@redhat.com>
619821
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
619821
(cherry picked from commit ec2cbbdd80463efd4bc81a9d1362a2acb3097a21)
619821
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
619821
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
619821
---
619821
 vl.c | 8 +++++++-
619821
 1 file changed, 7 insertions(+), 1 deletion(-)
619821
619821
diff --git a/vl.c b/vl.c
619821
index 9756361..7c34b7c 100644
619821
--- a/vl.c
619821
+++ b/vl.c
619821
@@ -1393,8 +1393,14 @@ static void smp_parse(const char *optarg)
619821
         if (cores == 0) {
619821
             threads = threads > 0 ? threads : 1;
619821
             cores = smp / (sockets * threads);
619821
-        } else {
619821
+        } else if (threads == 0) {
619821
             threads = smp / (cores * sockets);
619821
+        } else if (sockets * cores * threads < smp) {
619821
+            fprintf(stderr, "cpu topology: error: "
619821
+                    "sockets (%u) * cores (%u) * threads (%u) < "
619821
+                    "smp_cpus (%u)\n",
619821
+                    sockets, cores, threads, smp);
619821
+            exit(1);
619821
         }
619821
     }
619821
     smp_cpus = smp;
619821
-- 
619821
1.8.3.1
619821