Accepting request 228104 from Kernel:kdump

Update to 0.8.10

OBS-URL: https://build.opensuse.org/request/show/228104
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/kdump?expand=0&rev=66
This commit is contained in:
Stephan Kulow 2014-03-31 18:43:17 +00:00 committed by Git OBS Bridge
commit ba7370d86e
8 changed files with 58 additions and 407 deletions

3
kdump-0.8.10.tar.bz2 Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e9d01a1d35da5a9906bb128338c025dc7ff0cecd508e2a760c7910cfe7a24398
size 3332347

View File

@ -1,309 +0,0 @@
From: Petr Tesarik <ptesarik@suse.cz>
Subject: Add '-X' to makedumpfile when dumping a Xen host
References: bnc#864910
Patch-mainline: 0.8.10
When dumping a Xen virtualization host, kdump should dump only Dom0 and
hypervisor pages, i.e. it should exclude all DomU pages.
A kdumptool flag is introduced to override this default behaviour.
Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
---
NEWS | 4 +
doc/man/kdump.5.txt.in | 7 +-
kdumptool/savedump.cc | 9 ++
kdumptool/util.cc | 166 +++++++++++++++++++++++++++++++++++++++++++++++++
kdumptool/util.h | 20 +++++
sysconfig.kdump.in | 3
6 files changed, 206 insertions(+), 3 deletions(-)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,7 @@
+0.8.10
+------
+ * Filter out DomU pages, when dumping a Xen virtualization host
+
0.8.9
-----
* Fixed dracut hook install
--- a/doc/man/kdump.5.txt.in
+++ b/doc/man/kdump.5.txt.in
@@ -481,7 +481,7 @@ KDUMPTOOL_FLAGS
~~~~~~~~~~~~~~~
This is a space-separated list of flags to tweak the run-time behaviour of
-*kdumptool*(8). Currently, only one flag is supported:
+*kdumptool*(8). These flags are recognized:
*NOSPARSE*::
Disable the creation of sparse-files. This flag is for debugging purposes,
@@ -495,6 +495,11 @@ This is a space-separated list of flags
You can specify this flag to force the use of only one dumping process,
regardless of the value of KDUMP_CPUS.
+*XENALLDOMAINS*::
+ When dumping a Xen virtualization host, *makedumpfile*(8) is normally
+ invoked with the _-X_ option to exclude DomU pages. This flag can be
+ used to include all pages in the dump.
+
Default: ""
KDUMP_NETCONFIG
--- a/kdumptool/savedump.cc
+++ b/kdumptool/savedump.cc
@@ -275,7 +275,12 @@ void SaveDump::saveDump(const RootDirURL
cerr << "Splitting ELF dumps is not supported." << endl;
}
- if (useElf && dumplevel == 0) {
+ bool excludeDomU = false;
+ if (!config->kdumptoolContainsFlag("XENALLDOMAINS") &&
+ Util::isXenCoreDump(m_dump.c_str()))
+ excludeDomU = true;
+
+ if (useElf && dumplevel == 0 && !excludeDomU) {
// use file source?
provider = new FileDataProvider(m_dump.c_str());
m_useMakedumpfile = false;
@@ -287,6 +292,8 @@ void SaveDump::saveDump(const RootDirURL
cmdline << "--split ";
cmdline << config->MAKEDUMPFILE_OPTIONS.value() << " ";
cmdline << "-d " << config->KDUMP_DUMPLEVEL.value() << " ";
+ if (excludeDomU)
+ cmdline << "-X ";
if (useElf)
cmdline << "-E ";
if (useCompressed)
--- a/kdumptool/util.cc
+++ b/kdumptool/util.cc
@@ -26,6 +26,7 @@
#include <sys/types.h>
#include <sys/utsname.h>
#include <sys/stat.h>
+#include <sys/mman.h>
#include <libelf.h>
#include <gelf.h>
@@ -162,6 +163,171 @@ bool Util::isElfFile(const string &file)
} catch (...) {
close(fd);
throw;
+ }
+
+ return ret;
+}
+
+// -----------------------------------------------------------------------------
+static off_t FindElfNoteByName(int fd, off_t offset, size_t sz,
+ const char *name)
+ throw (KError)
+{
+ char *buf, *p;
+ size_t to_read;
+ size_t nlen;
+ off_t ret = (off_t)-1;
+
+ Debug::debug()->trace("FindElfNoteByName(%d, %lu, %lu, %s)",
+ fd, (unsigned long)offset, (unsigned long)sz, name);
+
+ if (lseek(fd, offset, SEEK_SET) == (off_t)-1)
+ throw KSystemError("Cannot seek to ELF notes", errno);
+
+ buf = new char[sz];
+ try {
+ to_read = sz;
+ p = buf;
+ while (to_read) {
+ ssize_t bytes_read = read(fd, p, to_read);
+ if (bytes_read < 0)
+ throw KSystemError("Cannot read ELF note", errno);
+ else if (!bytes_read)
+ throw KError("Unexpected EOF while reading ELF note");
+
+ to_read -= bytes_read;
+ p += bytes_read;
+ }
+
+ nlen = strlen(name);
+ to_read = sz;
+ p = buf;
+ while (to_read) {
+ Elf64_Nhdr *hdr = reinterpret_cast<Elf64_Nhdr*>(p);
+ if (to_read < sizeof(*hdr))
+ break;
+ to_read -= sizeof(*hdr);
+ p += sizeof(*hdr);
+
+ size_t notesz =
+ ((hdr->n_namesz + 3) & (-(Elf64_Word)4)) +
+ ((hdr->n_descsz + 3) & (-(Elf64_Word)4));
+ if (to_read < notesz)
+ break;
+
+ if ((hdr->n_namesz == nlen && !memcmp(p, name, nlen)) ||
+ (hdr->n_namesz == nlen+1 && !memcmp(p, name, nlen+1))) {
+ ret = offset + (p - buf) - sizeof(*hdr);
+ break;
+ }
+
+ to_read -= notesz;
+ p += notesz;
+ }
+ } catch (...) {
+ delete buf;
+ throw;
+ }
+
+ return ret;
+}
+
+// -----------------------------------------------------------------------------
+#define ELF_HEADER_MAPSIZE (128*1024)
+
+bool Util::isXenCoreDump(int fd)
+ throw (KError)
+{
+ void *map = MAP_FAILED;
+ Elf *elf = (Elf*)0;
+ bool ret;
+
+ Debug::debug()->trace("isXenCoreDump(%d)", fd);
+
+ if (elf_version(EV_CURRENT) == EV_NONE)
+ throw KError("libelf is out of date.");
+
+ try {
+ map = mmap(NULL, ELF_HEADER_MAPSIZE, PROT_READ, MAP_PRIVATE, fd, 0);
+ if (map == MAP_FAILED) {
+ map = mmap(NULL, ELF_HEADER_MAPSIZE, PROT_READ,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ if (map == MAP_FAILED)
+ throw KSystemError("Cannot allocate ELF headers", errno);
+
+ size_t to_read = ELF_HEADER_MAPSIZE;
+ char *p = reinterpret_cast<char *>(map);
+ while (to_read) {
+ ssize_t bytes_read = read(fd, p, to_read);
+ if (bytes_read < 0)
+ throw KSystemError("ELF read error", errno);
+ else if (!bytes_read)
+ break;
+
+ to_read -= bytes_read;
+ p += bytes_read;
+ }
+ }
+ elf = elf_memory(reinterpret_cast<char *>(map), ELF_HEADER_MAPSIZE);
+ if (!elf)
+ throw KELFError("elf_memory() failed", elf_errno());
+
+ if (elf_kind(elf) != ELF_K_ELF)
+ return false;
+
+ switch (gelf_getclass(elf)) {
+ case ELFCLASS32:
+ case ELFCLASS64:
+ break;
+ default:
+ throw KError("Unrecognized ELF class");
+ }
+
+ size_t phnum, i;
+ if (elf_getphdrnum(elf, &phnum))
+ throw KELFError("Cannot count ELF program headers", elf_errno());
+
+ for (i = 0; i < phnum; ++i) {
+ GElf_Phdr phdr;
+
+ if (gelf_getphdr(elf, i, &phdr) != &phdr)
+ throw KELFError("getphdr() failed.", elf_errno());
+
+ if (phdr.p_type == PT_NOTE &&
+ FindElfNoteByName(fd, phdr.p_offset, phdr.p_filesz, "Xen")
+ != (off_t)-1) {
+ ret = true;
+ break;
+ }
+ }
+ } catch (...) {
+ if (elf)
+ elf_end(elf);
+ if (map != MAP_FAILED)
+ munmap(map, ELF_HEADER_MAPSIZE);
+ throw;
+ }
+
+ munmap(map, ELF_HEADER_MAPSIZE);
+ elf_end(elf);
+ return ret;
+}
+
+// -----------------------------------------------------------------------------
+bool Util::isXenCoreDump(const string &file)
+ throw (KError)
+{
+ int fd = open(file.c_str(), O_RDONLY);
+ if (fd < 0) {
+ throw KSystemError("Opening of " + file + " failed.", errno);
+ }
+
+ bool ret;
+ try {
+ ret = isXenCoreDump(fd);
+ } catch (...) {
+ close(fd);
+ throw;
}
return ret;
--- a/kdumptool/util.h
+++ b/kdumptool/util.h
@@ -94,6 +94,26 @@ class Util {
throw (KError);
/**
+ * Checks if @p filename is a Xen core dump.
+ *
+ * @param[in] filename the file to check
+ * @return @c true if it's a Xen core dump, @c false otherwise
+ * @exception KError if opening the file failed
+ */
+ static bool isXenCoreDump(const std::string &filename)
+ throw (KError);
+
+ /**
+ * Checks if @p filename is a Xen core dump.
+ *
+ * @param[in] fd a file descriptor
+ * @return @c true if it's a Xen core dump, @c false otherwise
+ * @exception KError if opening the file failed
+ */
+ static bool isXenCoreDump(int fd)
+ throw (KError);
+
+ /**
* Frees a vector.
*/
template <typename T>
--- a/sysconfig.kdump.in
+++ b/sysconfig.kdump.in
@@ -260,7 +260,7 @@ KDUMP_POSTSCRIPT=""
#
KDUMP_COPY_KERNEL="yes"
-## Type: string(NOSPARSE,NOSPLIT)
+## Type: string(NOSPARSE,NOSPLIT,XENALLDOMAINS)
## Default: ""
## ServiceRestart: kdump
#
@@ -268,6 +268,7 @@ KDUMP_COPY_KERNEL="yes"
#
# NOSPARSE disable creation of sparse files.
# NOSPLIT do not pass "--split" to makedumpfile even if KDUMP_CPUS > 1
+# XENALLDOMAINS do not filter out Xen DomU pages
#
# See also: kdump(5).
#

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c94bd8c4c577fc05db4d01f07b0cdb794d94588c1bede848fe99afc0ff8b1133
size 109350

View File

@ -1,59 +0,0 @@
From: Julian Wolf <juwolf@suse.com>
Subject: Added dracut network activation in initrd to mkdumprd
Patch-mainline: not yet
Acked-by: Petr Tesarik <ptesarik@suse.cz>
---
init/mkdumprd | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
--- a/init/mkdumprd
+++ b/init/mkdumprd
@@ -119,10 +119,34 @@ function run_mkinitrd()
# Create a new initrd using dracut {{{
function run_dracut()
{
+ local modules="kdump"
+
. /lib/kdump/setup-kdump.functions
DRACUT_ARGS="--force --hostonly --omit 'systemd plymouth resume usrmount'"
+ # network configuration
+ if [ "$KDUMP_NETCONFIG" = "auto" ] ; then
+ status_message "Network: auto"
+ DRACUT_ARGS+=" --kernel-cmdline 'rd.neednet=1 ip=any'"
+ modules="$modules network"
+ elif [ -z "$KDUMP_NETCONFIG" ] ; then
+ status_message "Network: none"
+ else
+ interface=$(echo "$KDUMP_NETCONFIG" | cut -d ':' -f 1)
+ mode=$(echo "$KDUMP_NETCONFIG" | cut -d ':' -f 2)
+
+ status_message "Network interface: $interface"
+ if [ "$mode" = "static" ] ; then
+ status_message "Network mode: Static IP"
+ DRACUT_ARGS+=" --kernel-cmdline 'rd.neednet=1'"
+ else
+ status_message "Network mode: Automatic IP (DHCP)"
+ DRACUT_ARGS+=" --kernel-cmdline 'rd.neednet=1 ip=${interface}:dhcp'"
+ fi
+ modules="$modules network"
+ fi
+
# add mount points
kdump_get_mountpoints || return 1
i=0
@@ -135,8 +159,10 @@ function run_dracut()
done
# Check for additional modules
- modules="kdump"
for protocol in "${kdump_Protocol[@]}" ; do
+ if [ "$protocol" = "nfs" ]; then
+ modules="$modules nfs"
+ fi
if [ "$protocol" = "cifs" -o "$protocol" = "smb" ]; then
modules="$modules cifs"
fi

View File

@ -1,25 +0,0 @@
From: Julian Wolf <juwolf@suse.com>
Subject: Fixed wrong argument for ledblink.
Patch-mainline: not yet
There is no --background option for kdumptool ledblink.
Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
---
init/save_dump.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/init/save_dump.sh
+++ b/init/save_dump.sh
@@ -143,8 +143,8 @@ FADUMP_ENABLED=/sys/kernel/fadump_enable
FADUMP_RELEASE_MEM=/sys/kernel/fadump_release_mem
#
-# start LED blinking in background
-kdumptool ledblink --background
+# start LED blinking
+kdumptool ledblink &
#
# create core dumps by default here for kdumptool debugging

View File

@ -1,3 +1,34 @@
-------------------------------------------------------------------
Fri Mar 28 13:15:08 UTC 2014 - ptesarik@suse.cz
- specfile cleanup: remove blocks for pre-openSUSE11.0
- fix location of the udev files (see sr 227790).
-------------------------------------------------------------------
Thu Mar 27 15:51:34 UTC 2014 - ptesarik@suse.cz
- Update to 0.8.10
o Support snappy compression algorithm (FATE#315726)
o Improved algorithm for "calibrate"
o Network support for dracut
o Filter out DomU pages, when dumping a Xen virtualization host
(bnc#864910)
o Do not try to copy separate debuginfo files (bnc#869971)
o Unit test for FilePath::listDir() (SUSE Test Initiative)
o delete_dumps: ignore non-kdump directories (FATE#313185)
o fixed the testsuite on non-x86
- include and run the test suite
- kdump-ledblink-background.patch: Dropped.
- kdump-initrd-network.patch: Dropped.
- kdump-0.8.10-detect-xen-dumps.patch: Dropped.
-------------------------------------------------------------------
Tue Mar 18 16:55:26 UTC 2014 - ptesarik@suse.cz
- kdump-0.8.9-detect-xen-dumps.patch: fix uninitialized variable;
without the fix, '-X' is (almost) always added.
-------------------------------------------------------------------
Tue Mar 18 10:28:56 UTC 2014 - ptesarik@suse.cz

View File

@ -18,10 +18,20 @@
%define dracutlibdir %{_prefix}/lib/dracut
%{!?_udevdir: %global _udevdir %(pkg-config --variable=udevdir udev)}
%if "%{_udevdir}" == ""
%if 0%{?suse_version} >= 1230
%global _udevdir /usr/lib/udev
%else
%global _udevdir /lib/udev
%endif
%endif
%define _udevrulesdir %{_udevdir}/rules.d
Url: http://freehg.org/u/bwalle/kdump/
Name: kdump
Version: 0.8.9
Version: 0.8.10
Release: 0
Requires: curl
Requires: makedumpfile
@ -36,12 +46,12 @@ BuildRequires: libcurl-devel
BuildRequires: libelf-devel
BuildRequires: libesmtp-devel
BuildRequires: libopenssl-devel
BuildRequires: libssh2-devel
BuildRequires: libxslt
BuildRequires: pkg-config
BuildRequires: udev
BuildRequires: zlib-devel
#!BuildIgnore: fop
%if %suse_version > 1100
BuildRequires: libssh2-devel
%endif
%if %suse_version > 1220
BuildRequires: systemd
%endif
@ -49,9 +59,6 @@ PreReq: %insserv_prereq %fillup_prereq mkinitrd
Source: %{name}-%{version}.tar.bz2
Source2: %{name}-%{version}-rpmlintrc
Source3: kdump.service
Patch1: %{name}-ledblink-background.patch
Patch2: %{name}-initrd-network.patch
Patch3: %{name}-%{version}-detect-xen-dumps.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
# rename "kdump-helpers" (10.3) -> "kdump" (11.0/SP2)
Provides: kdump-helpers = %{version}
@ -89,9 +96,6 @@ Authors:
%prep
%setup
%patch1 -p1
%patch2 -p1
%patch3 -p1
%build
export CFLAGS="%optflags"
@ -102,10 +106,19 @@ cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} ..
make
cd -
%check
cd build
make test
%install
cd build
make DESTDIR=$RPM_BUILD_ROOT install
cd -
# move udev rules
mkdir -p $RPM_BUILD_ROOT/%{_udevrulesdir}
mv $RPM_BUILD_ROOT/%{_sysconfdir}/udev/rules.d/* $RPM_BUILD_ROOT/%{_udevrulesdir}/
# remove executable bit from non-binaries
chmod -x $RPM_BUILD_ROOT/lib/kdump/setup-kdump.functions
# symlink for init script
mkdir -p $RPM_BUILD_ROOT/sbin
ln -s /etc/init.d/boot.kdump $RPM_BUILD_ROOT/sbin/rckdump
@ -186,7 +199,7 @@ rm -rf $RPM_BUILD_ROOT
%{dracutlibdir}/modules.d/99kdump/
%dir /lib/kdump
/lib/kdump/*
%config %{_sysconfdir}/udev/rules.d/70-kdump.rules
%{_udevrulesdir}/70-kdump.rules
%if %suse_version > 1220
%{_unitdir}/kdump.service
%endif