Blame SOURCES/kvm-vl-exit-if-maxcpus-is-negative.patch

4a2fec
From 72c9f52facf418294ce72056d771591debb2a2f0 Mon Sep 17 00:00:00 2001
4a2fec
From: Sam Bobroff <sbobroff@redhat.com>
4a2fec
Date: Fri, 13 Oct 2017 00:56:26 +0200
4a2fec
Subject: [PATCH 33/34] vl: exit if maxcpus is negative
4a2fec
MIME-Version: 1.0
4a2fec
Content-Type: text/plain; charset=UTF-8
4a2fec
Content-Transfer-Encoding: 8bit
4a2fec
4a2fec
RH-Author: Sam Bobroff <sbobroff@redhat.com>
4a2fec
Message-id: <1507856186-31186-1-git-send-email-sbobroff@redhat.com>
4a2fec
Patchwork-id: 77221
4a2fec
O-Subject: [RHEL7.5 qemu-kvm-rhev PATCH] vl: exit if maxcpus is negative
4a2fec
Bugzilla: 1491743
4a2fec
RH-Acked-by: David Gibson <dgibson@redhat.com>
4a2fec
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
4a2fec
RH-Acked-by: Thomas Huth <thuth@redhat.com>
4a2fec
4a2fec
From: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
4a2fec
4a2fec
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
4a2fec
4a2fec
---Steps to Reproduce---
4a2fec
4a2fec
When passed a negative number to 'maxcpus' parameter, Qemu aborts
4a2fec
with a core dump.
4a2fec
4a2fec
Run the following command with maxcpus argument as negative number
4a2fec
4a2fec
ppc64-softmmu/qemu-system-ppc64 --nographic -vga none -machine
4a2fec
pseries,accel=kvm,kvm-type=HV -m size=200g -device virtio-blk-pci,
4a2fec
drive=rootdisk -drive file=/home/images/pegas-1.0-ppc64le.qcow2,
4a2fec
if=none,cache=none,id=rootdisk,format=qcow2 -monitor telnet
4a2fec
:127.0.0.1:1234,server,nowait -net nic,model=virtio -net
4a2fec
user -redir tcp:2000::22 -device nec-usb-xhci -smp 8,cores=1,
4a2fec
threads=1,maxcpus=-12
4a2fec
4a2fec
(process:12149): GLib-ERROR **: gmem.c:130: failed to allocate
4a2fec
 18446744073709550568 bytes
4a2fec
4a2fec
Trace/breakpoint trap
4a2fec
4a2fec
Reported-by: R.Nageswara Sastry <rnsastry@linux.vnet.ibm.com>
4a2fec
Signed-off-by: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
4a2fec
Message-Id: <1504511031-26834-1-git-send-email-s1seetee@linux.vnet.ibm.com>
4a2fec
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
4a2fec
(cherry picked from commit c0dd10991903c552811d8cbe9231055b1b3a7ebd)
4a2fec
4a2fec
Testing: Run qemu-kvm with "-smp maxcpus=-1".
4a2fec
Signed-off-by: Sam Bobroff <sbobroff@redhat.com>
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 include/sysemu/sysemu.h | 2 +-
4a2fec
 vl.c                    | 6 +++---
4a2fec
 2 files changed, 4 insertions(+), 4 deletions(-)
4a2fec
4a2fec
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
4a2fec
index 54fdc4f..d6a9cd7 100644
4a2fec
--- a/include/sysemu/sysemu.h
4a2fec
+++ b/include/sysemu/sysemu.h
4a2fec
@@ -115,7 +115,7 @@ extern int win2k_install_hack;
4a2fec
 extern int alt_grab;
4a2fec
 extern int ctrl_grab;
4a2fec
 extern int smp_cpus;
4a2fec
-extern int max_cpus;
4a2fec
+extern unsigned int max_cpus;
4a2fec
 extern int cursor_hide;
4a2fec
 extern int graphic_rotate;
4a2fec
 extern int no_quit;
4a2fec
diff --git a/vl.c b/vl.c
4a2fec
index 183b7f7..18b837c 100644
4a2fec
--- a/vl.c
4a2fec
+++ b/vl.c
4a2fec
@@ -164,7 +164,7 @@ Chardev *sclp_hds[MAX_SCLP_CONSOLES];
4a2fec
 int win2k_install_hack = 0;
4a2fec
 int singlestep = 0;
4a2fec
 int smp_cpus = 1;
4a2fec
-int max_cpus = 1;
4a2fec
+unsigned int max_cpus = 1;
4a2fec
 int smp_cores = 1;
4a2fec
 int smp_threads = 1;
4a2fec
 int acpi_enabled = 1;
4a2fec
@@ -4244,8 +4244,8 @@ int main(int argc, char **argv, char **envp)
4a2fec
 
4a2fec
     machine_class->max_cpus = machine_class->max_cpus ?: 1; /* Default to UP */
4a2fec
     if (max_cpus > machine_class->max_cpus) {
4a2fec
-        error_report("Number of SMP CPUs requested (%d) exceeds max CPUs "
4a2fec
-                     "supported by machine '%s' (%d)", max_cpus,
4a2fec
+        error_report("Invalid SMP CPUs %d. The max CPUs "
4a2fec
+                     "supported by machine '%s' is %d", max_cpus,
4a2fec
                      machine_class->name, machine_class->max_cpus);
4a2fec
         exit(1);
4a2fec
     }
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec