File kdump-no-xen-secondary-kernel.patch of Package kdump.624

From: Petr Tesarik <ptesarik@suse.cz>
Subject: Avoid Xen kernels as kdump kernel
References: bsc#900418
Patch-mainline: not yet

Since Xen kernels cannot run on bare metal, they must be avoided
as a secondary kernel.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>

---
 kdumptool/findkernel.cc |   22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

--- a/kdumptool/findkernel.cc
+++ b/kdumptool/findkernel.cc
@@ -130,14 +130,26 @@ bool FindKernel::suitableForKdump(const
         }
     }
 
+    Kconfig *kconfig = kt.retrieveKernelConfig();
+    KconfigValue kv;
+
+    // Avoid Xen kernels, because they do not run on bare metal
+    kv = kconfig->get("CONFIG_XEN");
+    if (kv.getType() == KconfigValue::T_TRISTATE &&
+	    kv.getTristateValue() == KconfigValue::ON) {
+        Debug::debug()->dbg("%s is a Xen kernel. Avoid.",
+            kernelImage.c_str());
+	delete kconfig;
+	return false;
+    }
+
     if (strict) {
         string arch = Util::getArch();
-        Kconfig *kconfig = kt.retrieveKernelConfig();
 
         // avoid large number of CPUs on x86 since that increases
         // memory size constraints of the capture kernel
         if (arch == "i386" || arch == "x86_64") {
-            KconfigValue kv = kconfig->get("CONFIG_NR_CPUS");
+            kv = kconfig->get("CONFIG_NR_CPUS");
             if (kv.getType() == KconfigValue::T_INTEGER &&
                     kv.getIntValue() > MAXCPUS_KDUMP) {
                 Debug::debug()->dbg("NR_CPUS of %s is %d >= %d. Avoid.",
@@ -148,17 +160,17 @@ bool FindKernel::suitableForKdump(const
         }
 
         // avoid realtime kernels
-        KconfigValue kv = kconfig->get("CONFIG_PREEMPT_RT");
+        kv = kconfig->get("CONFIG_PREEMPT_RT");
         if (kv.getType() != KconfigValue::T_INVALID) {
             Debug::debug()->dbg("%s is realtime kernel. Avoid.",
                 kernelImage.c_str());
             delete kconfig;
             return false;
         }
-
-        delete kconfig;
     }
 
+    delete kconfig;
+
     return true;
 }