From 4ac97296408193bffc5c71e51340a042d00723f082756c3913196d48694e5df4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Tesa=C5=99=C3=ADk?= Date: Fri, 14 Mar 2014 07:13:36 +0000 Subject: [PATCH 1/4] Accepting request 224742 from home:juwolf:branches:Kernel:kdump dracut needs rd.neednet=1 commandline parameter to force network activation. Together with Request 224727 to dracut this should solve current kdump-via-network issues (bnc#866771) OBS-URL: https://build.opensuse.org/request/show/224742 OBS-URL: https://build.opensuse.org/package/show/Kernel:kdump/kdump?expand=0&rev=64 --- initrd_network.patch | 29 +++++++++++++++++++++++++++++ kdump.changes | 12 ++++++++++++ kdump.spec | 4 ++++ ledblink_background.patch | 13 +++++++++++++ 4 files changed, 58 insertions(+) create mode 100644 initrd_network.patch create mode 100644 ledblink_background.patch diff --git a/initrd_network.patch b/initrd_network.patch new file mode 100644 index 0000000..039ba21 --- /dev/null +++ b/initrd_network.patch @@ -0,0 +1,29 @@ +--- init/mkdumprd.old 2014-03-04 17:51:17.000000000 +0100 ++++ init/mkdumprd 2014-03-05 17:57:07.606638345 +0100 +@@ -123,6 +123,26 @@ + + 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'" ++ 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 ++ fi ++ + # add mount points + kdump_get_mountpoints || return 1 + i=0 diff --git a/kdump.changes b/kdump.changes index a6fa393..1000c6c 100644 --- a/kdump.changes +++ b/kdump.changes @@ -1,3 +1,15 @@ +------------------------------------------------------------------- +Wed Mar 5 16:58:02 UTC 2014 - juwolf@suse.com + +- Added dracut network activation in initrd to mkdumprd. + Patch added: initrd_network.patch + +------------------------------------------------------------------- +Tue Mar 4 12:19:24 UTC 2014 - juwolf@suse.com + +- Fixed wrong argument for ledblink + ledblink_background.patch: Added + ------------------------------------------------------------------- Sun Mar 2 15:35:11 UTC 2014 - ptesarik@suse.cz diff --git a/kdump.spec b/kdump.spec index afc6265..a24a88a 100644 --- a/kdump.spec +++ b/kdump.spec @@ -49,6 +49,8 @@ PreReq: %insserv_prereq %fillup_prereq mkinitrd Source: %{name}-%{version}.tar.bz2 Source2: %{name}-%{version}-rpmlintrc Source3: kdump.service +Patch1: ledblink_background.patch +Patch2: initrd_network.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build # rename "kdump-helpers" (10.3) -> "kdump" (11.0/SP2) Provides: kdump-helpers = %{version} @@ -86,6 +88,8 @@ Authors: %prep %setup +%patch1 -p0 +%patch2 -p0 %build export CFLAGS="%optflags" diff --git a/ledblink_background.patch b/ledblink_background.patch new file mode 100644 index 0000000..c7c672b --- /dev/null +++ b/ledblink_background.patch @@ -0,0 +1,13 @@ +--- init/save_dump.sh.old 2014-03-04 12:44:06.595720000 +0100 ++++ init/save_dump.sh 2014-03-04 12:44:19.444960000 +0100 +@@ -143,8 +143,8 @@ + 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 From e713d7a61db4a025cb46176da9ccb6c7ee20a4b3b4407f4fbd7fe0876660115d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Tesa=C5=99=C3=ADk?= Date: Fri, 14 Mar 2014 07:22:25 +0000 Subject: [PATCH 2/4] - kdump-ledblink-background.patch: Run kdumptool in the background. - kdump-initrd-network.patch: Added dracut network activation in initrd to mkdumprd. - kdump-ledblink-background.patch: Fixed wrong argument for ledblink. OBS-URL: https://build.opensuse.org/package/show/Kernel:kdump/kdump?expand=0&rev=65 --- ...etwork.patch => kdump-initrd-network.patch | 16 +++++++++--- kdump-ledblink-background.patch | 25 +++++++++++++++++++ kdump.changes | 13 +++++++--- kdump.spec | 4 +-- ledblink_background.patch | 13 ---------- 5 files changed, 49 insertions(+), 22 deletions(-) rename initrd_network.patch => kdump-initrd-network.patch (72%) create mode 100644 kdump-ledblink-background.patch delete mode 100644 ledblink_background.patch diff --git a/initrd_network.patch b/kdump-initrd-network.patch similarity index 72% rename from initrd_network.patch rename to kdump-initrd-network.patch index 039ba21..89c9d84 100644 --- a/initrd_network.patch +++ b/kdump-initrd-network.patch @@ -1,6 +1,16 @@ ---- init/mkdumprd.old 2014-03-04 17:51:17.000000000 +0100 -+++ init/mkdumprd 2014-03-05 17:57:07.606638345 +0100 -@@ -123,6 +123,26 @@ +From: Julian Wolf +Subject: Added dracut network activation in initrd to mkdumprd +Patch-mainline: not yet + +Acked-by: Petr Tesarik + +--- + init/mkdumprd | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +--- a/init/mkdumprd ++++ b/init/mkdumprd +@@ -123,6 +123,26 @@ function run_dracut() DRACUT_ARGS="--force --hostonly --omit 'systemd plymouth resume usrmount'" diff --git a/kdump-ledblink-background.patch b/kdump-ledblink-background.patch new file mode 100644 index 0000000..4db0df0 --- /dev/null +++ b/kdump-ledblink-background.patch @@ -0,0 +1,25 @@ +From: Julian Wolf +Subject: Fixed wrong argument for ledblink. +Patch-mainline: not yet + +There is no --background option for kdumptool ledblink. + +Signed-off-by: Petr Tesarik + +--- + 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 diff --git a/kdump.changes b/kdump.changes index 1000c6c..3eec18f 100644 --- a/kdump.changes +++ b/kdump.changes @@ -1,14 +1,19 @@ +------------------------------------------------------------------- +Fri Mar 14 07:21:41 UTC 2014 - ptesarik@suse.cz + +- kdump-ledblink-background.patch: Run kdumptool in the background. + ------------------------------------------------------------------- Wed Mar 5 16:58:02 UTC 2014 - juwolf@suse.com -- Added dracut network activation in initrd to mkdumprd. - Patch added: initrd_network.patch +- kdump-initrd-network.patch: Added dracut network activation in + initrd to mkdumprd. ------------------------------------------------------------------- Tue Mar 4 12:19:24 UTC 2014 - juwolf@suse.com -- Fixed wrong argument for ledblink - ledblink_background.patch: Added +- kdump-ledblink-background.patch: Fixed wrong argument for + ledblink. ------------------------------------------------------------------- Sun Mar 2 15:35:11 UTC 2014 - ptesarik@suse.cz diff --git a/kdump.spec b/kdump.spec index a24a88a..8a54ec2 100644 --- a/kdump.spec +++ b/kdump.spec @@ -49,8 +49,8 @@ PreReq: %insserv_prereq %fillup_prereq mkinitrd Source: %{name}-%{version}.tar.bz2 Source2: %{name}-%{version}-rpmlintrc Source3: kdump.service -Patch1: ledblink_background.patch -Patch2: initrd_network.patch +Patch1: %{name}-ledblink-background.patch +Patch2: %{name}-initrd-network.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build # rename "kdump-helpers" (10.3) -> "kdump" (11.0/SP2) Provides: kdump-helpers = %{version} diff --git a/ledblink_background.patch b/ledblink_background.patch deleted file mode 100644 index c7c672b..0000000 --- a/ledblink_background.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- init/save_dump.sh.old 2014-03-04 12:44:06.595720000 +0100 -+++ init/save_dump.sh 2014-03-04 12:44:19.444960000 +0100 -@@ -143,8 +143,8 @@ - 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 From 304a65377ba79cbbbb85beea4df8d862b64a9d93fd7257dcb8e59522abee63e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Tesa=C5=99=C3=ADk?= Date: Fri, 14 Mar 2014 07:22:59 +0000 Subject: [PATCH 3/4] Fix patch prefix length. OBS-URL: https://build.opensuse.org/package/show/Kernel:kdump/kdump?expand=0&rev=66 --- kdump.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kdump.spec b/kdump.spec index 8a54ec2..5171f88 100644 --- a/kdump.spec +++ b/kdump.spec @@ -88,8 +88,8 @@ Authors: %prep %setup -%patch1 -p0 -%patch2 -p0 +%patch1 -p1 +%patch2 -p1 %build export CFLAGS="%optflags" From 2104b8c771cf2d344c03d3ec3729fc9e5a12d1681f66e1fb222cbe7aa4eb6799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Tesa=C5=99=C3=ADk?= Date: Fri, 14 Mar 2014 11:18:35 +0000 Subject: [PATCH 4/4] Accepting request 225920 from home:ptesarik:branches:Kernel:kdump Add Xen detection code OBS-URL: https://build.opensuse.org/request/show/225920 OBS-URL: https://build.opensuse.org/package/show/Kernel:kdump/kdump?expand=0&rev=67 --- kdump-0.8.9-detect-xen-dumps.patch | 309 +++++++++++++++++++++++++++++ kdump.changes | 6 + kdump.spec | 2 + 3 files changed, 317 insertions(+) create mode 100644 kdump-0.8.9-detect-xen-dumps.patch diff --git a/kdump-0.8.9-detect-xen-dumps.patch b/kdump-0.8.9-detect-xen-dumps.patch new file mode 100644 index 0000000..70e1c9b --- /dev/null +++ b/kdump-0.8.9-detect-xen-dumps.patch @@ -0,0 +1,309 @@ +From: Petr Tesarik +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 + +--- + 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 + #include + #include ++#include + + #include + #include +@@ -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(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(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(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 +--- 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). + # diff --git a/kdump.changes b/kdump.changes index 3eec18f..a0494d1 100644 --- a/kdump.changes +++ b/kdump.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Fri Mar 14 11:03:35 UTC 2014 - ptesarik@suse.cz + +- kdump-0.8.9-detect-xen-dumps.patch: Add '-X' to makedumpfile when + dumping a Xen host (bnc#864910). + ------------------------------------------------------------------- Fri Mar 14 07:21:41 UTC 2014 - ptesarik@suse.cz diff --git a/kdump.spec b/kdump.spec index 5171f88..8449f8a 100644 --- a/kdump.spec +++ b/kdump.spec @@ -51,6 +51,7 @@ 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} @@ -90,6 +91,7 @@ Authors: %setup %patch1 -p1 %patch2 -p1 +%patch3 -p1 %build export CFLAGS="%optflags"