Accepting request 505675 from home:ptesarik:branches:Kernel:kdump

Fix saving to an NFS target.

OBS-URL: https://build.opensuse.org/request/show/505675
OBS-URL: https://build.opensuse.org/package/show/Kernel:kdump/kdump?expand=0&rev=134
This commit is contained in:
Petr Tesařík 2017-06-22 12:49:29 +00:00 committed by Git OBS Bridge
parent 1d77e6d7e2
commit 77637b9478
4 changed files with 119 additions and 0 deletions

View File

@ -0,0 +1,80 @@
From: Petr Tesarik <ptesarik@suse.com>
Date: Thu Jun 22 14:23:02 2017 +0200
Subject: Fix save_dump to NFS targets
References: bsc#1045541
Upstream: v0.8.17
Git-commit: 11d36a645ab99c9805f9fa3ca9eabce3aa2a9418
For NFS, the parent directory of the target must be mounted, because
the target directory itself does not exist yet.
For this to work, split the target path to directory (i.e. parent
directory) and basename. Then construct a unique mount point from the
host name and the parent directory, and finally append the base name
again to form a subdirectory in the target (to be created by the file
transfer method).
Signed-off-by: Petr Tesarik <ptesarik@suse.com>
---
kdumptool/transfer.cc | 24 +++++++++++-------------
kdumptool/transfer.h | 4 +---
2 files changed, 12 insertions(+), 16 deletions(-)
--- a/kdumptool/transfer.cc
+++ b/kdumptool/transfer.cc
@@ -462,22 +462,20 @@ RootDirURL NFSTransfer::translate(const
if (!rt.check(config->KDUMP_NET_TIMEOUT.value()))
cerr << "WARNING: Dump target not reachable" << endl;
- string mountedDir = parser.getPath();
- FileUtil::nfsmount(parser.getHostname(), mountedDir,
- DEFAULT_MOUNTPOINT, options);
-
+ FilePath path = parser.getPath();
+ string mountedDir = path.dirName();
+ string rest = path.baseName();
m_mountpoint = DEFAULT_MOUNTPOINT;
- m_rest = parser.getPath();
- m_rest.replace(m_rest.begin(), m_rest.begin() + mountedDir.size(), "");
- m_rest.ltrim("/");
+ m_mountpoint.appendPath(parser.getHostname()).appendPath(mountedDir);
+ m_mountpoint.mkdir(true);
+ Debug::debug()->dbg("Path: %s, Mountpoint: %s, Rest: %s",
+ path.c_str(), m_mountpoint.c_str(), rest.c_str());
- (m_prefix = m_mountpoint).appendPath(m_rest);
-
- Debug::debug()->dbg("Mountpoint: %s, Rest: %s, Prefix: $s",
- m_mountpoint.c_str(), m_rest.c_str(), m_prefix.c_str());
+ FileUtil::nfsmount(parser.getHostname(), mountedDir,
+ m_mountpoint, options);
- return RootDirURL("file://" + m_prefix, "");
+ return RootDirURL("file://" + m_mountpoint + PATH_SEPARATOR + rest, "");
}
// -----------------------------------------------------------------------------
@@ -507,7 +505,7 @@ void NFSTransfer::close()
throw (KError)
{
Debug::debug()->trace("NFSTransfer::close()");
- if (m_mountpoint.size() > 0) {
+ if (!m_mountpoint.empty()) {
FileUtil::umount(m_mountpoint);
m_mountpoint.clear();
}
--- a/kdumptool/transfer.h
+++ b/kdumptool/transfer.h
@@ -271,9 +271,7 @@ class NFSTransfer : public URLTransfer {
private:
- std::string m_mountpoint;
- KString m_rest;
- FilePath m_prefix;
+ FilePath m_mountpoint;
FileTransfer *m_fileTransfer;
};

View File

@ -0,0 +1,27 @@
From: Petr Tesarik <ptesarik@suse.com>
Date: Thu Jun 22 14:31:26 2017 +0200
Subject: Invoke subcommand destructors on exit
References: bsc#1045541
Upstream: v0.8.17
Git-commit: ff813cdc274caf7c006d438dbf30d83413bb896e
To execute the destructor for a subcommand, the object must be
explicitly freed in KdumpTool destructor. This fixes a bug that
NFS shares are not unmounted on exit.
Signed-off-by: Petr Tesarik <ptesarik@suse.com>
---
kdumptool/kdumptool.cc | 1 +
1 file changed, 1 insertion(+)
--- a/kdumptool/kdumptool.cc
+++ b/kdumptool/kdumptool.cc
@@ -67,6 +67,7 @@ KdumpTool::~KdumpTool()
throw ()
{
Debug::debug()->trace("KdumpTool::~KdumpTool()");
+ delete m_subcommand;
}
// -----------------------------------------------------------------------------

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Thu Jun 22 12:42:50 UTC 2017 - ptesarik@suse.com
- kdump-fix-save_dump-to-NFS.patch: Fix save_dump to NFS targets
(bsc#1045541).
- kdump-invoke-subcommand-destructors-on-exit.patch: Invoke
subcommand destructors on exit (bsc#1045541).
-------------------------------------------------------------------
Fri Jun 16 12:04:14 UTC 2017 - msuchanek@suse.com

View File

@ -59,6 +59,8 @@ Patch14: %{name}-do-not-free-fadump-memory-when-immediate-reboot-is-reque
Patch15: %{name}-do-not-check-bind-mount.patch
Patch16: %{name}-source-save_dump.patch
Patch17: %{name}-remount-sysroot-readwrite.patch
Patch18: %{name}-fix-save_dump-to-NFS.patch
Patch19: %{name}-invoke-subcommand-destructors-on-exit.patch
BuildRequires: asciidoc
BuildRequires: cmake
BuildRequires: gcc-c++
@ -136,6 +138,8 @@ cp %{S:1} tests/data/
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19 -p1
%build
export CFLAGS="%{optflags}"