mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
Compare commits
102 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04407d24fc | ||
|
|
bcb8ea09d1 | ||
|
|
88619b6dba | ||
|
|
e127b89624 | ||
|
|
3591b94c42 | ||
|
|
2a29a28f78 | ||
|
|
cb831aea44 | ||
|
|
04be704083 | ||
|
|
1bcfcd3253 | ||
|
|
2dbaf9f991 | ||
|
|
2ea20094d0 | ||
|
|
a80c14d72c | ||
|
|
10518da618 | ||
|
|
e9d1e168b2 | ||
|
|
7567506cca | ||
|
|
524017ac06 | ||
|
|
15774dbe32 | ||
|
|
f247850ff0 | ||
|
|
800ef7cb13 | ||
|
|
48cf3b3809 | ||
|
|
99c8c27302 | ||
|
|
a5c3af1361 | ||
|
|
353c23a157 | ||
|
|
d371ba0db8 | ||
|
|
8308143008 | ||
|
|
d8871197ea | ||
|
|
df338a3bac | ||
|
|
1005e7be7e | ||
|
|
afb14cba7a | ||
|
|
1e450e6f7b | ||
|
|
696a007b62 | ||
|
|
ea5f3f4a1c | ||
|
|
6afd5e97d1 | ||
|
|
b1da8bbbe9 | ||
|
|
6ece595532 | ||
|
|
40d4aa38e9 | ||
|
|
c58cfd1ec1 | ||
|
|
02086f26d2 | ||
|
|
7a2666d727 | ||
|
|
2df532c1fa | ||
|
|
969a439aaa | ||
|
|
f8331a4b8e | ||
|
|
895dc80580 | ||
|
|
d93645d690 | ||
|
|
c3bb6307b8 | ||
|
|
6208c0626a | ||
|
|
3949c62f6f | ||
|
|
8c6c2ef30e | ||
|
|
12c84469fd | ||
|
|
0a8e726d05 | ||
|
|
533df585fd | ||
|
|
c4eb2d5fba | ||
|
|
35029ad010 | ||
|
|
296079f70a | ||
|
|
4f1c73d592 | ||
|
|
1fb859729e | ||
|
|
bbeb0f8445 | ||
|
|
2ae44cb794 | ||
|
|
a0b8033088 | ||
|
|
9cc74839b0 | ||
|
|
b7b7002855 | ||
|
|
55e428a4d7 | ||
|
|
cb09223a56 | ||
|
|
28db3523d0 | ||
|
|
f15e32cdb1 | ||
|
|
094057e265 | ||
|
|
025a2198a4 | ||
|
|
2b938b78aa | ||
|
|
de36fc5259 | ||
|
|
e3e5b6422a | ||
|
|
38343be0fa | ||
|
|
957e612720 | ||
|
|
1d2316caef | ||
|
|
64539853ca | ||
|
|
686c331b69 | ||
|
|
01551f98d5 | ||
|
|
0e2c5907e0 | ||
|
|
68ff79e4c3 | ||
|
|
5b96d86538 | ||
|
|
4043137cd7 | ||
|
|
735d8f5493 | ||
|
|
28efa7d120 | ||
|
|
ebde75eeda | ||
|
|
a645ec0fc0 | ||
|
|
761a185938 | ||
|
|
890b15d158 | ||
|
|
07677668a3 | ||
|
|
fde914fd1c | ||
|
|
35c97a07aa | ||
|
|
45e3f016f4 | ||
|
|
38b520ab4c | ||
|
|
3b6920271e | ||
|
|
a3146409da | ||
|
|
76aa8e4a52 | ||
|
|
f5e6f4a8cb | ||
|
|
80cb1553a3 | ||
|
|
706f59b9d9 | ||
|
|
02cc902b90 | ||
|
|
ff2fb42868 | ||
|
|
451bf7fbc6 | ||
|
|
d2a4a8b0f3 | ||
|
|
fe5753d34d |
7
.gitignore
vendored
7
.gitignore
vendored
@@ -9,6 +9,10 @@
|
||||
tags
|
||||
TAGS
|
||||
|
||||
# Ignore coverage data
|
||||
*.gcda
|
||||
*.gcno
|
||||
|
||||
#
|
||||
# Ignore generated executables and other generated files
|
||||
#
|
||||
@@ -25,6 +29,7 @@ dasdview/dasdview
|
||||
dump2tar/src/dump2tar
|
||||
fdasd/fdasd
|
||||
hmcdrvfs/hmcdrvfs
|
||||
hsavmcore/check-dep-fuse
|
||||
hsavmcore/hsavmcore
|
||||
hyptop/hyptop
|
||||
ip_watcher/xcec-bridge
|
||||
@@ -98,7 +103,9 @@ zipl/boot/*.bin
|
||||
zipl/boot/*.exec
|
||||
zipl/boot/data.h
|
||||
zipl/src/chreipl_helper.device-mapper
|
||||
zdev/src/zdev_id
|
||||
zipl/src/zipl
|
||||
zipl/src/zipl-editenv
|
||||
zipl/src/zipl_helper.device-mapper
|
||||
zkey/check-dep-zkey
|
||||
zkey/check-dep-zkey-cryptsetup
|
||||
|
||||
@@ -2,6 +2,7 @@ List of all individuals having contributed content to s390-tools
|
||||
----------------------------------------------------------------
|
||||
|
||||
- Alexander Egorenkov
|
||||
- Alexandra Winter
|
||||
- Alexey Ishchuk
|
||||
- Andreas Herrmann
|
||||
- Andre Wild
|
||||
@@ -110,6 +111,7 @@ List of all individuals having contributed content to s390-tools
|
||||
- Swen Schillig
|
||||
- Taraka R. Bodireddy
|
||||
- Thomas Heidrich
|
||||
- Thomas Huth
|
||||
- Thomas Richter
|
||||
- Thomas Spatzier
|
||||
- Thomas Weber
|
||||
|
||||
48
CHANGELOG.md
48
CHANGELOG.md
@@ -1,5 +1,53 @@
|
||||
Release history for s390-tools (MIT version)
|
||||
--------------------------------------------
|
||||
* __v2.19.0 (2021-11-10)__
|
||||
|
||||
For Linux kernel version: 5.15
|
||||
|
||||
Add new tools / libraries:
|
||||
- chreipl-fcp-mpath: New toolset that uses multipath information to change
|
||||
the configured FCP re-IPL path on detecting issues with the current path
|
||||
|
||||
Changes of existing tools:
|
||||
- dbginfo.sh: Add retry timeout and remove possible blocking "blockdev --report"
|
||||
- dbginfo.sh: Collect config- and debug-data for chreipl-fcp-mpath
|
||||
- hsci: Add support for multiple MAC addresses
|
||||
|
||||
Bug Fixes:
|
||||
- lshwc: Fix compile error for gcc <8.1
|
||||
- zdump: Various clean-ups and fixes
|
||||
- ziomon: Correct throughput calculation in ziorep_printers
|
||||
- zipl: Fix segmentation fault when setting stage3_parms
|
||||
|
||||
* __v2.18.0 (2021-10-01)__
|
||||
|
||||
For Linux kernel version: 5.14
|
||||
|
||||
Add new tools:
|
||||
- scripts: Add tool for parsing sclp s390dbf logs
|
||||
- zdev: Add udev rule helper tool
|
||||
- zipl-editenv: Add tool to operate with zIPL environment installed in the boot record
|
||||
|
||||
Changes of existing tools:
|
||||
- Makefile: Fix order of build of libraries for parallel builds
|
||||
- dbginfo.sh: Add collection in area of timedate, coredump and --check option
|
||||
- dbginfo.sh: Add exception on dump2tar for /sys/kernel/mm/page_idle/bitmap
|
||||
- dbginfo.sh: Cleanup of outdated sections and general code rework
|
||||
- dbginfo.sh: Collect zipl boot menu entries from boot loader specification
|
||||
- lszcrypt: Add support for vfio-ap status field
|
||||
- lszcrypt: Improved output for deconfig cards and queues
|
||||
- lszfcp: Add linkdown case to host marker of extended output
|
||||
- zdev: Add auto-config for PCI and crypto devices
|
||||
- zdump: Introduce multi-level message logging
|
||||
- zipl: Add support for environment block interpretation
|
||||
- zkey-cryptsetup: Support LUKS2 volumes with integrity support enabled
|
||||
|
||||
Bug Fixes:
|
||||
- hsavmcore: Avoid recompilation of overlay during install step
|
||||
- libkmipclient: Fix parsing of hex values for XML and JSON encoding
|
||||
- vmur/vmur.cpp: Fix error handling on transfer failure
|
||||
- zdump: Lots of smaller fixes across the board
|
||||
|
||||
* __v2.17.0 (2021-07-07)__
|
||||
|
||||
For Linux kernel version: 5.12 / 5.13
|
||||
|
||||
28
Makefile
28
Makefile
@@ -3,16 +3,22 @@ ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/ar
|
||||
# Include common definitions
|
||||
include common.mak
|
||||
|
||||
LIB_DIRS = libvtoc libutil libzds libdasd libvmdump libccw libvmcp libekmfweb \
|
||||
libseckey libkmipclient
|
||||
#
|
||||
# BASELIBS: Libraries that have no dependency to other libraries in s390-tools
|
||||
# LIBS: Libraries that can have a dependency to base libraries
|
||||
# TOOLS: Tools that can have a dependency to base libraries or libraries
|
||||
#
|
||||
BASELIB_DIRS = libutil libseckey
|
||||
LIB_DIRS = libvtoc libzds libdasd libvmdump libccw libvmcp libekmfweb \
|
||||
libkmipclient
|
||||
TOOL_DIRS = zipl zdump fdasd dasdfmt dasdview tunedasd \
|
||||
tape390 osasnmpd qetharp ip_watcher qethconf scripts zconf \
|
||||
vmconvert vmcp man mon_tools dasdinfo vmur cpuplugd ipl_tools \
|
||||
ziomon iucvterm hyptop cmsfs-fuse qethqoat zfcpdump zdsfs cpumf \
|
||||
systemd hmcdrvfs cpacfstats zdev dump2tar zkey netboot etc zpcictl \
|
||||
genprotimg lsstp hsci hsavmcore
|
||||
genprotimg lsstp hsci hsavmcore chreipl-fcp-mpath
|
||||
|
||||
SUB_DIRS = $(LIB_DIRS) $(TOOL_DIRS)
|
||||
SUB_DIRS = $(BASELIB_DIRS) $(LIB_DIRS) $(TOOL_DIRS)
|
||||
|
||||
all: $(TOOL_DIRS)
|
||||
clean: $(TOOL_DIRS)
|
||||
@@ -26,9 +32,10 @@ MAKECMDGOALS = all
|
||||
endif
|
||||
|
||||
#
|
||||
# We have to build the libraries before the tools are built. Otherwise
|
||||
# the tools would trigger parallel "make -C" builds for libraries in
|
||||
# case of "make -j".
|
||||
# We have to build the base libraries before the other libraries are built,
|
||||
# and then build the other libraries before the tools are built. Otherwise the
|
||||
# other libraries and tools would trigger parallel "make -C" builds for the
|
||||
# base libraries and the other libraries in case of "make -j".
|
||||
#
|
||||
# MAKECMDGOALS contains the list of goals, e.g. "clean all". We use
|
||||
# "foreach" to generate a ";" separated list of "make -C <target>".
|
||||
@@ -45,7 +52,12 @@ $(TOOL_DIRS): $(LIB_DIRS)
|
||||
$(MAKE) -C $@ TOPDIR=$(TOPDIR) ARCH=$(ARCH) $(goal) ;)
|
||||
.PHONY: $(TOOL_DIRS)
|
||||
|
||||
$(LIB_DIRS):
|
||||
$(LIB_DIRS): $(BASELIB_DIRS)
|
||||
$(foreach goal,$(MAKECMDGOALS), \
|
||||
$(MAKE) -C $@ TOPDIR=$(TOPDIR) ARCH=$(ARCH) $(goal) ;)
|
||||
.PHONY: $(LIB_DIRS)
|
||||
|
||||
$(BASELIB_DIRS):
|
||||
$(foreach goal,$(MAKECMDGOALS), \
|
||||
$(MAKE) -C $@ TOPDIR=$(TOPDIR) ARCH=$(ARCH) $(goal) ;)
|
||||
.PHONY: $(BASELIB_DIRS)
|
||||
|
||||
28
README.md
28
README.md
@@ -109,6 +109,9 @@ Package contents
|
||||
feature. Those traces are filtered with the zfcpdbf script, i.e. merge
|
||||
several traces, make it more readable etc.
|
||||
|
||||
* sclpdbf:
|
||||
Display debug data for the sclp kernel component.
|
||||
|
||||
* scsi_logging_level:
|
||||
Create, get or set the logging level for the SCSI logging facility.
|
||||
|
||||
@@ -267,6 +270,10 @@ Package contents
|
||||
can be time consuming and prevent the HSA memory from being reused
|
||||
by other LPARs.
|
||||
|
||||
* chreipl-fcp-mpath:
|
||||
Use multipath information to change the configured FCP re-IPL path on
|
||||
detecting issues with the current path.
|
||||
|
||||
For more information refer to the following publications:
|
||||
|
||||
* "Device Drivers, Features, and Commands" chapter "Useful Linux commands"
|
||||
@@ -304,11 +311,11 @@ build options:
|
||||
|
||||
This table lists additional build or install options:
|
||||
|
||||
| __COMPONENT__ | __OPTION__ | __TOOLS__ |
|
||||
|------------------|:----------------------------:|:--------------:|
|
||||
| dracut | `HAVE_DRACUT` | zdev |
|
||||
| initramfs-tools | `HAVE_INITRAMFS` | zdev |
|
||||
| | `ZDEV_ALWAYS_UPDATE_INITRD` | zdev |
|
||||
| __COMPONENT__ | __OPTION__ | __TOOLS__ |
|
||||
|------------------|:----------------------------:|:-----------------------:|
|
||||
| dracut | `HAVE_DRACUT` | zdev, chreipl-fcp-mpath |
|
||||
| initramfs-tools | `HAVE_INITRAMFS` | zdev |
|
||||
| | `ZDEV_ALWAYS_UPDATE_INITRD` | zdev |
|
||||
|
||||
The s390-tools build process uses "pkg-config" if available and hard-coded
|
||||
compiler and linker options otherwise.
|
||||
@@ -462,3 +469,14 @@ the different tools are provided:
|
||||
(libxml2-devel.rpm), and libcurl version 7.59 or newer (libcurl-devel.rpm).
|
||||
Tip: you may skip the libkmipclient build by adding `HAVE_OPENSSL=0`,
|
||||
`HAVE_JSONC=0`, `HAVE_LIBXML2=0`, or `HAVE_LIBCURL=0` to the make invocation.
|
||||
|
||||
* chreipl-fcp-mpath:
|
||||
For a complete list and documentation of the requirements, installation and
|
||||
uninstallation, please see
|
||||
[chreipl-fcp-mpath/README.md](chreipl-fcp-mpath/README.md).
|
||||
|
||||
Summarized: chreipl-fcp-mpath requires GNU Bash, GNU Core Utilities,
|
||||
util-linux, udev, and multipath-tools. When using `HAVE_DRACUT=1` with the
|
||||
make invocation, it also requires dracut. When using `ENABLE_DOC=1` with the
|
||||
make invocation to build a man page and render the README.md as HTML, make
|
||||
further requires pandoc, GNU awk, and GNU Gzip for the build process.
|
||||
|
||||
13
chreipl-fcp-mpath/.gitignore
vendored
Normal file
13
chreipl-fcp-mpath/.gitignore
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
# build artifacts
|
||||
/chreipl-fcp-mpath-common.sh
|
||||
/chreipl-fcp-mpath-is-ipl-tgt
|
||||
/chreipl-fcp-mpath-is-ipl-vol
|
||||
/chreipl-fcp-mpath-is-reipl-zfcp
|
||||
/chreipl-fcp-mpath-record-volume-identifier
|
||||
/chreipl-fcp-mpath-try-change-ipl-path
|
||||
/dracut/dracut.conf.d/70-chreipl-fcp-mpath.conf
|
||||
/README.html
|
||||
/README.pdf
|
||||
/chreipl-fcp-mpath.md
|
||||
/chreipl-fcp-mpath.7
|
||||
/chreipl-fcp-mpath.7.gz
|
||||
259
chreipl-fcp-mpath/Makefile
Normal file
259
chreipl-fcp-mpath/Makefile
Normal file
@@ -0,0 +1,259 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
# chreipl-fcp-mpath: use multipath information to change FCP IPL target
|
||||
# (C) Copyright IBM Corp. 2021
|
||||
#
|
||||
# Uses the following system-utilities (and shell-builtins):
|
||||
# Utilities list in GNU Make Conventions:
|
||||
# https://www.gnu.org/software/make/manual/make.html#Utilities-in-Makefiles
|
||||
# Those necessary for sourced Makefiles:
|
||||
# - ../common.mak
|
||||
# - chreipl-fcp-mpath.mak
|
||||
# bash:
|
||||
# - bash
|
||||
# If $(ENABLE_DOC) is `1`:
|
||||
# GNU Gzip:
|
||||
# - gzip
|
||||
# GNU awk:
|
||||
# - gawk
|
||||
|
||||
override SHELL := /bin/bash
|
||||
override .SHELLFLAGS := -O globstar -O nullglob -O extglob -c
|
||||
|
||||
# Include common s390-tools definitions
|
||||
include ../common.mak
|
||||
|
||||
# Include common chreipl-fcp-mpath definitions
|
||||
include chreipl-fcp-mpath.mak
|
||||
|
||||
# Local setting: .make.config
|
||||
# You may create a file named like this in the same directory as this
|
||||
# Makefile, and customize the build this way (e.g. re-define variables
|
||||
# set in `chreipl-fcp-mpath.mak`, or define a `CHREIPLZFCPMP_POST_INSTALL`
|
||||
# that is automatically called after each installation)
|
||||
ifneq ($(wildcard .make.config),)
|
||||
include $(wildcard .make.config)
|
||||
endif
|
||||
|
||||
#
|
||||
## Build
|
||||
#
|
||||
|
||||
.PHONY: chreipl-fcp-mpath chreipl-fcp-mpath-clean
|
||||
chreipl-fcp-mpath:
|
||||
chreipl-fcp-mpath-clean:
|
||||
all: chreipl-fcp-mpath
|
||||
clean: chreipl-fcp-mpath-clean
|
||||
|
||||
# common function used in the helper scripts
|
||||
CHREIPL_FCP_MPATH_COMMON := \
|
||||
chreipl-fcp-mpath-common.sh
|
||||
CHREIPL_FCP_MPATH_UDEV_HELPER := \
|
||||
chreipl-fcp-mpath-is-ipl-tgt \
|
||||
chreipl-fcp-mpath-is-ipl-vol \
|
||||
chreipl-fcp-mpath-is-reipl-zfcp \
|
||||
chreipl-fcp-mpath-record-volume-identifier \
|
||||
chreipl-fcp-mpath-try-change-ipl-path
|
||||
|
||||
$(CHREIPL_FCP_MPATH_UDEV_HELPER) $(CHREIPL_FCP_MPATH_COMMON): $(MAKEFILE_LIST)
|
||||
$(CHREIPL_FCP_MPATH_UDEV_HELPER) $(CHREIPL_FCP_MPATH_COMMON): % : %.in
|
||||
$(call chreiplzfcpmp-sed-buildvar-replace,$(<),$(@))
|
||||
chmod a+x $(@)
|
||||
|
||||
$(CHREIPL_FCP_MPATH_UDEV_HELPER): $(CHREIPL_FCP_MPATH_COMMON)
|
||||
|
||||
.PHONY: chreipl-fcp-mpath-udev-helper-clean
|
||||
chreipl-fcp-mpath-udev-helper-clean:
|
||||
rm -f $(CHREIPL_FCP_MPATH_UDEV_HELPER) $(CHREIPL_FCP_MPATH_COMMON)
|
||||
|
||||
udev/rules.d/70-chreipl-fcp-mpath.rules: $(CHREIPL_FCP_MPATH_UDEV_HELPER)
|
||||
|
||||
chreipl-fcp-mpath: udev/rules.d/70-chreipl-fcp-mpath.rules
|
||||
chreipl-fcp-mpath-clean: chreipl-fcp-mpath-udev-helper-clean
|
||||
|
||||
dracut/dracut.conf.d/70-chreipl-fcp-mpath.conf: $(MAKEFILE_LIST)
|
||||
dracut/dracut.conf.d/70-chreipl-fcp-mpath.conf: % : %.in
|
||||
$(call chreiplzfcpmp-sed-buildvar-replace,$(<),$(@))
|
||||
|
||||
.PHONY: chreipl-fcp-mpath-dracut-clean
|
||||
chreipl-fcp-mpath-dracut-clean:
|
||||
rm -f dracut/dracut.conf.d/70-chreipl-fcp-mpath.conf
|
||||
|
||||
chreipl-fcp-mpath: dracut/dracut.conf.d/70-chreipl-fcp-mpath.conf
|
||||
chreipl-fcp-mpath-clean: chreipl-fcp-mpath-dracut-clean
|
||||
|
||||
ifeq ($(ENABLE_DOC),1)
|
||||
|
||||
.PHONY: chreipl-fcp-mpath-doc
|
||||
chreipl-fcp-mpath-doc: README.html chreipl-fcp-mpath.7
|
||||
|
||||
ifeq ($(ENABLE_DOC_PDF),1)
|
||||
chreipl-fcp-mpath-doc: README.pdf
|
||||
|
||||
README.pdf: PANDOCFLAGS += -M title="chreipl-fcp-mpath" -M subtitle="README"
|
||||
endif
|
||||
|
||||
README.html: PANDOCFLAGS += -M title="chreipl-fcp-mpath" -M subtitle="README"
|
||||
|
||||
chreiplzfcpmp-doc-man-meta = \
|
||||
-M title="CHREIPL-FCP-MPATH" \
|
||||
-V header="Administrator Manual" \
|
||||
-V section="7" \
|
||||
-V footer="s390-tools $(S390_TOOLS_RELEASE)"
|
||||
|
||||
chreipl-fcp-mpath.7: PANDOCFLAGS += $(chreiplzfcpmp-doc-man-meta)
|
||||
|
||||
.INTERMEDIATE: chreipl-fcp-mpath.md
|
||||
chreipl-fcp-mpath.md: README.md
|
||||
gawk -- '/NOT-IN-MAN \{/,/NOT-IN-MAN \}/ { next } { print }' $(<) > $(@)
|
||||
|
||||
.PHONY: chreipl-fcp-mpath-doc-clean
|
||||
chreipl-fcp-mpath-doc-clean:
|
||||
rm -f README.html README.pdf chreipl-fcp-mpath.md chreipl-fcp-mpath.7
|
||||
|
||||
chreipl-fcp-mpath: chreipl-fcp-mpath-doc
|
||||
chreipl-fcp-mpath-clean: chreipl-fcp-mpath-doc-clean
|
||||
|
||||
endif
|
||||
|
||||
#
|
||||
## Install
|
||||
#
|
||||
|
||||
.PHONY: chreipl-fcp-mpath-install
|
||||
# The content of `CHREIPLZFCPMP_POST_INSTALL` (bash script) is automatically
|
||||
# called *after* installing chreipl-fcp-mpath during `make install`. If not
|
||||
# defined (the default), nothing happens. You may define this on the make
|
||||
# command line, or by creating a `.make.config` and defining the variable in
|
||||
# there.
|
||||
chreipl-fcp-mpath-install:
|
||||
$(CHREIPLZFCPMP_POST_INSTALL)
|
||||
|
||||
install: chreipl-fcp-mpath-install
|
||||
|
||||
# install udev rules
|
||||
INSTDIRS += $(UDEVRULESDIR)
|
||||
|
||||
.PHONY: chreipl-fcp-mpath-install-udev-rules
|
||||
chreipl-fcp-mpath-install-udev-rules: | $(DESTDIR)$(UDEVRULESDIR)
|
||||
chreipl-fcp-mpath-install-udev-rules: udev/rules.d/70-chreipl-fcp-mpath.rules
|
||||
$(INSTALL_DATA) -t $(DESTDIR)$(UDEVRULESDIR) \
|
||||
udev/rules.d/70-chreipl-fcp-mpath.rules
|
||||
|
||||
chreipl-fcp-mpath-install: chreipl-fcp-mpath-install-udev-rules
|
||||
|
||||
# install udev helper programs
|
||||
INSTDIRS += $(UDEVDIR)
|
||||
|
||||
.PHONY: chreipl-fcp-mpath-install-udev-helper
|
||||
chreipl-fcp-mpath-install-udev-helper: | $(DESTDIR)$(UDEVDIR)
|
||||
chreipl-fcp-mpath-install-udev-helper: $(CHREIPL_FCP_MPATH_UDEV_HELPER)
|
||||
$(INSTALL_EXEC) -t $(DESTDIR)$(UDEVDIR) $(CHREIPL_FCP_MPATH_UDEV_HELPER)
|
||||
|
||||
chreipl-fcp-mpath-install: chreipl-fcp-mpath-install-udev-helper
|
||||
|
||||
# install common library files
|
||||
INSTDIRS += $(CHREIPLZFCPMPDIR)
|
||||
|
||||
.PHONY: chreipl-fcp-mpath-install-libfiles
|
||||
chreipl-fcp-mpath-install-libfiles: | $(DESTDIR)$(CHREIPLZFCPMPDIR)
|
||||
chreipl-fcp-mpath-install-libfiles: $(CHREIPL_FCP_MPATH_COMMON)
|
||||
$(INSTALL_DATA) -t $(DESTDIR)$(CHREIPLZFCPMPDIR) \
|
||||
$(CHREIPL_FCP_MPATH_COMMON)
|
||||
|
||||
chreipl-fcp-mpath-install: chreipl-fcp-mpath-install-libfiles
|
||||
|
||||
ifeq ($(HAVE_DRACUT),1)
|
||||
|
||||
# install dracut config files
|
||||
INSTDIRS += $(DRACUTCONFDIR)
|
||||
|
||||
.PHONY: chreipl-fcp-mpath-install-dracut-config
|
||||
chreipl-fcp-mpath-install-dracut-config: | $(DESTDIR)$(DRACUTCONFDIR)
|
||||
chreipl-fcp-mpath-install-dracut-config: dracut/dracut.conf.d/70-chreipl-fcp-mpath.conf
|
||||
$(INSTALL_DATA) -t $(DESTDIR)$(DRACUTCONFDIR) \
|
||||
dracut/dracut.conf.d/70-chreipl-fcp-mpath.conf
|
||||
|
||||
chreipl-fcp-mpath-install: chreipl-fcp-mpath-install-dracut-config
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(ENABLE_DOC),1)
|
||||
|
||||
# chreipl-fcp-mpath: install man page
|
||||
INSTDIRS += $(MANDIR)
|
||||
|
||||
.PHONY: chreipl-fcp-mpath-install-man-page
|
||||
chreipl-fcp-mpath-install-man-page: | $(DESTDIR)$(MANDIR)/man7
|
||||
chreipl-fcp-mpath-install-man-page: chreipl-fcp-mpath.7
|
||||
$(GZIP) -fk --best chreipl-fcp-mpath.7
|
||||
$(INSTALL_DATA) -t $(DESTDIR)$(MANDIR)/man7 \
|
||||
chreipl-fcp-mpath.7.gz
|
||||
|
||||
chreipl-fcp-mpath-install: chreipl-fcp-mpath-install-man-page
|
||||
|
||||
.PHONY: chreipl-fcp-mpath-install-man-page-clean
|
||||
chreipl-fcp-mpath-install-man-page-clean:
|
||||
rm -f chreipl-fcp-mpath.7.gz
|
||||
|
||||
chreipl-fcp-mpath-clean: chreipl-fcp-mpath-install-man-page-clean
|
||||
|
||||
endif
|
||||
|
||||
#
|
||||
## Utility
|
||||
#
|
||||
|
||||
# Utilities for the debug feature of chreipl-fcp-mpath-common.sh.
|
||||
#
|
||||
# When `chreipl-fcp-mpath` is built with D=1 (default is D=0), each run
|
||||
# of one of the helper scripts will create a debug log in $(DEBUGOUTDIR)
|
||||
# (default: /run/udev) which among other things contains the complete shell
|
||||
# trace of that script run, with some added information that would not be
|
||||
# inspectable otherwise with just the trace.
|
||||
#
|
||||
# There is currently no way of enabling/disabling this at runtime.
|
||||
#
|
||||
# chreipl-fcp-mpath-common.sh defines debug log file name as
|
||||
# "chreiplzfcpmp-${debug_trace_tag}-${SEQNUM:-0}.XXXXXXXXXX" where SEQNUM is a
|
||||
# udev rule environment variable and each X is replaced with some [[:alnum:]]
|
||||
# by mktemp. For a definition of `debug_trace_tag`, please see the comments
|
||||
# in the source.
|
||||
#
|
||||
# The following targets can be used for some simple access and filtering of the
|
||||
# logs during development.
|
||||
|
||||
DEBUG_LOG_GLOB = $(DEBUGOUTDIR)/chreiplzfcpmp-[[:digit:]][[:digit:]][[:alpha:]][[:alpha:]][[:alpha:]][[:alpha:]]-+([[:digit:]]).[[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]]
|
||||
|
||||
# display all debug log files on the system
|
||||
.PHONY: chreipl-fcp-mpath-debug-logs
|
||||
chreipl-fcp-mpath-debug-logs:
|
||||
@ls -1d $(DEBUG_LOG_GLOB)
|
||||
|
||||
# display only debug log files of script runs that exited with status 0 (= good)
|
||||
#
|
||||
# XXX: `sed -n -e '$p'` is used instead of `tail -n1` to prevent an other
|
||||
# dependency just for that (both invocations do the same thing).
|
||||
.PHONY: chreipl-fcp-mpath-debug-logs-filter-good
|
||||
chreipl-fcp-mpath-debug-logs-filter-good:
|
||||
@for lg in $(DEBUG_LOG_GLOB); do \
|
||||
sed -e '/^+ trap_exit$$/,/^+ trap - EXIT$$/d' "$${lg}" \
|
||||
| sed -n -e '$$p' \
|
||||
| grep -q -e '^+ exit 0$$' || continue; \
|
||||
ls -d "$${lg}"; \
|
||||
done
|
||||
|
||||
# display only debug log files of script runs that didn't exit with status 0
|
||||
# (= bad)
|
||||
.PHONY: chreipl-fcp-mpath-debug-logs-filter-bad
|
||||
chreipl-fcp-mpath-debug-logs-filter-bad:
|
||||
@for lg in $(DEBUG_LOG_GLOB); do \
|
||||
sed -e '/^+ trap_exit$$/,/^+ trap - EXIT$$/d' "$${lg}" \
|
||||
| sed -n -e '$$p' \
|
||||
| grep -q -e '^+ exit 0$$' && continue; \
|
||||
ls -d "$${lg}"; \
|
||||
done
|
||||
|
||||
.PHONY: chreipl-fcp-mpath-debug-logs-clean
|
||||
chreipl-fcp-mpath-debug-logs-clean:
|
||||
rm -f $(DEBUG_LOG_GLOB)
|
||||
269
chreipl-fcp-mpath/README.md
Normal file
269
chreipl-fcp-mpath/README.md
Normal file
@@ -0,0 +1,269 @@
|
||||
<!-- markdown documentation: https://github.github.com/gfm/ -->
|
||||
|
||||
NAME
|
||||
====
|
||||
|
||||
chreipl-fcp-mpath - use multipath information for re-IPL path failover on a
|
||||
running Linux instance
|
||||
|
||||
DESCRIPTION
|
||||
===========
|
||||
|
||||
The IPL process of Linux on Z or LinuxONE from an FCP-attached SCSI volume uses
|
||||
exactly one path to the volume. If this path is unavailable, the IPL fails.
|
||||
|
||||
The **chreipl-fcp-mpath** toolset monitors **udev** events about paths to the
|
||||
re-IPL volume. If the currently configured re-IPL path becomes unavailable, the
|
||||
toolset checks for operational paths to the same volume. If available, it
|
||||
reconfigures the re-IPL settings to use an operational path.
|
||||
|
||||
Thus, re-IPL from an FCP-attached SCSI volume can be successful despite path
|
||||
failures on a running Linux instance if at least one path to the re-IPL volume
|
||||
remains operational.
|
||||
|
||||
**Chreipl-fcp-mpath** requires **udev**, **multipathd** and **dm-multipath**.
|
||||
Once installed, the toolset runs automatically and autonomously. No user
|
||||
intervention is possible or required.
|
||||
|
||||
Other than installing the toolset, there is no user interface for
|
||||
**chreipl-fcp-mpath**.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
The **chreipl-fcp-mpath** tool has the following requirements on the
|
||||
Linux instance that is being monitored:
|
||||
|
||||
- The Linux instance must have started successfully, during IPL.
|
||||
|
||||
- The running Linux instance must use **dm-multipath** and **multipathd** for
|
||||
the configured re-IPL volume - a volume that contains a zipl boot record
|
||||
and has one of its paths used in the re-IPL configuration.
|
||||
|
||||
- **udev** must run.
|
||||
|
||||
- The toolset must observe at least one event about the configured re-IPL
|
||||
path. Examples for such events are: the SCSI disk comes online, or a path
|
||||
of the corresponding multipath device goes down or comes back online.
|
||||
|
||||
- The WWID of the re-IPL volume must not change while the Linux instance is
|
||||
running.
|
||||
|
||||
- When the configured re-IPL path becomes unavailable while the Linux
|
||||
instance is running, at least one operational path to the re-IPL volume
|
||||
must be available, or must become available. If no such path is available
|
||||
when the Linux instance is rebooted, the re-IPL path is not changed.
|
||||
|
||||
- The tool assumes that any manually reconfigured re-IPL device is valid and
|
||||
operational.
|
||||
|
||||
The tool treats a newly configured re-IPL device like the initially
|
||||
configured re-IPL device. In particular, if the newly configured re-IPL
|
||||
device fulfills the requirements of the tool, re-IPL path failover takes
|
||||
place if the configured re-IPL path becomes unavailable.
|
||||
|
||||
Caution with Manual Changes to the Configured re-IPL Target
|
||||
-----------------------------------------------------------
|
||||
|
||||
**chreipl-fcp-mpath** is designed to accept operator-inititated changes of the
|
||||
re-IPL device. However, concurrent changes by the operator and tool driven
|
||||
changes can result in the operator change being overwritten.
|
||||
|
||||
To avoid this problem, change the re-IPL device only during steady-state
|
||||
operations, when no path events happen. Alternatively, make sure that no events
|
||||
are processed while you change the device. See [EXAMPLES](#examples) for one
|
||||
way to suspend event processing.
|
||||
|
||||
MESSAGES
|
||||
========
|
||||
|
||||
During monitoring and event processing, **chreipl-fcp-mpath** writes messages
|
||||
to the syslog.
|
||||
|
||||
When the configured re-IPL path is changed to a different path to the same
|
||||
volume (priority *daemon.notice*):
|
||||
|
||||
> Changed re-IPL path to: \<device-bus-id\>:\<wwpn\>:\<lun\>.
|
||||
|
||||
When a path event indicates that the last available path has become
|
||||
non-operational (priority *daemon.alert*):
|
||||
|
||||
> The re-IPL device cannot be changed because no operational path to the
|
||||
> re-IPL volume remains. The next re-IPL might fail unless you re-attach or
|
||||
> enable at least one valid path to the re-IPL volume.
|
||||
|
||||
When changing the configured re-IPL device failed because of an error with the
|
||||
used Linux kernel interface (priority *daemon.crit*):
|
||||
|
||||
> Changing the re-IPL device failed. The current re-IPL settings might be
|
||||
> inconsistent. Check and correct the settings (see the README.md of
|
||||
> chreipl-fcp-mpath) to make sure that the current re-IPL device is valid.
|
||||
|
||||
A failure to change the re-IPL device can indicate an inconsistent setting that
|
||||
cannot be corrected automatically by **chreipl-fcp-mpath**. As a result, the
|
||||
next re-IPL might fail or might not use the intended re-IPL device.
|
||||
|
||||
You can use the following tools to check and correct the current settings:
|
||||
|
||||
- **lsreipl** to confirm that the intended re-IPL device is configured;
|
||||
- **chreipl** to change the re-IPL device;
|
||||
- **lszfcp** to inspect the state of available paths to the re-IPL device.
|
||||
|
||||
<!-- NOT-IN-MAN { -->
|
||||
|
||||
SOFTWARE REQUIREMENTS
|
||||
=====================
|
||||
|
||||
**chreipl-fcp-mpath** integrates into s390-tools's build and install
|
||||
infrastructure. Use **make** to build it. No explicit dependency management is
|
||||
in place, but the toolset has some software dependencies besides the
|
||||
requirements in section [Requirements](#requirements):
|
||||
|
||||
- GNU Bash;
|
||||
- GNU Core Utilities (mktemp, readlink, sync, truncate);
|
||||
- util-linux (flock, hexdump, logger);
|
||||
- udev / systemd-udev;
|
||||
- multipath-tools.
|
||||
|
||||
To make use of the optional dracut configuration you need: dracut.
|
||||
|
||||
To build and install the documentation (man page) you need:
|
||||
|
||||
- pandoc;
|
||||
- GNU Core Utilities (date);
|
||||
- GNU awk;
|
||||
- GNU Gzip.
|
||||
|
||||
INSTALLATION
|
||||
============
|
||||
|
||||
If your distribution includes a packaged version of **chreipl-fcp-mpath**,
|
||||
either as a separate package or as part of a **s390-tools** package, install
|
||||
that package. Otherwise, you can either install it from source as part of
|
||||
**s390-tools** or separately.
|
||||
|
||||
To install **chreipl-fcp-mpath** as part of **s390-tools**, use **make** on the
|
||||
top-level directory of your **s390-tools** distribution. Installing the entire
|
||||
distribution might overwrite other already installed tools.
|
||||
|
||||
To install the tool separately, change into the **chreipl-fcp-mpath**
|
||||
directory, and use **make** there.
|
||||
|
||||
You need *root* privileges to install the tool into the root file system.
|
||||
|
||||
Calling **make** runs the build steps. Calling **make install** runs the build
|
||||
steps and copies the resulting components to their final destination.
|
||||
**s390-tools** offers more options and targets to customize the build (see
|
||||
**make help**).
|
||||
|
||||
**chreipl-fcp-mpath** has the following optional build options:
|
||||
|
||||
| Option | Values | Default | Effect
|
||||
| :----- | :----: | :-----: | :-----
|
||||
| HAVE_DRACUT | 0, 1 | 0 | Install a dracut configuration file that includes **chreipl-fcp-mpath** in the initial ramdisks built with **dracut**.
|
||||
| ENABLE_DOC | 0, 1 | 0 | Build and install a man page for **chreipl-fcp-mpath**.
|
||||
|
||||
Specify any options as arguments for both the **make** and **make install**
|
||||
command as shown in the following example:
|
||||
|
||||
~ # cd chreipl-fcp-mpath/
|
||||
~ # make HAVE_DRACUT=1 ENABLE_DOC=1
|
||||
~ # make HAVE_DRACUT=1 ENABLE_DOC=1 install
|
||||
|
||||
After the installation, reload the udev rules database:
|
||||
|
||||
~ # udevadm control --reload
|
||||
|
||||
*The toolset is now active on your running Linux instance.*
|
||||
|
||||
If you use the *HAVE_DRACUT=1* option, also rebuild your
|
||||
initial ramdisk, to immediately include the toolset instead of
|
||||
waiting for the next kernel update.
|
||||
|
||||
How to rebuild the initial ramdisk and the naming scheme for the
|
||||
resulting file or files depends on your distribution.
|
||||
The following example applies to Fedora and to Red Hat Enterprise Linux:
|
||||
|
||||
~ # dracut --force /boot/initramfs-"$(uname -r)".img "$(uname -r)"
|
||||
|
||||
For SUSE Linux Enterprise Server run for example:
|
||||
|
||||
~ # dracut --hostonly --force /boot/initrd-"$(uname -r)" "$(uname -r)"
|
||||
|
||||
These commands replace the initial ramdisk for the currently running kernel.
|
||||
If your distribution uses **zipl** as its boot loader, run **zipl** to refresh
|
||||
the boot record to find the new initial ramdisk.
|
||||
|
||||
~ # zipl
|
||||
|
||||
With dracut and documentation enabled, **make install** deploys the following
|
||||
files to these default locations:
|
||||
|
||||
/usr/lib/chreipl-fcp-mpath/chreipl-fcp-mpath-common.sh
|
||||
/usr/lib/dracut/dracut.conf.d/70-chreipl-fcp-mpath.conf
|
||||
/usr/lib/udev/chreipl-fcp-mpath-is-ipl-tgt
|
||||
/usr/lib/udev/chreipl-fcp-mpath-is-ipl-vol
|
||||
/usr/lib/udev/chreipl-fcp-mpath-is-reipl-zfcp
|
||||
/usr/lib/udev/chreipl-fcp-mpath-record-volume-identifier
|
||||
/usr/lib/udev/chreipl-fcp-mpath-try-change-ipl-path
|
||||
/usr/lib/udev/rules.d/70-chreipl-fcp-mpath.rules
|
||||
/usr/share/man/man7/chreipl-fcp-mpath.7.gz
|
||||
|
||||
UNINSTALL
|
||||
=========
|
||||
|
||||
If your distribution includes a separately from **s390-tools** packaged version
|
||||
of **chreipl-fcp-mpath**, uninstall that package.
|
||||
|
||||
For installations without distribution packaging, you cannot uninstall
|
||||
**chreipl-fcp-mpath** with **make**.
|
||||
|
||||
Instead, remove the toolset by deleting the installed files as listed in
|
||||
[INSTALLATION](#installation)), reload the udev rules database, and rebuild all
|
||||
modified initial ramdisks as described in [INSTALLATION](#installation)).
|
||||
|
||||
<!-- NOT-IN-MAN } -->
|
||||
|
||||
EXAMPLES
|
||||
========
|
||||
|
||||
Manual Changes to the Configured re-IPL Device
|
||||
----------------------------------------------
|
||||
|
||||
As outlined in [DESCRIPTION](#description), be cautious when manually changing
|
||||
the configured re-IPL device. Assure that your reconfiguration actions do not
|
||||
collide with concurrent automatic event processing by **chreipl-fcp-mpath**.
|
||||
You can avoid such collisions, by stopping event processing, making your
|
||||
changes, and then re-enabling event processing. You need *root* privileges for
|
||||
running the commands in the following example:
|
||||
|
||||
~ # udevadm settle
|
||||
~ # udevadm control --stop-exec-queue
|
||||
~ # chreipl ...
|
||||
~ # udevadm control --start-exec-queue
|
||||
|
||||
Listing messages with journalctl
|
||||
--------------------------------
|
||||
|
||||
If your Linux instance includes **journalctl**, use the following command to
|
||||
list all messages that are issued by **chreipl-fcp-mpath**:
|
||||
|
||||
~ # journalctl -t chreipl-fcp-mpath
|
||||
|
||||
To list only messages that were issued since the last IPL, use this command:
|
||||
|
||||
~ # journalctl -t chreipl-fcp-mpath -b
|
||||
|
||||
REPORTING BUGS
|
||||
==============
|
||||
|
||||
Use the **Issues** functionality on GitHub to report any bugs in
|
||||
**chreipl-fcp-mpath**:
|
||||
[s390-tools Issues](<https://github.com/ibm-s390-linux/s390-tools/issues> "Link to the s390-tools Issues page").
|
||||
|
||||
SEE ALSO
|
||||
========
|
||||
|
||||
**chreipl**(8), **dracut**(8), **journalctl**(1), **lsreipl(8)**,
|
||||
**lszfcp**(8), **multipath**(8), **multipathd**(8), **udev**(7),
|
||||
**udevadm**(8), **zipl**(8)
|
||||
447
chreipl-fcp-mpath/chreipl-fcp-mpath-common.sh.in
Normal file
447
chreipl-fcp-mpath/chreipl-fcp-mpath-common.sh.in
Normal file
@@ -0,0 +1,447 @@
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
# chreipl-fcp-mpath: use multipath information to change FCP IPL target
|
||||
# (C) Copyright IBM Corp. 2021
|
||||
#
|
||||
# Uses the following system-utilities (and shell-builtins):
|
||||
# GNU coreutils:
|
||||
# - mktemp
|
||||
# - readlink
|
||||
# - sync
|
||||
# util-linux:
|
||||
# - flock
|
||||
# - logger
|
||||
|
||||
# Makes use of udev event environment variables:
|
||||
# SEQNUM
|
||||
|
||||
# (1) expand failed globs to an empty string
|
||||
# (2) extended pattern matching to strip leading/trailing whitespaces
|
||||
shopt -s nullglob extglob
|
||||
# (1) don't overwrite existing files using redirects (e.g.: `>`)
|
||||
set -o noclobber
|
||||
|
||||
# make sure any state files created are only writeable by the owning user
|
||||
umask 027
|
||||
|
||||
# create log if DEBUG is enabled (with Make: D=1)
|
||||
#
|
||||
# Each script importing this library and expecting a debug log to be created
|
||||
# must declare a *trace tag* in a variable `debug_trace_tag`. This is used as
|
||||
# identifier in the log file name. The format is:
|
||||
#
|
||||
# [[:digit:]][[:digit:]][[:alpha:]][[:alpha:]][[:alpha:]][[:alpha:]]
|
||||
# \ /\ /
|
||||
# --------\ /-------- -------------------\ /-------------------
|
||||
# \/ \/
|
||||
# relative position of some unique abbreviation for the script
|
||||
# execution in the name, excluding any common prefix
|
||||
# udev rules
|
||||
if '@DEBUG@' && [ -v debug_trace_tag ] && tlg="$(
|
||||
mktemp -p '@debugoutdir@' \
|
||||
"chreiplzfcpmp-${debug_trace_tag}-${SEQNUM:-0}.XXXXXXXXXX" \
|
||||
2>/dev/null)"
|
||||
then
|
||||
readonly tlg
|
||||
exec >|"${tlg}" 2>&1
|
||||
set -x
|
||||
set
|
||||
else
|
||||
unset tlg
|
||||
fi
|
||||
|
||||
declare -gr ID_FILE='@chreiplzfcpmp-id-file@'
|
||||
declare -gr FW_LOCK_FILE='@chreiplzfcpmp-fwlock-file@'
|
||||
|
||||
declare -gA TRAP_EXIT_FN=()
|
||||
declare -gf trap_exit 1>/dev/null
|
||||
function trap_exit() {
|
||||
local fn
|
||||
|
||||
for fn in "${TRAP_EXIT_FN[@]}"; do
|
||||
"${fn}"
|
||||
done
|
||||
|
||||
trap - EXIT
|
||||
}
|
||||
trap trap_exit EXIT
|
||||
|
||||
# Output variables:
|
||||
# id_file_unlock_exclusive_create() - call to unlock when finished with
|
||||
# critical section
|
||||
#
|
||||
# XXX: `id_file_lock_*` can't be taken recursively
|
||||
function id_file_lock_exclusive_create() {
|
||||
declare -g ID_FILE_LOCK=""
|
||||
|
||||
# prevent concurrent file creation
|
||||
#
|
||||
# First, open the file defined in ${ID_FILE} for writing; this will
|
||||
# succeed and create the file only if it doesn't exist already. If the
|
||||
# file already exist, the first open attempt will fail and we fall
|
||||
# back to opening it only for reading; this will always succeed if the
|
||||
# file already exists (the reason why the first attempty failed). In
|
||||
# both cases store the corresponding file descriptor in
|
||||
# ${ID_FILE_LOCK}.
|
||||
#
|
||||
# XXX: This should be race free.
|
||||
# open() with O_EXCL... is atomic (we set `noclobber` as shell
|
||||
# option); at least as long as we talk about a local FS.
|
||||
if ! { exec {ID_FILE_LOCK}>"${ID_FILE}"; } 2>/dev/null; then
|
||||
{ exec {ID_FILE_LOCK}<"${ID_FILE}"; } 2>/dev/null \
|
||||
|| return 1
|
||||
fi
|
||||
|
||||
declare -gf id_file_unlock_exclusive_create 1>/dev/null
|
||||
function id_file_unlock_exclusive_create() {
|
||||
if [ -v ID_FILE_LOCK ]; then
|
||||
sync "${ID_FILE}" 2>/dev/null
|
||||
# release file and implicitly the lock, if taken
|
||||
exec {ID_FILE_LOCK}>&-
|
||||
unset ID_FILE_LOCK
|
||||
fi
|
||||
|
||||
unset "TRAP_EXIT_FN[id_file_unlock_exclusive_create]"
|
||||
}
|
||||
TRAP_EXIT_FN+=(
|
||||
[id_file_unlock_exclusive_create]=id_file_unlock_exclusive_create
|
||||
)
|
||||
|
||||
flock --exclusive --timeout 5 "${ID_FILE_LOCK}" || return 2
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Output variables:
|
||||
# id_file_unlock_exclusive_no_create() - call to unlock when finished with
|
||||
# critical section
|
||||
#
|
||||
# XXX: `id_file_lock_*` can't be taken recursively
|
||||
function id_file_lock_exclusive_no_create() {
|
||||
declare -g ID_FILE_LOCK=""
|
||||
|
||||
# Open the file defined in ${ID_FILE} for reading, and store the
|
||||
# corresponding file descriptor in ${ID_FILE_LOCK}.
|
||||
#
|
||||
# XXX: return code is used in `chreipl-fcp-mpath-try-change-ipl-path`
|
||||
{ exec {ID_FILE_LOCK}<"${ID_FILE}"; } 2>/dev/null || return 1
|
||||
|
||||
declare -gf id_file_unlock_exclusive_no_create 1>/dev/null
|
||||
function id_file_unlock_exclusive_no_create() {
|
||||
if [ -v ID_FILE_LOCK ]; then
|
||||
sync "${ID_FILE}" 2>/dev/null
|
||||
# release file and implicitly the lock, if taken
|
||||
exec {ID_FILE_LOCK}<&-
|
||||
unset ID_FILE_LOCK
|
||||
fi
|
||||
|
||||
unset "TRAP_EXIT_FN[id_file_unlock_exclusive_no_create]"
|
||||
}
|
||||
TRAP_EXIT_FN+=(
|
||||
[id_file_unlock_exclusive_no_create]=id_file_unlock_exclusive_no_create
|
||||
)
|
||||
|
||||
flock --exclusive --timeout 5 "${ID_FILE_LOCK}" || return 2
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Output variables:
|
||||
# id_file_unlock_shared_no_create() - call to unlock when finished with
|
||||
# critical section
|
||||
#
|
||||
# XXX: `id_file_lock_*` can't be taken recursively
|
||||
function id_file_lock_shared_no_create() {
|
||||
declare -g ID_FILE_LOCK=""
|
||||
|
||||
# Open the file defined in ${ID_FILE} for reading, and store the
|
||||
# corresponding file descriptor in ${ID_FILE_LOCK}.
|
||||
{ exec {ID_FILE_LOCK}<"${ID_FILE}"; } 2>/dev/null || return 1
|
||||
|
||||
declare -gf id_file_unlock_shared_no_create 1>/dev/null
|
||||
function id_file_unlock_shared_no_create() {
|
||||
if [ -v ID_FILE_LOCK ]; then
|
||||
# release file and implicitly the lock, if taken
|
||||
exec {ID_FILE_LOCK}<&-
|
||||
unset ID_FILE_LOCK
|
||||
fi
|
||||
|
||||
unset "TRAP_EXIT_FN[id_file_unlock_shared_no_create]"
|
||||
}
|
||||
TRAP_EXIT_FN+=(
|
||||
[id_file_unlock_shared_no_create]=id_file_unlock_shared_no_create
|
||||
)
|
||||
|
||||
flock --shared --timeout 5 "${ID_FILE_LOCK}" || return 2
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Output variables:
|
||||
# firmware_unlock_exclusive() - call to unlock when finished with critical section
|
||||
#
|
||||
# XXX: `firmware_lock_*` can't be taken recursively
|
||||
function firmware_lock_exclusive() {
|
||||
declare -g FIRMWARE_LOCK=""
|
||||
|
||||
# Open the file defined in ${FW_LOCK_FILE} for reading, and store the
|
||||
# corresponding file descriptor in ${FIRMWARE_LOCK} (it doesn't matter
|
||||
# whether this is a normal file or directory). This file descriptor
|
||||
# will only be used for locking - not for actual I/O.
|
||||
{ exec {FIRMWARE_LOCK}<"${FW_LOCK_FILE}"; } 2>/dev/null || return 1
|
||||
|
||||
declare -gf firmware_unlock_exclusive 1>/dev/null
|
||||
function firmware_unlock_exclusive() {
|
||||
if [ -v FIRMWARE_LOCK ]; then
|
||||
# release file and implicitly the lock, if taken
|
||||
exec {FIRMWARE_LOCK}<&-
|
||||
unset FIRMWARE_LOCK
|
||||
fi
|
||||
|
||||
unset "TRAP_EXIT_FN[firmware_unlock_exclusive]"
|
||||
}
|
||||
TRAP_EXIT_FN+=([firmware_unlock_exclusive]=firmware_unlock_exclusive)
|
||||
|
||||
flock --exclusive --timeout 5 "${FIRMWARE_LOCK}" || return 2
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Output variables:
|
||||
# firmware_unlock_shared() - call to unlock when finished with critical section
|
||||
#
|
||||
# XXX: `firmware_lock_*` can't be taken recursively
|
||||
function firmware_lock_shared() {
|
||||
declare -g FIRMWARE_LOCK=""
|
||||
|
||||
# Open the file defined in ${FW_LOCK_FILE} for reading, and store the
|
||||
# corresponding file descriptor in ${FIRMWARE_LOCK} (it doesn't matter
|
||||
# whether this is a normal file or directory). This file descriptor
|
||||
# will only be used for locking - not for actual I/O.
|
||||
{ exec {FIRMWARE_LOCK}<"${FW_LOCK_FILE}"; } 2>/dev/null || return 1
|
||||
|
||||
declare -gf firmware_unlock_shared 1>/dev/null
|
||||
function firmware_unlock_shared() {
|
||||
if [ -v FIRMWARE_LOCK ]; then
|
||||
# release file and implicitly the lock, if taken
|
||||
exec {FIRMWARE_LOCK}<&-
|
||||
unset FIRMWARE_LOCK
|
||||
fi
|
||||
|
||||
unset "TRAP_EXIT_FN[firmware_unlock_shared]"
|
||||
}
|
||||
TRAP_EXIT_FN+=([firmware_unlock_shared]=firmware_unlock_shared)
|
||||
|
||||
flock --shared --timeout 5 "${FIRMWARE_LOCK}" || return 2
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Output variables:
|
||||
# IPL_TYPE
|
||||
# IPL_BUSID
|
||||
# IPL_WWPN
|
||||
# IPL_LUN
|
||||
function firmware_get_ipl_information() {
|
||||
declare -g IPL_TYPE="" IPL_BUSID="" IPL_WWPN="" IPL_LUN=""
|
||||
|
||||
# Take lock so we don't see any intermediate state from other helpers
|
||||
# running in parallel
|
||||
firmware_lock_shared || return 5
|
||||
|
||||
{ read -r IPL_TYPE _ < /sys/firmware/reipl/reipl_type; } 2>/dev/null \
|
||||
|| return 1
|
||||
{ read -r IPL_BUSID _ < /sys/firmware/reipl/fcp/device; } 2>/dev/null \
|
||||
|| return 2
|
||||
{ read -r IPL_WWPN _ < /sys/firmware/reipl/fcp/wwpn; } 2>/dev/null \
|
||||
|| return 3
|
||||
{ read -r IPL_LUN _ < /sys/firmware/reipl/fcp/lun; } 2>/dev/null \
|
||||
|| return 4
|
||||
|
||||
firmware_unlock_shared
|
||||
|
||||
# show read values in debug log if enabled
|
||||
if '@DEBUG@'; then
|
||||
declare -p IPL_TYPE IPL_BUSID IPL_WWPN IPL_LUN 1>&2
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Input:
|
||||
# 1: absolute canonical path to the scsi device in sysfs, e.g.:
|
||||
# /sys/devices/css0/0.0.0014/0.0.1700/host1/rport-1:0-0/target1:0:0/1:0:0:1075789848
|
||||
# Output variables:
|
||||
# SDEV_LUN
|
||||
function sdev_get_lun() {
|
||||
local sdev="${1}" sdev_lun_str
|
||||
# bash uses `intmax_t` as width for integer variables, and glibc
|
||||
# defines this either as `long int` on 64 bit systems, or
|
||||
# `long long int` on other.
|
||||
local -i sdev_lun=0 fcp_lun=0
|
||||
|
||||
sdev_lun_str="${sdev##*:}"
|
||||
# e.g.: 1075789848
|
||||
[[ "${sdev_lun_str}" == +([[:digit:]]) ]] || return 1
|
||||
# "cast" to integer
|
||||
sdev_lun="${sdev_lun_str}"
|
||||
|
||||
# convert the Linux integer LUN format to the hexadecimal 64 bit T10
|
||||
# LUN representation format used by many s390x interfaces
|
||||
(( fcp_lun = (((sdev_lun >> 0) & 0xffff) << 48)
|
||||
| (((sdev_lun >> 16) & 0xffff) << 32)
|
||||
| (((sdev_lun >> 32) & 0xffff) << 16)
|
||||
| (((sdev_lun >> 48) & 0xffff) << 0) ))
|
||||
# the '0x' prefix is part of the length
|
||||
printf -v SDEV_LUN "%#018llx" "${fcp_lun}"
|
||||
|
||||
# show read values in debug log if enabled
|
||||
if '@DEBUG@'; then
|
||||
declare -p SDEV_LUN 1>&2
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Input:
|
||||
# 1: path to the scsi device in sysfs, e.g.:
|
||||
# /sys/devices/css0/0.0.0014/0.0.1700/host1/rport-1:0-0/target1:0:0/1:0:0:1075789848
|
||||
# , or a symlink pointing to the scsi device, e.g.:
|
||||
# /sys/class/block/sds/device
|
||||
# Output variables:
|
||||
# SDEV_BUSID
|
||||
# SDEV_WWPN
|
||||
# SDEV_LUN
|
||||
function sdev_get_fcp_addressing() {
|
||||
local sdev="${1}" fcp_lun rport rport_wwpn zfcp_dev
|
||||
|
||||
declare -g SDEV_BUSID="" SDEV_WWPN="" SDEV_LUN=""
|
||||
|
||||
sdev="$(readlink -se "${sdev}")" || return 1
|
||||
|
||||
# get the LUN for this SDEV
|
||||
#
|
||||
# sets ${SDEV_LUN}
|
||||
sdev_get_lun "${sdev}" || return 2
|
||||
|
||||
# get the WWPN of the remote port this SDEV is attached to
|
||||
printf -v rport "%s" "${sdev}"/../../fc_remote_ports/rport-*:*-*
|
||||
# e.g.: /sys/devices/css0/0.0.0016/0.0.1740/host0/rport-0:0-1/fc_remote_ports/rport-0:0-1
|
||||
[ "${rport}" != "" ] || return 3
|
||||
|
||||
# XXX: This works even if the rport is currently in a bad
|
||||
# state, so e.g. when it has just gone down because of a
|
||||
# cable pull.
|
||||
{ read -r rport_wwpn _ < "${rport}"/port_name; } 2>/dev/null \
|
||||
|| return 4
|
||||
|
||||
# The Linux kernel doesn't guarantee the same format as in
|
||||
# /sys/firmware/..., so make sure it is the one we expect.
|
||||
[[ "${rport_wwpn}" =~ ^0x[[:xdigit:]]{1,16}$ ]] || return 5
|
||||
# the '0x' prefix is part of the length
|
||||
printf -v rport_wwpn "%#018llx" "${rport_wwpn}"
|
||||
|
||||
# get the Device Bus-ID of the device via which this SDEV is attached
|
||||
zfcp_dev="$(readlink -se "${sdev}"/../../../..)" || return 6
|
||||
# e.g.: /sys/devices/css0/0.0.0016/0.0.1740
|
||||
zfcp_dev="${zfcp_dev##*/}"
|
||||
|
||||
# shellcheck disable=2034
|
||||
SDEV_BUSID="${zfcp_dev}"
|
||||
# shellcheck disable=2034
|
||||
SDEV_WWPN="${rport_wwpn}"
|
||||
return 0
|
||||
}
|
||||
|
||||
# Input:
|
||||
# 1: path to the scsi device in sysfs
|
||||
# Output variables:
|
||||
# SDEV_WWID
|
||||
function sdev_get_wwid() {
|
||||
local sdev="${1}"
|
||||
local -a wwid
|
||||
|
||||
declare -g SDEV_WWID=""
|
||||
|
||||
# read the volume identifier without stripping any content
|
||||
#
|
||||
# XXX: we can read the WWID file, even if the SDEV is currently not
|
||||
# operational (e.g.: due to the path has gone away), as long as
|
||||
# the VPD PG 83 is still cached in the kernel; and the page gets
|
||||
# only released on SDEV device release.
|
||||
{ readarray -d "" -t wwid < "${sdev}"/wwid; } 2>/dev/null \
|
||||
|| return 1
|
||||
if '@DEBUG@'; then declare -p wwid 1>&2; fi
|
||||
|
||||
# test whether we read something
|
||||
#
|
||||
# This strips all leading spaces from the beginning of the read WWID
|
||||
# (until the first non-space or NUL character), and checks whether the
|
||||
# result is empty.
|
||||
# Hence, we return early if the WWID consists of only whitespace.
|
||||
#
|
||||
# XXX: there could be unexpected characters in the returned ID.
|
||||
# `scsi_id` from the udev helpers sanitizes the strings it reads
|
||||
# from the devices, so they can be used in environment variables
|
||||
# without much danger.
|
||||
# But we don't export anything here, so it should be fine.
|
||||
[ "${wwid[0]/#*([[:space:]])}" != "" ] || return 2
|
||||
|
||||
# shellcheck disable=2034
|
||||
SDEV_WWID="${wwid[0]}"
|
||||
return 0
|
||||
}
|
||||
|
||||
# Input:
|
||||
# 1: path to the scsi device in sysfs
|
||||
# Return Value:
|
||||
# == 0: SDEV referenced by `1` in good state
|
||||
# != 0: otherwise
|
||||
function sdev_test_path_state() {
|
||||
local sdev="${1}" state zfcp_failed zfcp_in_recovery rport port_state
|
||||
|
||||
sdev="$(readlink -se "${sdev}")" || return 1
|
||||
|
||||
{ read -r state _ < "${sdev}"/state; } 2>/dev/null || return 2
|
||||
{ read -r zfcp_failed _ < "${sdev}"/zfcp_failed; } 2>/dev/null \
|
||||
|| return 3
|
||||
{ read -r zfcp_in_recovery _ < "${sdev}"/zfcp_in_recovery; } 2>/dev/null \
|
||||
|| return 4
|
||||
|
||||
printf -v rport "%s" "${sdev}"/../../fc_remote_ports/rport-*:*-*
|
||||
# e.g.: /sys/devices/css0/0.0.0016/0.0.1740/host0/rport-0:0-1/fc_remote_ports/rport-0:0-1
|
||||
[ "${rport}" != "" ] || return 5
|
||||
{ read -r port_state _ < "${rport}"/port_state; } 2>/dev/null \
|
||||
|| return 6
|
||||
|
||||
if '@DEBUG@'; then
|
||||
declare -p state zfcp_failed zfcp_in_recovery port_state 1>&2
|
||||
fi
|
||||
|
||||
[ "${state}" = "running" ] || return 7
|
||||
[ "${zfcp_failed}" = "0" ] || return 8
|
||||
[ "${zfcp_in_recovery}" = "0" ] || return 9
|
||||
{ [ "${port_state}" = "Online" ] \
|
||||
|| [ "${port_state}" = "Marginal" ]; } || return 10
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Input:
|
||||
# *: all input parameters are used as quoted message
|
||||
function log_note() {
|
||||
logger -p 'daemon.notice' -t 'chreipl-fcp-mpath' "${*}" &>/dev/null
|
||||
}
|
||||
|
||||
# Input:
|
||||
# *: all input parameters are used as quoted message
|
||||
function log_crit() {
|
||||
logger -p 'daemon.crit' -t 'chreipl-fcp-mpath' "${*}" &>/dev/null
|
||||
}
|
||||
|
||||
# Input:
|
||||
# *: all input parameters are used as quoted message
|
||||
function log_alert() {
|
||||
logger -p 'daemon.alert' -t 'chreipl-fcp-mpath' "${*}" &>/dev/null
|
||||
}
|
||||
56
chreipl-fcp-mpath/chreipl-fcp-mpath-is-ipl-tgt.in
Normal file
56
chreipl-fcp-mpath/chreipl-fcp-mpath-is-ipl-tgt.in
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
# chreipl-fcp-mpath: use multipath information to change FCP IPL target
|
||||
# (C) Copyright IBM Corp. 2021
|
||||
#
|
||||
# Uses the following system-utilities (and shell-builtins):
|
||||
# Those necessary for sourced library:
|
||||
# - chreipl-fcp-mpath-common.sh
|
||||
|
||||
# Find out whether the device in udev event environment variable ${DEVPATH}
|
||||
# represents the device we want to re-IPL from. We do this by comparing
|
||||
# Device-Bus-ID/Target-WWPN/LUN of the individual SDEVs to the parameters set
|
||||
# in `/sys/firmware/reipl/fcp/`.
|
||||
#
|
||||
# Makes use of udev event environment variables:
|
||||
# DM_UUID
|
||||
# SUBSYSTEM
|
||||
# DEVPATH
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
declare -gr debug_trace_tag=05iilt
|
||||
# shellcheck disable=SC1091
|
||||
source '@chreiplzfcpmp-lib@' || exit 127
|
||||
|
||||
firmware_get_ipl_information || exit 1
|
||||
|
||||
if [[ "${DM_UUID}" == mpath-* ]]; then
|
||||
# Assume Multipath Device Mapper Device;
|
||||
# e.g.: DEVPATH = /devices/virtual/block/dm-0
|
||||
declare sdev
|
||||
|
||||
# depends on `nullglob` from `chreipl-fcp-mpath-common.sh`
|
||||
for sdev in /sys/"${DEVPATH}"/slaves/sd*/device; do
|
||||
sdev_get_fcp_addressing "${sdev}" || continue
|
||||
[ "${SDEV_LUN}" = "${IPL_LUN}" ] || continue
|
||||
[ "${SDEV_WWPN}" = "${IPL_WWPN}" ] || continue
|
||||
[ "${SDEV_BUSID}" = "${IPL_BUSID}" ] || continue
|
||||
|
||||
exit 0
|
||||
done
|
||||
unset sdev
|
||||
|
||||
elif [ "${SUBSYSTEM}" = block ]; then
|
||||
# Assume SCSI Disk;
|
||||
# e.g.: DEVPATH = /devices/css0/0.0.0014/0.0.1700/host0/rport-0:0-0/target0:0:0/0:0:0:1074806808/block/sds
|
||||
|
||||
sdev_get_fcp_addressing /sys/"${DEVPATH}"/device || exit 2
|
||||
[ "${SDEV_LUN}" = "${IPL_LUN}" ] || exit 3
|
||||
[ "${SDEV_WWPN}" = "${IPL_WWPN}" ] || exit 4
|
||||
[ "${SDEV_BUSID}" = "${IPL_BUSID}" ] || exit 5
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
exit 6
|
||||
86
chreipl-fcp-mpath/chreipl-fcp-mpath-is-ipl-vol.in
Normal file
86
chreipl-fcp-mpath/chreipl-fcp-mpath-is-ipl-vol.in
Normal file
@@ -0,0 +1,86 @@
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
# chreipl-fcp-mpath: use multipath information to change FCP IPL target
|
||||
# (C) Copyright IBM Corp. 2021
|
||||
#
|
||||
# Uses the following system-utilities (and shell-builtins):
|
||||
# Those necessary for sourced library:
|
||||
# - chreipl-fcp-mpath-common.sh
|
||||
|
||||
# Find out whether the device in environment variable ${DEVPATH} represents the
|
||||
# _volume_ that we IPL'ed from. We do this by comparing its WWID to the one
|
||||
# recorded in `@chreiplzfcpmp-id-file@`.
|
||||
#
|
||||
# Makes use of udev event environment variables:
|
||||
# DM_UUID
|
||||
# SUBSYSTEM
|
||||
# DEVPATH
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
declare -gr debug_trace_tag=11iilv
|
||||
# shellcheck disable=SC1091
|
||||
source '@chreiplzfcpmp-lib@' || exit 127
|
||||
|
||||
function id_file_read_ipl_information() {
|
||||
local -a records
|
||||
|
||||
declare -g REC_WWID="" REC_BUSID="" REC_WWPN="" REC_LUN=""
|
||||
|
||||
# lock file before reading ID, so we don't see any intermediate state
|
||||
id_file_lock_shared_no_create || return 1
|
||||
|
||||
{ readarray -d "" -t -u "${ID_FILE_LOCK}" records; } 2>/dev/null \
|
||||
|| return 2
|
||||
if '@DEBUG@'; then declare -p records 1>&2; fi
|
||||
|
||||
id_file_unlock_shared_no_create
|
||||
|
||||
[ "${#records[@]}" = "4" ] || return 3
|
||||
# check that none of the array fields contains whitespace only
|
||||
[ "${records[0]/#*([[:space:]])}" != "" ] || return 4
|
||||
[ "${records[1]/#*([[:space:]])}" != "" ] || return 5
|
||||
[ "${records[2]/#*([[:space:]])}" != "" ] || return 6
|
||||
[ "${records[3]/#*([[:space:]])}" != "" ] || return 7
|
||||
|
||||
REC_WWID="${records[0]}"
|
||||
REC_BUSID="${records[1]}"
|
||||
REC_WWPN="${records[2]}"
|
||||
REC_LUN="${records[3]}"
|
||||
return 0
|
||||
}
|
||||
|
||||
id_file_read_ipl_information || exit 1
|
||||
|
||||
if [[ "${DM_UUID}" == mpath-* ]]; then
|
||||
# Assume Multipath Device Mapper Device;
|
||||
# e.g.: DEVPATH = /devices/virtual/block/dm-0
|
||||
declare sdev found=false
|
||||
|
||||
for sdev in /sys/"${DEVPATH}"/slaves/sd*/device; do
|
||||
if sdev_get_wwid "${sdev}"; then
|
||||
found=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
unset sdev
|
||||
|
||||
"${found}" || exit 2
|
||||
|
||||
elif [ "${SUBSYSTEM}" = block ]; then
|
||||
# Assume SCSI Disk;
|
||||
# e.g.: DEVPATH = /devices/css0/0.0.0014/0.0.1700/host0/rport-0:0-0/target0:0:0/0:0:0:1074806808/block/sds
|
||||
|
||||
sdev_get_wwid /sys/"${DEVPATH}"/device || exit 3
|
||||
fi
|
||||
|
||||
# set by `sdev_get_wwid` and `id_file_read_ipl_information`
|
||||
[ "${SDEV_WWID}" = "${REC_WWID}" ] || exit 4
|
||||
|
||||
firmware_get_ipl_information || exit 5
|
||||
# set by `firmware_get_ipl_information` and `id_file_read_ipl_information`
|
||||
[ "${IPL_BUSID}" = "${REC_BUSID}" ] || exit 6
|
||||
[ "${IPL_WWPN}" = "${REC_WWPN}" ] || exit 7
|
||||
[ "${IPL_LUN}" = "${REC_LUN}" ] || exit 8
|
||||
|
||||
exit 0
|
||||
25
chreipl-fcp-mpath/chreipl-fcp-mpath-is-reipl-zfcp.in
Normal file
25
chreipl-fcp-mpath/chreipl-fcp-mpath-is-reipl-zfcp.in
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
# chreipl-fcp-mpath: use multipath information to change FCP IPL target
|
||||
# (C) Copyright IBM Corp. 2021
|
||||
#
|
||||
# Uses the following system-utilities (and shell-builtins):
|
||||
# Those necessary for sourced library:
|
||||
# - chreipl-fcp-mpath-common.sh
|
||||
|
||||
# Find out whether ReIPL is gonna happen from a SCSI volume attached via zFCP
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
declare -gr debug_trace_tag=00iriz
|
||||
# shellcheck disable=SC1091
|
||||
source '@chreiplzfcpmp-lib@' || exit 127
|
||||
|
||||
declare reipl_type
|
||||
|
||||
{ read -r reipl_type _ < /sys/firmware/reipl/reipl_type; } 2>/dev/null || exit 1
|
||||
if '@DEBUG@'; then declare -p reipl_type 1>&2; fi
|
||||
|
||||
[ "${reipl_type}" = "fcp" ] || exit 2
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,73 @@
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
# chreipl-fcp-mpath: use multipath information to change FCP IPL target
|
||||
# (C) Copyright IBM Corp. 2021
|
||||
#
|
||||
# Uses the following system-utilities (and shell-builtins):
|
||||
# Those necessary for sourced library:
|
||||
# - chreipl-fcp-mpath-common.sh
|
||||
# GNU coreutils:
|
||||
# - truncate
|
||||
# util-linux:
|
||||
# - hexdump
|
||||
|
||||
# Record the identification of the volume we want to re-IPL from
|
||||
#
|
||||
# Makes use of udev event environment variables:
|
||||
# DM_UUID
|
||||
# SUBSYSTEM
|
||||
# DEVPATH
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
declare -gr debug_trace_tag=10rvid
|
||||
# shellcheck disable=SC1091
|
||||
source '@chreiplzfcpmp-lib@' || exit 127
|
||||
|
||||
function id_file_record_ipl_information() {
|
||||
local sdev_wwid="${1}" ipl_busid="${2}" ipl_wwpn="${3}" ipl_lun="${4}"
|
||||
|
||||
# lock file before writing ID, so noone sees any intermediate state
|
||||
id_file_lock_exclusive_create || return 1
|
||||
|
||||
# reset ID without removing the file (necessary for the locking to work
|
||||
# properly, since the FD we use for locking is on this file/inode)
|
||||
truncate --no-create --size=0 "${ID_FILE}" || return 3
|
||||
echo -ne "${sdev_wwid}\x00${ipl_busid}\x00${ipl_wwpn}\x00${ipl_lun}\x00" \
|
||||
>>"${ID_FILE}" || return 4
|
||||
|
||||
if '@DEBUG@'; then hexdump -vC "${ID_FILE}" 1>&2; fi
|
||||
|
||||
id_file_unlock_exclusive_create
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
if [[ "${DM_UUID}" == mpath-* ]]; then
|
||||
# Assume Multipath Device Mapper Device;
|
||||
# e.g.: DEVPATH = /devices/virtual/block/dm-0
|
||||
declare sdev
|
||||
|
||||
for sdev in /sys/"${DEVPATH}"/slaves/sd*/device; do
|
||||
if sdev_get_wwid "${sdev}"; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
unset sdev
|
||||
|
||||
elif [ "${SUBSYSTEM}" = block ]; then
|
||||
# Assume SCSI Disk;
|
||||
# e.g.: DEVPATH = /devices/css0/0.0.0014/0.0.1700/host0/rport-0:0-0/target0:0:0/0:0:0:1074806808/block/sds
|
||||
|
||||
sdev_get_wwid /sys/"${DEVPATH}"/device
|
||||
fi
|
||||
# shellcheck disable=SC2153
|
||||
[ "${SDEV_WWID}" != "" ] || exit 1
|
||||
|
||||
firmware_get_ipl_information || exit 2
|
||||
# shellcheck disable=SC2153
|
||||
id_file_record_ipl_information \
|
||||
"${SDEV_WWID}" "${IPL_BUSID}" "${IPL_WWPN}" "${IPL_LUN}" \
|
||||
|| exit 3
|
||||
|
||||
exit 0
|
||||
158
chreipl-fcp-mpath/chreipl-fcp-mpath-try-change-ipl-path.in
Normal file
158
chreipl-fcp-mpath/chreipl-fcp-mpath-try-change-ipl-path.in
Normal file
@@ -0,0 +1,158 @@
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
# chreipl-fcp-mpath: use multipath information to change FCP IPL target
|
||||
# (C) Copyright IBM Corp. 2021
|
||||
#
|
||||
# Uses the following system-utilities (and shell-builtins):
|
||||
# Those necessary for sourced library:
|
||||
# - chreipl-fcp-mpath-common.sh
|
||||
# GNU coreutils:
|
||||
# - truncate
|
||||
# util-linux:
|
||||
# - hexdump
|
||||
|
||||
# Try to change the current re-IPL target to a dfferent, operational path to
|
||||
# the same volume.
|
||||
#
|
||||
# Makes use of udev event environment variables:
|
||||
# DM_UUID
|
||||
# SUBSYSTEM
|
||||
# DEVPATH
|
||||
# CHREIPL_FCP_MPATH_IS_TGT
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
declare -gr debug_trace_tag=15tcip
|
||||
# shellcheck disable=SC1091
|
||||
source '@chreiplzfcpmp-lib@' || exit 127
|
||||
|
||||
function apply_ipl_information() {
|
||||
local sdev_wwid="${1}"
|
||||
local sdev_busid="${2}" sdev_wwpn="${3}" sdev_lun="${4}"
|
||||
local ipl_type="${5}" ipl_busid="${6}" ipl_wwpn="${7}" ipl_lun="${8}"
|
||||
local -a records
|
||||
local try_update_id_file=true
|
||||
|
||||
[ "${ipl_type}" = "fcp" ] || return 1
|
||||
|
||||
[[ "${sdev_busid}" =~ ^[[:xdigit:]]{1,3}\.[[:xdigit:]]\.[[:xdigit:]]{1,4}$ ]] \
|
||||
|| return 2
|
||||
[[ "${sdev_wwpn}" =~ ^0x[[:xdigit:]]{16}$ ]] || return 3
|
||||
[[ "${sdev_lun}" =~ ^0x[[:xdigit:]]{16}$ ]] || return 4
|
||||
|
||||
# After updating the firmware re-IPL information below we also try to
|
||||
# update the information stored in the ID file (necessary, so it
|
||||
# contains the correct Device-Bus-ID/WWPN/LUN after the update). For
|
||||
# the update of the ID file we try to grab an exclusive lock, so there
|
||||
# are no overlapping reads/writes.
|
||||
#
|
||||
# In case we can't get the lock because the ID file is missing, but we
|
||||
# have a direct TGT match, we may still try to change the re-IPL
|
||||
# information, but skip the ID file update.
|
||||
#
|
||||
# "direct match" means, the event subject is either the SDEV that is
|
||||
# currently set as re-IPL target, or it is the dm-multipath device that
|
||||
# currently contains the re-IPL target.
|
||||
if ! id_file_lock_exclusive_no_create; then
|
||||
# rc == 1 --> could not read ${ID_FILE}
|
||||
[ "${PIPESTATUS[0]}" -eq 1 ] || return 5
|
||||
# if true, we are dealing with a direct TGT match
|
||||
[ "${CHREIPL_FCP_MPATH_IS_TGT}" = "true" ] || return 6
|
||||
try_update_id_file=false
|
||||
fi
|
||||
|
||||
# If we have a direct match (see in the comment above), we know
|
||||
# that we have a path to the current re-IPL volume - no matter of the
|
||||
# WWID. Otherwise, we got here by comparing the WWID of the event
|
||||
# subject with the one recorded in the ID file; in this case we try to
|
||||
# make sure the information is still up-to-date.
|
||||
if [ "${CHREIPL_FCP_MPATH_IS_TGT}" != "true" ]; then
|
||||
# last bail to make sure we don't overwrite user choices..
|
||||
#
|
||||
# XXX: this will *NOT* prevent the race completely, but at least
|
||||
# make it less likely
|
||||
{ readarray -d "" -t -u "${ID_FILE_LOCK}" records; } 2>/dev/null \
|
||||
|| return 7
|
||||
if '@DEBUG@'; then declare -p records 1>&2; fi
|
||||
|
||||
[ "${#records[@]}" = "4" ] || return 8
|
||||
[ "${records[0]}" = "${sdev_wwid}" ] || return 9
|
||||
[ "${records[1]}" = "${ipl_busid}" ] || return 10
|
||||
[ "${records[2]}" = "${ipl_wwpn}" ] || return 11
|
||||
[ "${records[3]}" = "${ipl_lun}" ] || return 12
|
||||
fi
|
||||
|
||||
# Take lock so we don't see any intermediate state from other helpers
|
||||
# running in parallel
|
||||
firmware_lock_exclusive || return 13
|
||||
|
||||
if ! { echo "${sdev_busid}" >| /sys/firmware/reipl/fcp/device \
|
||||
&& echo "${sdev_wwpn}" >| /sys/firmware/reipl/fcp/wwpn \
|
||||
&& echo "${sdev_lun}" >| /sys/firmware/reipl/fcp/lun; };
|
||||
then
|
||||
log_alert "Changing the re-IPL device failed. The current re-IPL settings might be inconsistent. Check and correct the settings (see the README.md of chreipl-fcp-mpath) to make sure that the current re-IPL device is valid."
|
||||
return 14
|
||||
fi
|
||||
|
||||
firmware_unlock_exclusive
|
||||
|
||||
if [ "${sdev_busid}" != "${ipl_busid}" ] \
|
||||
|| [ "${sdev_wwpn}" != "${ipl_wwpn}" ] \
|
||||
|| [ "${sdev_lun}" != "${ipl_lun}" ]; then
|
||||
log_note "Changed re-IPL path to: ${sdev_busid}:${sdev_wwpn}:${sdev_lun}."
|
||||
fi
|
||||
|
||||
# Try to update the information in the ID file if we have gotten the
|
||||
# lock for it.
|
||||
if ${try_update_id_file}; then
|
||||
# reset ID without removing the file
|
||||
truncate --no-create --size=0 "${ID_FILE}" || return 15
|
||||
echo -ne "${sdev_wwid}\x00${sdev_busid}\x00${sdev_wwpn}\x00${sdev_lun}\x00" \
|
||||
>>"${ID_FILE}" || return 16
|
||||
|
||||
id_file_unlock_exclusive_no_create
|
||||
|
||||
if '@DEBUG@'; then hexdump -vC "${ID_FILE}" 1>&2; fi
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
declare -g SDEV=""
|
||||
if [[ "${DM_UUID}" == mpath-* ]]; then
|
||||
# Assume Multipath Device Mapper Device;
|
||||
# e.g.: DEVPATH = /devices/virtual/block/dm-0
|
||||
|
||||
for sdev in /sys/"${DEVPATH}"/slaves/sd*/device; do
|
||||
if sdev_test_path_state "${sdev}"; then
|
||||
SDEV="${sdev}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# No path of the multipath-device that represents the IPL volume is
|
||||
# online.
|
||||
if [ "${SDEV}" = "" ]; then
|
||||
log_crit "The re-IPL device cannot be changed because no operational path to the re-IPL volume remains. The next re-IPL might fail unless you re-attach or enable at least one valid path to the re-IPL volume."
|
||||
fi
|
||||
|
||||
elif [ "${SUBSYSTEM}" = block ]; then
|
||||
# Assume SCSI Disk;
|
||||
# e.g.: DEVPATH = /devices/css0/0.0.0014/0.0.1700/host0/rport-0:0-0/target0:0:0/0:0:0:1074806808/block/sds
|
||||
if sdev_test_path_state /sys/"${DEVPATH}"/device; then
|
||||
SDEV=/sys/"${DEVPATH}"/device
|
||||
fi
|
||||
|
||||
fi
|
||||
[ "${SDEV}" != "" ] || exit 0
|
||||
|
||||
sdev_get_wwid "${SDEV}" || exit 0
|
||||
sdev_get_fcp_addressing "${SDEV}" || exit 0
|
||||
firmware_get_ipl_information || exit 0
|
||||
|
||||
# shellcheck disable=SC2153
|
||||
apply_ipl_information \
|
||||
"${SDEV_WWID}" "${SDEV_BUSID}" "${SDEV_WWPN}" "${SDEV_LUN}" \
|
||||
"${IPL_TYPE}" "${IPL_BUSID}" "${IPL_WWPN}" "${IPL_LUN}" || exit 0
|
||||
|
||||
exit 0
|
||||
93
chreipl-fcp-mpath/chreipl-fcp-mpath.mak
Normal file
93
chreipl-fcp-mpath/chreipl-fcp-mpath.mak
Normal file
@@ -0,0 +1,93 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
# chreipl-fcp-mpath: use multipath information to change FCP IPL target
|
||||
# (C) Copyright IBM Corp. 2021
|
||||
#
|
||||
# Uses the following system-utilities (and shell-builtins):
|
||||
# Utilities list in GNU Make Conventions:
|
||||
# https://www.gnu.org/software/make/manual/make.html#Utilities-in-Makefiles
|
||||
# GNU coreutils:
|
||||
# - mktemp
|
||||
# If $(ENABLE_DOC) is `1`:
|
||||
# Pandoc:
|
||||
# - pandoc
|
||||
# GNU coreutils:
|
||||
# - date
|
||||
|
||||
#
|
||||
## Paths and Build Variables
|
||||
#
|
||||
|
||||
# Install the configuration file for dracut, to automatically pull in the
|
||||
# toolset into the initial ramdisk, when built with it.
|
||||
HAVE_DRACUT = 0
|
||||
|
||||
# Build documentation; requires: Pandoc
|
||||
ENABLE_DOC = 0
|
||||
|
||||
# https://www.gnu.org/software/make/manual/make.html#Directory-Variables
|
||||
CHREIPLZFCPMPDIR = $(USRLIBDIR)/chreipl-fcp-mpath
|
||||
UDEVDIR = $(USRLIBDIR)/udev
|
||||
UDEVRULESDIR = $(UDEVDIR)/rules.d
|
||||
UDEVRUNDIR = /run/udev
|
||||
DRACUTDIR = $(USRLIBDIR)/dracut
|
||||
DRACUTCONFDIR = $(DRACUTDIR)/dracut.conf.d
|
||||
DEBUGOUTDIR = $(UDEVRUNDIR)
|
||||
|
||||
INSTALL_EXEC = $(INSTALL) -g $(GROUP) -o $(OWNER) --preserve-timestamps
|
||||
INSTALL_DATA = $(INSTALL_EXEC) --mode=0644
|
||||
|
||||
# used for data exchange and synchronization across the different helpers
|
||||
chreiplzfcpmp-id-file = $(UDEVRUNDIR)/chreiplzfcpmp-ipl-volume-id
|
||||
# file used to implement mutual exclusion when accessing firmware IPL info:
|
||||
# - this should be something that is (practically) always available, so we
|
||||
# dont have to worry about fallbacks or error-handling;
|
||||
# - at the same time, it should not be used by anything else with flock(2) to
|
||||
# hold a lock for long periods.
|
||||
chreiplzfcpmp-fwlock-file = /sys/firmware/reipl
|
||||
|
||||
.DELETE_ON_ERROR:
|
||||
|
||||
# export build-time definitions to the scripts/built-components
|
||||
define chreiplzfcpmp-sed-buildvar-replace =
|
||||
tmpout=$$(mktemp -p ./ .make.tmp.XXXXXXXXXXXXXXXX) && { \
|
||||
$(SED) -E \
|
||||
-e 's|@DEBUG@|$(if $(filter 1,$(D)),true,false)|g' \
|
||||
-e 's|@chreiplzfcpmp-id-file@|$(chreiplzfcpmp-id-file)|g' \
|
||||
-e 's|@chreiplzfcpmp-fwlock-file@|$(chreiplzfcpmp-fwlock-file)|g' \
|
||||
-e 's|@chreiplzfcpmp-lib@|$(CHREIPLZFCPMPDIR)/chreipl-fcp-mpath-common.sh|g' \
|
||||
-e 's|@debugoutdir@|$(DEBUGOUTDIR)|g' \
|
||||
-e 's|@udevdir@|$(UDEVDIR)|g' \
|
||||
-e 's|@udevrulesdir@|$(UDEVRULESDIR)|g' \
|
||||
$(1) > $${tmpout} \
|
||||
&& mv $${tmpout} $(2) \
|
||||
|| { rm $${tmpout}; false; } \
|
||||
; }
|
||||
endef
|
||||
|
||||
.PHONY: clean-mk-temp
|
||||
clean: clean-mk-temp
|
||||
clean-mk-temp:
|
||||
rm -f .make.tmp.[[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]]
|
||||
|
||||
# Definitions for generating documentation when $(ENABLE_DOC) is set to `1`
|
||||
|
||||
PANDOCFLAGS = --fail-if-warnings
|
||||
ALL_PANDOCFLAGS = --preserve-tabs --tab-stop=8 --strip-comments \
|
||||
--standalone --self-contained \
|
||||
-M date="$(shell date +'%Y-%m-%d')" \
|
||||
$(PANDOCFLAGS)
|
||||
|
||||
$(eval $(call cmd_define, PANDOC," PANDOC ",pandoc))
|
||||
|
||||
%.html : ALL_PANDOCFLAGS += -t html
|
||||
%.html : %.md
|
||||
$(PANDOC) $(ALL_PANDOCFLAGS) -f gfm -o $(@) $(<)
|
||||
|
||||
%.pdf : ALL_PANDOCFLAGS += -t latex --toc
|
||||
%.pdf : %.md
|
||||
$(PANDOC) $(ALL_PANDOCFLAGS) -f gfm -o $(@) $(<)
|
||||
|
||||
%.7 : ALL_PANDOCFLAGS += -t man
|
||||
%.7 : %.md
|
||||
$(PANDOC) $(ALL_PANDOCFLAGS) -f gfm -o $(@) $(<)
|
||||
@@ -0,0 +1,16 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
# chreipl-fcp-mpath: use multipath information to change FCP IPL target
|
||||
# (C) Copyright IBM Corp. 2021
|
||||
|
||||
add_dracutmodules+=" bash multipath udev-rules "
|
||||
|
||||
install_items+=" @udevrulesdir@/70-chreipl-fcp-mpath.rules "
|
||||
install_items+=" @chreiplzfcpmp-lib@ "
|
||||
install_items+=" @udevdir@/chreipl-fcp-mpath-is-ipl-tgt "
|
||||
install_items+=" @udevdir@/chreipl-fcp-mpath-is-ipl-vol "
|
||||
install_items+=" @udevdir@/chreipl-fcp-mpath-is-reipl-zfcp "
|
||||
install_items+=" @udevdir@/chreipl-fcp-mpath-record-volume-identifier "
|
||||
install_items+=" @udevdir@/chreipl-fcp-mpath-try-change-ipl-path "
|
||||
|
||||
install_items+=" flock hexdump logger mktemp readlink sync truncate "
|
||||
101
chreipl-fcp-mpath/udev/rules.d/70-chreipl-fcp-mpath.rules
Normal file
101
chreipl-fcp-mpath/udev/rules.d/70-chreipl-fcp-mpath.rules
Normal file
@@ -0,0 +1,101 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
# chreipl-fcp-mpath: use multipath information to change FCP IPL target
|
||||
# (C) Copyright IBM Corp. 2021
|
||||
|
||||
# Did the event affect a multipath or scsi disk device?
|
||||
ACTION=="change", KERNEL=="dm-[0-9]*", SUBSYSTEM=="block", \
|
||||
ENV{DM_UUID}=="mpath-*", ENV{DM_ACTION}=="PATH_FAILED", \
|
||||
GOTO="chreipl_fcp_mpath_path_change"
|
||||
ACTION=="change", KERNEL=="dm-[0-9]*", SUBSYSTEM=="block", \
|
||||
ENV{DM_UUID}=="mpath-*", ENV{DM_ACTION}=="PATH_REINSTATED", \
|
||||
GOTO="chreipl_fcp_mpath_path_change"
|
||||
ACTION=="add", KERNEL=="sd[a-z]*", SUBSYSTEM=="block", \
|
||||
GOTO="chreipl_fcp_mpath_path_change"
|
||||
GOTO="chreipl_fcp_mpath_end"
|
||||
LABEL="chreipl_fcp_mpath_path_change"
|
||||
|
||||
# Is this system IPL'ed (IOW, are we on s390x)? And do we ReIPL via zFCP?
|
||||
#
|
||||
# udev(7): If no absolute path is given, the program is expected to live
|
||||
# in /usr/lib/udev; otherwise, the absolute path must be
|
||||
# specified.
|
||||
TEST!="/sys/firmware/ipl", GOTO="chreipl_fcp_mpath_end"
|
||||
PROGRAM!="chreipl-fcp-mpath-is-reipl-zfcp", GOTO="chreipl_fcp_mpath_end"
|
||||
|
||||
# Consider the following scenarios.
|
||||
# Either:
|
||||
#
|
||||
# (A) We recognized a new SCSI Disk. This might represent:
|
||||
# (a) the path we want to ReIPL from;
|
||||
# (b) an alternative path to the volume we want to ReIPL from;
|
||||
# (c) a path to some unrelated volume.
|
||||
#
|
||||
# Or:
|
||||
#
|
||||
# (B) We recognized a PATH_ event for a multipath device. This might represent:
|
||||
# the path we want to ReIPL from:
|
||||
# (a) went away;
|
||||
# (b) came back online;
|
||||
# an alternative path to the volume we want to ReIPL from:
|
||||
# (c) went away;
|
||||
# (d) came back online;
|
||||
# (e) some unrelated multipath device saw an event.
|
||||
|
||||
# Test whether the affected device is, or contains, the current IPL target.
|
||||
#
|
||||
# This covers scenarios:
|
||||
# (A) (a),
|
||||
# (B) (a)/(b)/(c)/(d)
|
||||
PROGRAM!="chreipl-fcp-mpath-is-ipl-tgt", \
|
||||
ENV{CHREIPL_FCP_MPATH_IS_TGT}="false", \
|
||||
GOTO="chreipl_fcp_mpath_not_direct_match"
|
||||
ENV{CHREIPL_FCP_MPATH_IS_TGT}="true"
|
||||
|
||||
# Record the WWID, Device-Bus-ID, Remote WWPN, and LUN of the ReIPL target
|
||||
# (see `chreipl-fcp-mpath-is-ipl-vol` for usecases). This information
|
||||
# might change, depending on whether the machine operator changes the ReIPL
|
||||
# target to a different volume.
|
||||
#
|
||||
# XXX: Because the kernel doesn't generate any events upon changing of
|
||||
# the ReIPL target, the chreipl-fcp-mpath toolset can't take any
|
||||
# actions until the next path event for the new target is
|
||||
# generated. Following that, we assume that when the machine
|
||||
# operator changes the ReIPL target, the new target is reachable
|
||||
# and in a good state at this point in time.
|
||||
PROGRAM!="chreipl-fcp-mpath-record-volume-identifier", \
|
||||
GOTO="chreipl_fcp_mpath_try_change_ipl_path"
|
||||
GOTO="chreipl_fcp_mpath_try_change_ipl_path"
|
||||
|
||||
# If the even subject is not a direct match (not the sdev that is the current
|
||||
# ReIPL target, and not a mpath device that contains the current ReIPL target)
|
||||
LABEL="chreipl_fcp_mpath_not_direct_match"
|
||||
|
||||
# While this sdev/mpath device doesn't directly correspond to the path
|
||||
# currently set as ReIPL target, it might still point to the same volume.
|
||||
#
|
||||
# For mpath devices this can happen if the original ReIPL target is completely
|
||||
# gone from the machine, and so there is no way we can successfully, directly
|
||||
# compare the ReIPL parameters to the sdevs of the mpath device.
|
||||
#
|
||||
# For cases like these we recorded the volume identifier, which we now can
|
||||
# compare, and so still decide whether we are addressing the correct volume.
|
||||
#
|
||||
# This covers scenarios:
|
||||
# (A) (b)/(c),
|
||||
# (B) (c)/(d)/(e)
|
||||
#
|
||||
# XXX: we recorded WWID, Device-Bus-ID, Remote WWPN, LUN of the ReIPL target at
|
||||
# the time; if the latter three don't match the current ReIPL setting
|
||||
# anymore, we have to assume that someone changed the ReIPL target
|
||||
# manually, and we cannot use the WWID anymore since we can't possibly
|
||||
# know whether that stayed the same when the change was done.
|
||||
PROGRAM!="chreipl-fcp-mpath-is-ipl-vol", GOTO="chreipl_fcp_mpath_end"
|
||||
|
||||
# We are here because of scenarios:
|
||||
# (A) (a)/(b),
|
||||
# (B) (a)/(b)/(c)/(d)
|
||||
LABEL="chreipl_fcp_mpath_try_change_ipl_path"
|
||||
RUN{program}+="chreipl-fcp-mpath-try-change-ipl-path"
|
||||
|
||||
LABEL="chreipl_fcp_mpath_end"
|
||||
@@ -5,7 +5,7 @@ COMMON_INCLUDED = true
|
||||
# The variable "DISTRELEASE" should be overwritten in rpm spec files with:
|
||||
# "make DISTRELEASE=%{release}" and "make install DISTRELEASE=%{release}"
|
||||
VERSION = 2
|
||||
RELEASE = 17
|
||||
RELEASE = 19
|
||||
PATCHLEVEL = 0
|
||||
DISTRELEASE = build-$(shell date +%Y%m%d)
|
||||
S390_TOOLS_RELEASE = $(VERSION).$(RELEASE).$(PATCHLEVEL)-$(DISTRELEASE)
|
||||
@@ -182,6 +182,7 @@ USRSBINDIR = $(INSTALLDIR)/usr/sbin
|
||||
USRBINDIR = $(INSTALLDIR)/usr/bin
|
||||
BINDIR = $(INSTALLDIR)/sbin
|
||||
LIBDIR = $(INSTALLDIR)/lib
|
||||
USRLIBDIR = $(INSTALLDIR)/usr/lib
|
||||
USRLIB64DIR = $(INSTALLDIR)/usr/lib64
|
||||
SYSCONFDIR = $(INSTALLDIR)/etc
|
||||
MANDIR = $(INSTALLDIR)/usr/share/man
|
||||
@@ -206,10 +207,10 @@ INSTDIRS = $(USRSBINDIR) $(USRBINDIR) $(BINDIR) $(LIBDIR) $(MANDIR) \
|
||||
$(TOOLS_LIBDIR) $(TOOLS_DATADIR) \
|
||||
$(ZFCPDUMP_DIR) $(SYSTEMDSYSTEMUNITDIR) \
|
||||
$(USRLIB64DIR) $(USRINCLUDEDIR) $(ZKEYKMSPLUGINDIR) \
|
||||
$(SOINSTALLDIR)
|
||||
$(SOINSTALLDIR) $(USRLIBDIR)
|
||||
OWNER = $(shell id -un)
|
||||
GROUP = $(shell id -gn)
|
||||
export INSTALLDIR BINDIR LIBDIR USRLIB64DIR MANDIR OWNER GROUP
|
||||
export INSTALLDIR BINDIR LIBDIR USRLIBDIR USRLIB64DIR MANDIR OWNER GROUP
|
||||
|
||||
# Special defines for zfcpdump
|
||||
ZFCPDUMP_IMAGE = zfcpdump-image
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <linux/limits.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
@@ -45,15 +46,15 @@
|
||||
#define CPUS_POSSIBLE "/sys/devices/system/cpu/possible"
|
||||
#define CPUS_KERNELMAX "/sys/devices/system/cpu/kernel_max"
|
||||
#define MAXCTRS 512
|
||||
#define IOCTLSLEEP 60U
|
||||
|
||||
static const unsigned int ioctlsleep = 60;
|
||||
static unsigned int read_interval = ioctlsleep, cfvn, csvn, authorization;
|
||||
static unsigned int read_interval = IOCTLSLEEP, cfvn, csvn, authorization;
|
||||
static unsigned long loop_count = 1;
|
||||
static unsigned char *ioctlbuffer;
|
||||
static bool allcpu;
|
||||
|
||||
static unsigned int max_possible_cpus; /* No of possible CPUs */
|
||||
struct ctrname { /* List of defined counters */
|
||||
static struct ctrname { /* List of defined counters */
|
||||
char *name; /* Counter name */
|
||||
bool hitcnt; /* Counter number read from ioctl() */
|
||||
unsigned long total; /* Total counter value */
|
||||
@@ -240,7 +241,7 @@ static char *show_ctrset(unsigned long set)
|
||||
/* Parse CPU list and counter sets */
|
||||
static void parse_cpulist(char *parm, struct s390_hwctr_start *start)
|
||||
{
|
||||
__u64 *words = start->cpumask;
|
||||
uint64_t *words = start->cpumask;
|
||||
unsigned long i, no_a, no_b;
|
||||
char *cp, *tokens[16]; /* Used to parse command line params */
|
||||
char cpubuf[256];
|
||||
@@ -275,8 +276,8 @@ static void parse_cpulist(char *parm, struct s390_hwctr_start *start)
|
||||
show_ctrset(noton));
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(tokens) && (tokens[i] = strtok(parm, ",")) != 0;
|
||||
++i, parm = 0) {
|
||||
for (i = 0; i < ARRAY_SIZE(tokens) && (tokens[i] = strtok(parm, ","));
|
||||
++i, parm = NULL) {
|
||||
cp = strchr(tokens[i], '-'); /* Range character? */
|
||||
if (cp) {
|
||||
no_a = getnumber(tokens[i], *cp);
|
||||
@@ -292,15 +293,15 @@ static void parse_cpulist(char *parm, struct s390_hwctr_start *start)
|
||||
/* Convert the CPU list to a bitmask for kernel cpumask_t */
|
||||
for (i = 0, no_b = 0; i < max_possible_cpus; ++i) {
|
||||
if (check[i].cpu_req) {
|
||||
no_a = i % __BITS_PER_LONG;
|
||||
no_b = i / __BITS_PER_LONG;
|
||||
no_a = i % LONG_BIT;
|
||||
no_b = i / LONG_BIT;
|
||||
words[no_b] |= 1ULL << no_a;
|
||||
}
|
||||
}
|
||||
/* no_b is highest used index, swap array */
|
||||
start->cpumask_len = (no_b + 1) * 8;
|
||||
for (no_a = 0; no_a < no_b; ++no_a, --no_b) {
|
||||
__u64 tmp = words[no_a];
|
||||
uint64_t tmp = words[no_a];
|
||||
|
||||
words[no_a] = words[no_b];
|
||||
words[no_b] = tmp;
|
||||
@@ -326,7 +327,7 @@ static bool check_setpossible(void)
|
||||
}
|
||||
parm = cpubuf;
|
||||
for (i = 0; i < ARRAY_SIZE(tokens) && (tokens[i] = strtok(parm, ","));
|
||||
++i, parm = 0) {
|
||||
++i, parm = NULL) {
|
||||
cp = strchr(tokens[i], '-');
|
||||
if (cp) { /* Range */
|
||||
no_a = getnumber(tokens[i], *cp);
|
||||
@@ -525,7 +526,7 @@ static int test_read(struct s390_hwctr_read *read)
|
||||
}
|
||||
/* Iterate over all counters in each set */
|
||||
for (unsigned int k = 0; k < sp->no_cnts; ++k) {
|
||||
__u64 value;
|
||||
uint64_t value;
|
||||
void *addr = base + offset;
|
||||
size_t idx = ctrset_offset(sp->set) + k;
|
||||
|
||||
@@ -608,8 +609,8 @@ static int do_it(char *s)
|
||||
int rc;
|
||||
|
||||
memset(&start, 0, sizeof(start));
|
||||
rc = max_possible_cpus / sizeof(__u64);
|
||||
start.cpumask = alloca(max_possible_cpus / sizeof(__u64));
|
||||
rc = max_possible_cpus / sizeof(uint64_t);
|
||||
start.cpumask = alloca(max_possible_cpus / sizeof(uint64_t));
|
||||
memset(start.cpumask, 0, rc);
|
||||
parse_cpulist(s, &start);
|
||||
errno = 0;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#ifndef LSHWC_H
|
||||
#define LSHWC_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
enum {
|
||||
@@ -58,27 +59,27 @@ enum {
|
||||
*/
|
||||
|
||||
struct s390_hwctr_start { /* Set CPUs to operate on */
|
||||
__u64 version; /* Version of interface */
|
||||
__u64 data_bytes; /* # of bytes required */
|
||||
__u64 cpumask_len; /* Length of CPU mask in bytes */
|
||||
__u64 *cpumask; /* Pointer to CPU mask */
|
||||
__u64 counter_sets; /* Bit mask of counter set to get */
|
||||
uint64_t version; /* Version of interface */
|
||||
uint64_t data_bytes; /* # of bytes required */
|
||||
uint64_t cpumask_len; /* Length of CPU mask in bytes */
|
||||
uint64_t *cpumask; /* Pointer to CPU mask */
|
||||
uint64_t counter_sets; /* Bit mask of counter set to get */
|
||||
};
|
||||
|
||||
struct s390_hwctr_setdata { /* Counter set data */
|
||||
__u32 set; /* Counter set number */
|
||||
__u32 no_cnts; /* # of counters stored in cv[] */
|
||||
__u64 cv[0]; /* Counter values (variable length) */
|
||||
uint32_t set; /* Counter set number */
|
||||
uint32_t no_cnts; /* # of counters stored in cv[] */
|
||||
uint64_t cv[0]; /* Counter values (variable length) */
|
||||
};
|
||||
|
||||
struct s390_hwctr_cpudata { /* Counter set data per CPU */
|
||||
__u32 cpu_nr; /* Counter set number */
|
||||
__u32 no_sets; /* # of counters sets in data[] */
|
||||
uint32_t cpu_nr; /* Counter set number */
|
||||
uint32_t no_sets; /* # of counters sets in data[] */
|
||||
struct s390_hwctr_setdata data[0];
|
||||
};
|
||||
|
||||
struct s390_hwctr_read { /* Structure to get all ctr sets */
|
||||
__u64 no_cpus; /* Total # of CPUs data taken from */
|
||||
uint64_t no_cpus; /* Total # of CPUs data taken from */
|
||||
struct s390_hwctr_cpudata data[0];
|
||||
};
|
||||
|
||||
|
||||
@@ -110,6 +110,7 @@ static struct util_opt dump2tar_opts[] = {
|
||||
{
|
||||
.option = { "file-timeout", required_argument, NULL, 'T' },
|
||||
.desc = "Stop reading file after SEC seconds",
|
||||
.argument = "SEC",
|
||||
},
|
||||
{
|
||||
.option = { "file-max-size", required_argument, NULL, 'M' },
|
||||
|
||||
@@ -69,6 +69,7 @@ check-dep-fuse:
|
||||
"fuse.h", \
|
||||
"fuse-devel or libfuse-dev", \
|
||||
"HAVE_FUSE=0")
|
||||
touch check-dep-fuse
|
||||
|
||||
install: all
|
||||
$(INSTALL) -g $(GROUP) -o $(OWNER) -m 755 hsavmcore \
|
||||
@@ -81,6 +82,6 @@ install: all
|
||||
endif # HAVE_FUSE
|
||||
|
||||
clean:
|
||||
rm -f hsavmcore $(objects)
|
||||
rm -f hsavmcore $(objects) check-dep-fuse
|
||||
|
||||
.PHONY: all install clean
|
||||
|
||||
430
hsci/hsci
430
hsci/hsci
@@ -11,11 +11,36 @@
|
||||
hsdev=""
|
||||
ndev=""
|
||||
hsci=""
|
||||
hsdev_mac=""
|
||||
hscibr=""
|
||||
hscibp=""
|
||||
hsci_mac=""
|
||||
hsif_pnetid=""
|
||||
netif_pnetid=""
|
||||
hsci_pnetid=""
|
||||
|
||||
##############################################################################
|
||||
# Concept:
|
||||
# --------
|
||||
# | hsci |
|
||||
# --------
|
||||
# / \
|
||||
# -------- --------
|
||||
# | ndev | | hsdev |
|
||||
# -------- --------
|
||||
#
|
||||
# Detail (bridge w/ bridgeports):
|
||||
# --------
|
||||
# | hsci |
|
||||
# --------
|
||||
# |
|
||||
# ----------------------
|
||||
# | |hsci-bp| |
|
||||
# | hsci-br --------- |
|
||||
# | |
|
||||
# -------- -------- |
|
||||
# | ndev | | hsdev | |
|
||||
# ----------------------
|
||||
|
||||
function usage {
|
||||
cat <<-EOD
|
||||
Usage: hsci COMMAND [OPTION]
|
||||
@@ -42,50 +67,53 @@ function prereqs_check {
|
||||
fi
|
||||
}
|
||||
|
||||
function get_pnetid {
|
||||
local netdev=$1
|
||||
local pnetid=""
|
||||
|
||||
#### ROCE:
|
||||
if [ -e /sys/class/net/$netdev/device/util_string ]; then
|
||||
pnetids="$(cat /sys/class/net/$netdev/device/util_string | tr -d '\000' | iconv -f IBM-1047 -t ASCII)"
|
||||
else
|
||||
#### OSA /HiperSockets:
|
||||
if [ -e /sys/class/net/$netdev/device/chpid ]; then
|
||||
chpid="$(cat /sys/class/net/$netdev/device/chpid | tr [:upper:] [:lower:])"
|
||||
pnetids="$(cat /sys/devices/css0/chp0.$chpid/util_string | tr -d '\000' | iconv -f IBM-1047 -t ASCII)"
|
||||
fi
|
||||
fi
|
||||
if [ "$pnetids" != "" ]; then
|
||||
port_if="$(cat /sys/class/net/$netdev/dev_port)"
|
||||
(( idx=16*$port_if+1 ))
|
||||
(( end=$idx+15 ))
|
||||
pnetid="$(echo "$pnetids" | cut -c $idx-$end | tr -d ' ')"
|
||||
fi
|
||||
|
||||
echo $pnetid
|
||||
}
|
||||
|
||||
function check_pnetids {
|
||||
# get PNETID of the HS
|
||||
local hsif_pnetids=""
|
||||
local netif_pnetids=""
|
||||
|
||||
if [ -e /sys/class/net/$hsdev/device/util_string ]; then
|
||||
hsif_pnetids="$(cat /sys/class/net/$hsdev/device/util_string | tr -d '\000' | iconv -f IBM-1047 -t ASCII)"
|
||||
if [ "$hsdev" != "" ]; then
|
||||
hsif_pnetid="$(get_pnetid $hsdev)"
|
||||
else
|
||||
if [ -e /sys/class/net/$hsdev/device/chpid ]; then
|
||||
chpid="$(cat /sys/class/net/$hsdev/device/chpid | tr [:upper:] [:lower:])"
|
||||
hsif_pnetids="$(cat /sys/devices/css0/chp0.$chpid/util_string | tr -d '\000' | iconv -f IBM-1047 -t ASCII)"
|
||||
fi
|
||||
hsif_pnetid=""
|
||||
fi
|
||||
if [ "$hsif_pnetids" != "" ]; then
|
||||
port_hsif="$(cat /sys/class/net/$hsdev/dev_port)"
|
||||
(( idx=16*$port_hsif+1 ))
|
||||
(( end=$idx+15 ))
|
||||
hsif_pnetid="$(echo "$hsif_pnetids" | cut -c $idx-$end | tr -d ' ')"
|
||||
fi
|
||||
|
||||
# get PNETID of the NET_DEV
|
||||
if [ -e /sys/class/net/$ndev/device/util_string ]; then
|
||||
netif_pnetids="$(cat /sys/class/net/$ndev/device/util_string | tr -d '\000' | iconv -f IBM-1047 -t ASCII)"
|
||||
if [ "$ndev" != "" ]; then
|
||||
netif_pnetid="$(get_pnetid $ndev)"
|
||||
else
|
||||
if [ -e /sys/class/net/$ndev/device/chpid ]; then
|
||||
chpid="$(cat /sys/class/net/$ndev/device/chpid | tr [:upper:] [:lower:])"
|
||||
netif_pnetids="$(cat /sys/devices/css0/chp0.$chpid/util_string | tr -d '\000' | iconv -f IBM-1047 -t ASCII)"
|
||||
fi
|
||||
fi
|
||||
if [ "$netif_pnetids" != "" ]; then
|
||||
port_netif="$(cat /sys/class/net/$ndev/dev_port)"
|
||||
(( idx=16*$port_netif+1 ))
|
||||
(( end=$idx+15 ))
|
||||
netif_pnetid="$(echo "$netif_pnetids" | cut -c $idx-$end | tr -d ' ')"
|
||||
netif_pnetid=""
|
||||
fi
|
||||
|
||||
#Check PNETIDs
|
||||
if [ "$hsif_pnetid" != "" ] && [ "$netif_pnetid" != "" ] && [ "$netif_pnetid" != "$hsif_pnetid" ]; then
|
||||
echo "Error: $hsdev and $ndev have different PNETIDs! They are $hsif_pnetid and $netif_pnetid respectively" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ "$hsif_pnetid" != "" ] && [ "$netif_pnetid" != "" ] && [ "$netif_pnetid" == "$hsif_pnetid" ]; then
|
||||
hsci_pnetid=$hsif_pnetid
|
||||
else
|
||||
if [ "$hsif_pnetid" != "" ]; then
|
||||
hsci_pnetid=$hsif_pnetid
|
||||
else
|
||||
hsci_pnetid=$netif_pnetid
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -96,11 +124,11 @@ function verify_precon {
|
||||
echo "Error: $hsdev does not exist" >&2
|
||||
return 1
|
||||
fi
|
||||
if [ "$(cat /sys/class/net/$hsdev/device/card_type)" != "HiperSockets" ]; then
|
||||
if [ "$(cat /sys/class/net/$hsdev/device/card_type 2>/dev/null)" != "HiperSockets" ]; then
|
||||
echo "Error: $hsdev is not a HiperSockets device" >&2
|
||||
return 1
|
||||
fi
|
||||
if [ "$(cat /sys/class/net/$hsdev/device/layer2)" != "1" ]; then
|
||||
if [ "$(cat /sys/class/net/$hsdev/device/layer2 2>/dev/null)" != "1" ]; then
|
||||
echo "Error: $hsdev is not in layer 2 mode" >&2
|
||||
return 1
|
||||
fi
|
||||
@@ -108,7 +136,7 @@ function verify_precon {
|
||||
echo "Error: Missing vnic-characteristics support" >&2
|
||||
return 1
|
||||
fi
|
||||
if [ "$(cat /sys/class/net/$hsdev/device/vnicc/bridge_invisible)" == "n/a" ]; then
|
||||
if [ "$(cat /sys/class/net/$hsdev/device/vnicc/bridge_invisible 2>/dev/null)" == "n/a" ]; then
|
||||
echo "Error: $hsdev does not support vnicc" >&2
|
||||
return 1
|
||||
fi
|
||||
@@ -121,8 +149,10 @@ function verify_precon {
|
||||
return 1
|
||||
fi
|
||||
if [ $(ip link show $hsdev | grep master | wc -l) -ne 0 ]; then
|
||||
echo "Error: $hsdev is already a bridge port" >&2
|
||||
return 1
|
||||
if [ $(ip link show $hsdev | grep "master $hsci" | wc -l) -eq 0 ]; then
|
||||
echo "Error: $hsdev is already a subordinate to another master" >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
#Pre-verify net_dev
|
||||
@@ -130,17 +160,15 @@ function verify_precon {
|
||||
echo "Error: $ndev does not exist" >&2
|
||||
return 1
|
||||
fi
|
||||
if [ "$(cat /sys/class/net/$ndev/device/card_type)" == "HiperSockets" ]; then
|
||||
echo "Error: $ndev is also a HiperSockets device" >&2
|
||||
return 1
|
||||
fi
|
||||
if [ $(ip link show $ndev | grep UP | wc -l) -eq 0 ]; then
|
||||
echo "Error: $ndev is not in state UP" >&2
|
||||
return 1
|
||||
fi
|
||||
if [ $(ip link show $ndev | grep master | wc -l) -ne 0 ]; then
|
||||
echo "Error: $ndev is already a bridge port" >&2
|
||||
return 1
|
||||
if [ $(ip link show $ndev | grep "master $hsci" | wc -l) -eq 0 ]; then
|
||||
echo "Error: $ndev is already a subordinate to another master" >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
#Check PNETIDs
|
||||
@@ -153,10 +181,12 @@ function verify_precon {
|
||||
}
|
||||
|
||||
function clean_up {
|
||||
ip link del $hsci >/dev/null 2>&1
|
||||
bridge link set dev $hsdev learning_sync off self >/dev/null 2>&1
|
||||
echo 0 > /sys/class/net/$hsdev/device/vnicc/bridge_invisible >/dev/null 2>&1
|
||||
bridge fdb del $hsdev_mac dev $ndev >/dev/null 2>&1
|
||||
ip link del $hsci >/dev/null 2>&1
|
||||
bridge fdb del $hsci_mac dev $hsdev self local >/dev/null 2>&1
|
||||
bridge fdb del $hsci_mac dev $ndev self local >/dev/null 2>&1
|
||||
ip link del $hscibr >/dev/null 2>&1
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
@@ -172,22 +202,33 @@ function add_hsci {
|
||||
hsdev=$1
|
||||
ndev=$2
|
||||
|
||||
hsci_postfix="$(readlink /sys/class/net/$hsdev/device/cdev0 | tail -c5)"
|
||||
hscibr=hsci$hsci_postfix-br
|
||||
hscibp=hsci$hsci_postfix-bp
|
||||
hsci=hsci$hsci_postfix
|
||||
|
||||
#### Verify preconditions
|
||||
verify_precon
|
||||
if [ $? -ne 0 ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
hsci_postfix="$(readlink /sys/class/net/$hsdev/device/cdev0 | tail -c5)"
|
||||
hsci=hsci$hsci_postfix
|
||||
|
||||
echo "Adding $hsci with a HiperSockets dev $hsdev and an external dev $ndev"
|
||||
|
||||
#### Create bridge
|
||||
ip link add name $hsci type bridge stp_state 0 >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Could not create a bridge" >&2
|
||||
return 1
|
||||
#### Create bridge (idempotent)
|
||||
if [ ! -e /sys/class/net/$hscibr ]; then
|
||||
# ageing_time of $hscibr defaults to 30000 (300 secs)
|
||||
ip link add name $hscibr type bridge stp_state 0 >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Could not create a bridge" >&2
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
ip link set dev $hscibr type bridge stp_state 0 >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: $hscibr is not a bridge" >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
#### Prepare hsdev
|
||||
@@ -196,19 +237,24 @@ function add_hsci {
|
||||
echo 1 > /sys/class/net/$hsdev/device/vnicc/bridge_invisible
|
||||
|
||||
#### Create bridge ports
|
||||
ip link set dev $ndev master $hsci >/dev/null 2>&1
|
||||
ip link set dev $ndev master $hscibr >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Could not set master for $ndev" >&2
|
||||
clean_up
|
||||
return 1
|
||||
fi
|
||||
ip link set dev $hsdev master $hsci >/dev/null 2>&1
|
||||
ip link set dev $hsdev master $hscibr >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Could not set master for $hsdev" >&2
|
||||
clean_up
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Do not learn from ndev, but do learn from hsci-bp:
|
||||
# - First define hsdev and ndev as _isolated_ bridgeports
|
||||
# - Then turn on learning_sync on self on hsdev
|
||||
# - Then define hsci-bp as non-isolated veth bridgeport
|
||||
|
||||
# no forwarding between ndev and hsdev -> isolated on
|
||||
# ndev is default for outgoing unknown targets -> flood on
|
||||
# no need to learn external LAN targets into fdb -> learning off
|
||||
@@ -230,29 +276,102 @@ function add_hsci {
|
||||
clean_up
|
||||
return 1
|
||||
fi
|
||||
|
||||
# NOTE: Although not required, BCs will be sent out on hsdev.
|
||||
# NOTE: We need to receive BCs on hsdev, as z/OS HSCI does ARP requests on HS.
|
||||
|
||||
hsdev_mac="$(cat /sys/class/net/$hsdev/address)"
|
||||
echo "Set $hsdev MAC $hsdev_mac on $ndev and $hsci"
|
||||
|
||||
# set HS MAC on OSA as secondary MAC
|
||||
bridge fdb add $hsdev_mac dev $ndev >/dev/null 2>&1
|
||||
ip link set dev $hscibr up >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Failed to set HS MAC on OSA as secondary MAC" >&2
|
||||
echo "Error: Failed to set $hscibr up" >&2
|
||||
clean_up
|
||||
return 1
|
||||
fi
|
||||
|
||||
# set HS MAC (common MAC) on HSCI as primary MAC
|
||||
ip link set address $hsdev_mac dev $hsci >/dev/null 2>&1
|
||||
#### Turn on device for bridge notification
|
||||
#### Toggle is required to learn full list of HS targets,
|
||||
#### not only future changes.
|
||||
bridge link set dev $hsdev learning_sync off self >/dev/null 2>&1
|
||||
bridge link set dev $hsdev learning_sync on self >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Failed to set HiperSockets MAC (common MAC) on HSCI as primary MAC" >&2
|
||||
echo "Error: Failed to turn on device for bridge notification" >&2
|
||||
clean_up
|
||||
return 1
|
||||
fi
|
||||
|
||||
# define veth pair for hsci (idempotent)
|
||||
if [ ! -e /sys/class/net/$hsci ]; then
|
||||
ip link add dev $hsci type veth peer name $hscibp >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Could not create veth pair $hsci - $hscibp " >&2
|
||||
clean_up
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
if [ $hsci@$hscibp: != "$(ip -o -d link show dev $hsci | awk '/veth/ {print $2}' )" ]; then
|
||||
echo "Error: $hsci@$hscibp is not a veth" >&2
|
||||
clean_up
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
ip link set dev $hscibp master $hscibr >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Failed to add $hscibp to $hscibr" >&2
|
||||
clean_up
|
||||
return 1
|
||||
fi
|
||||
bridge link set dev $hscibp isolated off learning on flood on mcast_flood on >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Failed to set bridge parameters for $hscibp" >&2
|
||||
clean_up
|
||||
return 1
|
||||
fi
|
||||
|
||||
#### Set a static forwarding rule for hsci MAC, so hsci can be used as a
|
||||
#### single-MAC network interface without being subject to
|
||||
#### ageing and re-learning
|
||||
#### Wait for systemd to change the MAC of hsci, if it wants to:
|
||||
sleep 1
|
||||
hsci_mac="$(cat /sys/class/net/$hsci/address)"
|
||||
#### (idempotent)
|
||||
if [ $(bridge fdb show dev $hscibp | grep "$hsci_mac master $hscibr static" | wc -l) -eq 0 ]; then
|
||||
bridge fdb add $hsci_mac dev $hscibp master static
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Failed to set $hsci_mac to $hscibr fdb" >&2
|
||||
clean_up
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Bridge-to-device learning will set this MAC on hsdev and ndev.
|
||||
# Old kernel code doesn't do hsci bridge-to-device learning.
|
||||
# In this case: Set hsci_mac as local MAC of hsdev and ndev,
|
||||
# so at least the single-MAC scenario works.
|
||||
if [ $(bridge fdb show dev $hsdev | grep "$hsci_mac self permanent" | wc -l) -eq 0 ]; then
|
||||
echo "Warning: $hsci will support only its current static MAC address. Please upgrade your kernel to the latest level." >&2
|
||||
bridge fdb add $hsci_mac dev $hsdev self local
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Failed to add $hsci_mac to $hsdev" >&2
|
||||
clean_up
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
if [ $(bridge fdb show dev $ndev | grep "$hsci_mac self permanent" | wc -l) -eq 0 ]; then
|
||||
bridge fdb add $hsci_mac dev $ndev self local
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Failed to add $hsci_mac to $ndev" >&2
|
||||
clean_up
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
#### Set veth pair to UP
|
||||
ip link set dev $hscibp up >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Failed to set $hscibp up" >&2
|
||||
clean_up
|
||||
return 1
|
||||
fi
|
||||
ip link set dev $hsci up >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Failed to set $hsci up" >&2
|
||||
@@ -260,14 +379,7 @@ function add_hsci {
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Turn on device for bridge notification
|
||||
bridge link set dev $hsdev learning_sync on self >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Failed to turn on device for bridge notification" >&2
|
||||
clean_up
|
||||
return 1
|
||||
fi
|
||||
echo "Successfully added HSCI interface $hsci"
|
||||
echo "Added HSCI interface $hsci"
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -286,51 +398,97 @@ function del_hsci {
|
||||
echo "Error: $hsci does not exit" >&2
|
||||
return 1
|
||||
fi
|
||||
if [ $(ip link show | grep "master $hsci" | wc -l) -eq 0 ]; then
|
||||
echo "Error: $hsci is not an active HSCI interface" >&2
|
||||
return 1
|
||||
hsci_mac="$(cat /sys/class/net/$hsci/address)"
|
||||
|
||||
#### Find hscibp and hscibr
|
||||
hscibp="$(ip -o link show dev $hsci | awk '{print $2}')"
|
||||
if [[ $hscibp != *@* ]]; then
|
||||
# $hsci has no HSCI veth peer
|
||||
echo "Warning: $hsci may have been created by an older version of hsci" >&2
|
||||
mvp=1
|
||||
hscibp=""
|
||||
hscibr=$hsci
|
||||
else
|
||||
mvp=0
|
||||
hscibp=${hscibp##*@}
|
||||
hscibp=${hscibp%:}
|
||||
echo "$hsci is paired with $hscibp" >&2
|
||||
|
||||
hscibr="$(ip link show dev $hscibp | awk '{for(x=1;x<NF;x++) if($x~/master/) print $(x+1)}')"
|
||||
fi
|
||||
|
||||
bports="$(ip link show | grep "master $hsci" | awk '{print $2}')"
|
||||
#### Find hsdev and ndev
|
||||
hsdev=""
|
||||
ndev=""
|
||||
bports="$(ip link show | grep "master $hscibr" | awk '{print $2}')"
|
||||
for bport in $bports; do
|
||||
bport=${bport%:}
|
||||
if [[ $bport == *@* ]]; then
|
||||
bport=${bport%@*}
|
||||
fi
|
||||
if [ $(bridge -d link show dev $bport | grep "learning_sync on" | wc -l) -ne 0 ]; then
|
||||
hsdev=$bport
|
||||
else
|
||||
ndev=$bport
|
||||
bport=${bport%@*}
|
||||
if [ $(bridge -d link show dev $bport | grep "isolated on" | wc -l) -ne 0 ]; then
|
||||
if [ $(bridge -d link show dev $bport | grep "learning_sync on" | wc -l) -ne 0 ]; then
|
||||
hsdev=$bport
|
||||
else
|
||||
ndev=$bport
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [ "$hsdev" == "" ]; then
|
||||
echo "Error: $hsci has no active HiperSockets port" >&2
|
||||
return 1
|
||||
fi
|
||||
echo "Deleting HSCI interface $hsci with the HiperSockets $hsdev and the external $ndev"
|
||||
|
||||
bridge link set dev $hsdev learning_sync off self >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Failed to turn off learning_sync on $hsdev" >&2
|
||||
return 1
|
||||
fi
|
||||
echo 0 > /sys/class/net/$hsdev/device/vnicc/bridge_invisible
|
||||
|
||||
hsdev_mac="$(cat /sys/class/net/$hsdev/address)"
|
||||
echo "Deleting $hsev MAC $hsdev_mac on $ndev"
|
||||
bridge fdb del $hsdev_mac dev $ndev >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Failed to delete $hsev MAC $hsdev_mac on $ndev" >&2
|
||||
return 1
|
||||
if [ "$ndev" == "" ]; then
|
||||
echo "Error: $hsci has no active external port" >&2
|
||||
fi
|
||||
echo "Deleting HSCI interface $hsci with HiperSockets interface $hsdev and external interface $ndev"
|
||||
|
||||
#### Delete veth before resetting learning_sync and deleting bridge,
|
||||
#### so fdb entries are cleaned up (synced)!
|
||||
ip link del $hsci >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Failed to delete $hsci" >&2
|
||||
return 1
|
||||
fi
|
||||
echo "Successfully deleted device $hsci"
|
||||
# Bridge-to-device learning will remove learned MACs from hsdev and ndev.
|
||||
# Old kernel code doesn't do hsci bridge-to-device learning.
|
||||
# In this case: Remove the hsci_mac that was added during 'add' from
|
||||
# hsdev and ndev.
|
||||
if [ "$hsdev" != "" ] && [ $mvp -eq 0 ]; then
|
||||
if [ $(bridge fdb show dev $hsdev | grep "$hsci_mac self permanent" | wc -l) -ne 0 ]; then
|
||||
echo "Warning: It seems your kernel does not support all hsci features, please upgrade." >&2
|
||||
bridge fdb del $hsci_mac dev $hsdev self local
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Failed to delete $hsci_mac from $hsdev" >&2
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
# In the mvp case hsci_mac == hs_mac and was only set on ndev.
|
||||
if [ "$ndev" != "" ]; then
|
||||
if [ $(bridge fdb show dev $ndev | grep "$hsci_mac self permanent" | wc -l) -ne 0 ]; then
|
||||
bridge fdb del $hsci_mac dev $ndev self local
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Failed to delete $hsci_mac from $ndev" >&2
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
#### Reset learning_sync
|
||||
if [ "$hsdev" != "" ]; then
|
||||
bridge link set dev $hsdev learning_sync off self >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Failed to turn off learning_sync on $hsdev" >&2
|
||||
fi
|
||||
fi
|
||||
#### Delete bridge
|
||||
if [ "$hscibr" != "" ]; then
|
||||
ip link del $hscibr >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Failed to delete $hscibr" >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$hsdev" != "" ]; then
|
||||
echo 0 > /sys/class/net/$hsdev/device/vnicc/bridge_invisible
|
||||
fi
|
||||
|
||||
echo "Deleted $hsci"
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -338,19 +496,63 @@ function del_hsci {
|
||||
## Show HSCI
|
||||
##############################################################################
|
||||
|
||||
function list_active {
|
||||
hsdev=$1
|
||||
local ext=""
|
||||
function print_row {
|
||||
if [ $mvp -eq 0 ]; then
|
||||
printf '%-8s %-16s %-15s %-15s\n' "$hsci" "$hsci_pnetid" "$hsdev" "$ndev"
|
||||
else
|
||||
printf '%-8s %-16s %-15s %-15s (v1)\n' "$hsci" "$hsci_pnetid" "$hsdev" "$ndev"
|
||||
fi
|
||||
}
|
||||
|
||||
hsci="$(ip link show dev $hsdev | awk '{for(x=1;x<NF;x++) if($x~/master/) print $(x+1)}')"
|
||||
ext="$(ip link show | grep "master $hsci" | grep --invert-match $hsdev | awk '{print $2}')"
|
||||
# remove trailing ':'
|
||||
ndev="${ext%:}"
|
||||
function list_active {
|
||||
hsci=""
|
||||
hsdev=$1
|
||||
ndev=""
|
||||
hscibp=""
|
||||
mvp=1
|
||||
|
||||
hsci_pnetid="$(get_pnetid $hsdev)"
|
||||
|
||||
hscibr="$(ip link show dev $hsdev | awk '{for(x=1;x<NF;x++) if($x~/master/) print $(x+1)}')"
|
||||
if [ "$hscibr" == "" ]; then
|
||||
print_row
|
||||
return 0
|
||||
fi
|
||||
|
||||
#### find ndev (the other isolated subordinate)
|
||||
bports="$(ip link show | grep "master $hscibr" | awk '{print $2}')"
|
||||
for bport in $bports; do
|
||||
bport=${bport%:}
|
||||
bport=${bport%@*}
|
||||
if [ $(ip -d link show dev $bport | grep "isolated on" | wc -l) -ne 0 ]; then
|
||||
if [ $bport != $hsdev ]; then
|
||||
ndev=$bport
|
||||
fi
|
||||
else
|
||||
hscibp=$bport
|
||||
mvp=0
|
||||
fi
|
||||
done
|
||||
|
||||
check_pnetids
|
||||
|
||||
printf '%-8s %-16s %-15s %-15s\n' "$hsci" "$hsci_pnetid" "$hsdev" "$ndev"
|
||||
if [ $mvp -ne 0 ]; then
|
||||
hsci=$hscibr
|
||||
print_row
|
||||
return 0
|
||||
fi
|
||||
|
||||
#### find hsci (veth-peer of non-isolated subordinate of hscibr)
|
||||
hsci="$(ip -o link show dev $hscibp | awk '{print $2}')"
|
||||
if [[ $hsci != *@* ]]; then
|
||||
echo "Error: $hscibp has no HSCI veth peer" >&2
|
||||
print_row
|
||||
return 1
|
||||
fi
|
||||
hsci=${hsci##*@}
|
||||
hsci=${hsci%:}
|
||||
|
||||
print_row
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -358,13 +560,14 @@ function print_header {
|
||||
if [ $header -eq 0 ]; then
|
||||
echo "HSCI PNET_ID HiperSockets External "
|
||||
echo "------------------------------------------------------------"
|
||||
header=1
|
||||
fi
|
||||
}
|
||||
|
||||
function list_one {
|
||||
local hsnetdev=$1
|
||||
|
||||
if [ $(bridge -d link show dev $hsnetdev | grep "learning_sync on" | wc -l) -ne 0 ]; then
|
||||
if [ $(bridge -d link show dev $hsnetdev 2>/dev/null | grep "learning_sync on" | wc -l) -ne 0 ]; then
|
||||
print_header
|
||||
list_active $hsnetdev
|
||||
fi
|
||||
@@ -433,4 +636,3 @@ while true; do
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
@@ -20,6 +20,10 @@ void util_hexdump(FILE *fh, const char *tag, const void *data, int cnt);
|
||||
void util_hexdump_grp(FILE *fh, const char *tag, const void *data, int group,
|
||||
int cnt, int indent);
|
||||
void util_print_indented(const char *str, int indent);
|
||||
const char *util_libdir(void);
|
||||
const char *util_libdir_path(const char *filename);
|
||||
const char *util_datadir(void);
|
||||
const char *util_datadir_path(const char *filename);
|
||||
|
||||
static inline void util_ptr_vec_free(void **ptr_vec, int count)
|
||||
{
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
#define TOOLS_LIBDIR STRINGIFY (S390_TOOLS_LIBDIR)
|
||||
#define TOOLS_SYSCONFDIR STRINGIFY (S390_TOOLS_SYSCONFDIR)
|
||||
#define TOOLS_BINDIR STRINGIFY (S390_TOOLS_BINDIR)
|
||||
#define TOOLS_DATADIR STRINGIFY (S390_TOOLS_DATADIR)
|
||||
|
||||
#define __noreturn __attribute__((noreturn))
|
||||
#define __packed __attribute__((packed))
|
||||
|
||||
@@ -47,6 +47,8 @@ detect-openssl-version.dep:
|
||||
echo "}" >> $(TMPFILE)
|
||||
mv $(TMPFILE) $@
|
||||
|
||||
CURL_CONFIG ?= curl-config
|
||||
|
||||
check-dep-libekmfweb: detect-openssl-version.dep
|
||||
$(call check_dep, \
|
||||
"libekmfweb", \
|
||||
@@ -64,8 +66,8 @@ check-dep-libekmfweb: detect-openssl-version.dep
|
||||
"curl/curl.h", \
|
||||
"libcurl-devel", \
|
||||
"HAVE_LIBCURL=0" \
|
||||
`curl-config --cflags` `curl-config --libs`)
|
||||
curl-config --ssl-backends | grep OpenSSL >/dev/null 2>&1 || { echo "Error: libcurl is not built with the OpenSSL backend"; exit 1; }
|
||||
`$(CURL_CONFIG) --cflags` `$(CURL_CONFIG) --libs`)
|
||||
$(CURL_CONFIG) --ssl-backends | grep OpenSSL >/dev/null 2>&1 || { echo "Error: libcurl is not built with the OpenSSL backend"; exit 1; }
|
||||
touch check-dep-libekmfweb
|
||||
|
||||
skip-libekmfweb-openssl:
|
||||
@@ -83,8 +85,8 @@ ekmfweb.o: check-dep-libekmfweb ekmfweb.c utilities.h cca.h $(rootdir)include/ek
|
||||
utilities.o: check-dep-libekmfweb utilities.c utilities.h $(rootdir)include/ekmfweb/ekmfweb.h
|
||||
cca.o: check-dep-libekmfweb cca.c cca.h utilities.h $(rootdir)include/ekmfweb/ekmfweb.h
|
||||
|
||||
libekmfweb.so.$(VERSION): ALL_CFLAGS += -fPIC `curl-config --cflags`
|
||||
libekmfweb.so.$(VERSION): LDLIBS = -ljson-c -lcrypto -lssl `curl-config --libs` -ldl
|
||||
libekmfweb.so.$(VERSION): ALL_CFLAGS += -fPIC `$(CURL_CONFIG) --cflags`
|
||||
libekmfweb.so.$(VERSION): LDLIBS = -ljson-c -lcrypto -lssl `$(CURL_CONFIG) --libs` -ldl
|
||||
libekmfweb.so.$(VERSION): ALL_LDFLAGS += -shared -Wl,--version-script=libekmfweb.map \
|
||||
-Wl,-z,defs,-Bsymbolic -Wl,-soname,libekmfweb.so.$(VERM)
|
||||
libekmfweb.so.$(VERSION): ekmfweb.o utilities.o cca.o $(libs)
|
||||
|
||||
@@ -50,6 +50,9 @@ detect-openssl-version.dep:
|
||||
echo "}" >> $(TMPFILE)
|
||||
mv $(TMPFILE) $@
|
||||
|
||||
CURL_CONFIG ?= curl-config
|
||||
XML2_CONFIG ?= xml2-config
|
||||
|
||||
check-dep-libkmipclient: detect-openssl-version.dep
|
||||
$(call check_dep, \
|
||||
"libkmipclient", \
|
||||
@@ -67,14 +70,14 @@ check-dep-libkmipclient: detect-openssl-version.dep
|
||||
"libxml/tree.h", \
|
||||
"libxml2-devel", \
|
||||
"HAVE_LIBXML2=0", \
|
||||
`xml2-config --cflags` `xml2-config --libs`)
|
||||
`$(XML2_CONFIG) --cflags` `$(XML2_CONFIG) --libs`)
|
||||
$(call check_dep, \
|
||||
"libkmipclient", \
|
||||
"curl/curl.h", \
|
||||
"libcurl-devel", \
|
||||
"HAVE_LIBCURL=0" \
|
||||
`curl-config --cflags` `curl-config --libs`)
|
||||
curl-config --ssl-backends | grep OpenSSL >/dev/null 2>&1 || { echo "Error: libcurl is not built with the OpenSSL backend"; exit 1; }
|
||||
`$(CURL_CONFIG) --cflags` `$(CURL_CONFIG) --libs`)
|
||||
$(CURL_CONFIG) --ssl-backends | grep OpenSSL >/dev/null 2>&1 || { echo "Error: libcurl is not built with the OpenSSL backend"; exit 1; }
|
||||
touch check-dep-libkmipclient
|
||||
|
||||
skip-libkmipclient-openssl:
|
||||
@@ -104,8 +107,8 @@ tls.o: check-dep-libkmipclient tls.c kmip.h utils.h $(rootdir)include/kmipclient
|
||||
names.o: check-dep-libkmipclient names.c names.h utils.h $(rootdir)include/kmipclient/kmipclient.h
|
||||
utils.o: check-dep-libkmipclient utils.c names.h utils.h $(rootdir)include/kmipclient/kmipclient.h
|
||||
|
||||
libkmipclient.so.$(VERSION): ALL_CFLAGS += -fPIC `xml2-config --cflags` `curl-config --cflags`
|
||||
libkmipclient.so.$(VERSION): LDLIBS = -ljson-c -lcrypto -lssl `xml2-config --libs` `curl-config --libs`
|
||||
libkmipclient.so.$(VERSION): ALL_CFLAGS += -fPIC `$(XML2_CONFIG) --cflags` `$(CURL_CONFIG) --cflags`
|
||||
libkmipclient.so.$(VERSION): LDLIBS = -ljson-c -lcrypto -lssl `$(XML2_CONFIG) --libs` `$(CURL_CONFIG) --libs`
|
||||
libkmipclient.so.$(VERSION): ALL_LDFLAGS += -shared -Wl,--version-script=libkmipclient.map \
|
||||
-Wl,-z,defs,-Bsymbolic -Wl,-soname,libkmipclient.so.$(VERM)
|
||||
libkmipclient.so.$(VERSION): kmip.o request.o response.o attribute.o key.o ttlv.o json.o \
|
||||
|
||||
@@ -125,7 +125,7 @@ int kmip_parse_hex(const char *str, bool has_prefix, unsigned char **val,
|
||||
{
|
||||
unsigned char *buf;
|
||||
BIGNUM *b = NULL;
|
||||
int len, rc;
|
||||
int len;
|
||||
|
||||
if (str == NULL)
|
||||
return -EINVAL;
|
||||
@@ -133,18 +133,20 @@ int kmip_parse_hex(const char *str, bool has_prefix, unsigned char **val,
|
||||
if (has_prefix && strncmp(str, "0x", 2) != 0)
|
||||
return -EBADMSG;
|
||||
|
||||
rc = BN_hex2bn(&b, str + (has_prefix ? 2 : 0));
|
||||
if (rc <= 0)
|
||||
len = BN_hex2bn(&b, str + (has_prefix ? 2 : 0));
|
||||
if (len <= 0)
|
||||
return -EBADMSG;
|
||||
if (len < (int)strlen(str) - (has_prefix ? 2 : 0))
|
||||
return -EBADMSG;
|
||||
|
||||
len = BN_num_bytes(b);
|
||||
len = len / 2 + (len % 2 > 0 ? 1 : 0);
|
||||
buf = calloc(1, len);
|
||||
if (buf == NULL) {
|
||||
BN_free(b);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (BN_bn2bin(b, buf) != len) {
|
||||
if (BN_bn2binpad(b, buf, len) != len) {
|
||||
BN_free(b);
|
||||
free(buf);
|
||||
return -EIO;
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#include <err.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lib/util_base.h"
|
||||
@@ -91,3 +93,91 @@ void util_print_indented(const char *str, int indent)
|
||||
printf("\n");
|
||||
free(desc_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the absolute name of an s390-tools system directory
|
||||
* (it could be data, or library directory)
|
||||
*/
|
||||
static const char *util_sysdir(const char *env_var, const char *default_dir)
|
||||
{
|
||||
return secure_getenv(env_var) ?: default_dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the absolute name of a file installed in the s390-tools
|
||||
* system directory
|
||||
*/
|
||||
static const char *util_sysdir_path(const char *filename, const char *dirname)
|
||||
{
|
||||
static char libdir_pathname[PATH_MAX];
|
||||
int ret;
|
||||
|
||||
ret = snprintf(libdir_pathname, sizeof(libdir_pathname),
|
||||
"%s/%s", dirname, filename);
|
||||
|
||||
if (ret < 0 || ret >= (int)sizeof(libdir_pathname))
|
||||
errx(EXIT_FAILURE,
|
||||
"Could not compose absolute pathname of %s and %s",
|
||||
dirname, filename);
|
||||
return libdir_pathname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the absolute name of a s390-tools library directory
|
||||
*
|
||||
* Resources are handled by the library
|
||||
*
|
||||
* @returns Pointer to a buffer, which contains the null-terminated name
|
||||
*/
|
||||
const char *util_libdir(void)
|
||||
{
|
||||
return util_sysdir("S390TOOLS_LIBDIR", TOOLS_LIBDIR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the absolute name of a file installed in the s390-tools
|
||||
* library directory by its relative name.
|
||||
*
|
||||
* Resources are handled by the library. A second call of this function
|
||||
* overwrites previously returned data. Care must be taken when attempting
|
||||
* to do a second call.
|
||||
*
|
||||
* @param[in] filename Null-terminated file name relative to the s390-tools
|
||||
* library directory
|
||||
* @returns Pointer to a buffer of PATH_MAX size, which contains the
|
||||
* null-terminated absolute name
|
||||
*/
|
||||
const char *util_libdir_path(const char *filename)
|
||||
{
|
||||
return util_sysdir_path(filename, util_libdir());
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the absolute name of a s390-tools data directory
|
||||
*
|
||||
* Resources are handled by the library
|
||||
*
|
||||
* @returns Pointer to a buffer which contains the null-terminated name
|
||||
*/
|
||||
const char *util_datadir(void)
|
||||
{
|
||||
return util_sysdir("S390TOOLS_DATADIR", TOOLS_DATADIR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the absolute name of a file installed in the s390-tools
|
||||
* data directory by its relative name.
|
||||
*
|
||||
* Resources are handled by the library. A second call of this function
|
||||
* overwrites previously returned data. Care must be taken when attempting
|
||||
* to do a second call.
|
||||
*
|
||||
* @param[in] filename Null-terminated file name relative to the s390-tools
|
||||
* data directory
|
||||
* @returns Pointer to a buffer of PATH_MAX size, which contains the
|
||||
* null-terminated absolute name
|
||||
*/
|
||||
const char *util_datadir_path(const char *filename)
|
||||
{
|
||||
return util_sysdir_path(filename, util_datadir());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
include ../common.mak
|
||||
|
||||
SCRIPTS = dbginfo.sh zfcpdbf zipl-switch-to-blscfg scsi_logging_level
|
||||
SCRIPTS = dbginfo.sh zfcpdbf zipl-switch-to-blscfg scsi_logging_level
|
||||
SCRIPTS += sclpdbf
|
||||
MAN_PAGES = dbginfo.sh.1 zfcpdbf.1 zipl-switch-to-blscfg.1
|
||||
|
||||
all:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
.TH DBGINFO.SH 1 "April 2021" "s390-tools"
|
||||
.TH DBGINFO.SH 1 "September 2021" "s390-tools"
|
||||
|
||||
.SH NAME
|
||||
dbginfo.sh \- collect runtime, configuration and trace information
|
||||
@@ -14,8 +14,10 @@ for debugging Linux on IBM Z
|
||||
This script collects runtime, configuration and trace information that can
|
||||
be used to debug a Linux on IBM Z instance.
|
||||
For Linux on z/VM, the script also traces information about the z/VM system.
|
||||
KVM or DOCKER data ist collected on a host serving this.
|
||||
|
||||
The debug information is written to a file
|
||||
/tmp/DBGINFO\-<date>\-<time>\-<hostname>\-<processorid>.tgz
|
||||
/<DIRECTORY>/DBGINFO\-<date>\-<time>\-<hostname>\-<processorid>.tgz
|
||||
where [date] and [time] are the date and time when the debug data was
|
||||
collected. [hostname] indicates the hostname of the system the data was
|
||||
collected from. The [processorid] is taken from the processor 0 and indicates
|
||||
@@ -32,7 +34,12 @@ Print version information, then exit.
|
||||
|
||||
.TP
|
||||
\fB\-d <DIRECTORY>\fP, \fB\-\-directory <DIRECTORY>\fP
|
||||
Specify the DIRECTORY where the data collection stores the temporary data and the final archive. The specified directory must already exist. If this parameter is not specified, /tmp is used by default.
|
||||
Specify the DIRECTORY where the data collection stores the temporary data and the final archive.
|
||||
The specified directory must already exist. If this parameter is not specified, /tmp is used by default.
|
||||
|
||||
.TP
|
||||
\fB\-c\fP, \fB\-\-check\fP
|
||||
Print online quick check (not saving any data) - can be combind with a preceding -d option.
|
||||
|
||||
.SH FILES
|
||||
A .tgz file of the form
|
||||
@@ -56,48 +63,57 @@ Copyright IBM Corp. 2002, 2021
|
||||
.PP
|
||||
Hardware platform = s390x
|
||||
.br
|
||||
Kernel version = 5.4.0 (5.4.0-70-generic)
|
||||
.br
|
||||
Runtime environment = z/VM
|
||||
.br
|
||||
Kernel version = 4.18.0 (4.18.0-305.el8.s390x)
|
||||
.br
|
||||
OS version / distro = Red Hat Enterprise Linux 8.4 (Ootpa)
|
||||
.br
|
||||
Date and time of info = 2021-08-26-15-27-58
|
||||
.PP
|
||||
1 of 16: Collecting command output
|
||||
1 of 18: Collecting sysfs
|
||||
.PP
|
||||
2 of 16: Collecting z/VM command output
|
||||
2 of 18: Collecting procfs
|
||||
.PP
|
||||
3 of 16: Collecting procfs
|
||||
3 of 18: Collecting config files
|
||||
.PP
|
||||
4 of 16: Collecting sysfs
|
||||
4 of 18: Collecting command output
|
||||
.PP
|
||||
5 of 16: Collecting log files
|
||||
5 of 18: Collecting hyptop for z/VM - 5s output
|
||||
.PP
|
||||
6 of 16: Collecting config files
|
||||
6 of 18: Collecting z/VM output
|
||||
.PP
|
||||
7 of 16: Collecting osa oat output
|
||||
7 of 18: Collecting network output
|
||||
.PP
|
||||
8 of 16: Collecting ethtool output
|
||||
8 of 18: Collecting osa oat output
|
||||
.PP
|
||||
9 of 16: Collecting tc output
|
||||
9 of 18: Collecting ethtool output
|
||||
.PP
|
||||
10 of 16: Collecting bridge output
|
||||
10 of 18: Collecting Trafic Control output
|
||||
.PP
|
||||
11 of 16: Collecting OpenVSwitch output
|
||||
11 of 18: Collecting bridge output
|
||||
.PP
|
||||
12a of 16: Collecting docker container
|
||||
12b of 16: Collecting docker network
|
||||
12 of 18: Skip OpenVSwitch: ovs-vsctl not available
|
||||
.PP
|
||||
13 of 16: Collecting nvme output
|
||||
13 of 18: Skip KVM: no virsh command
|
||||
.PP
|
||||
14 of 16: Collecting KVM data
|
||||
14 of 18: Collecting docker output
|
||||
.PP
|
||||
15 of 16: Postprocessing
|
||||
15 of 18: Collecting NVME storage output
|
||||
.PP
|
||||
16 of 16: Finalizing: Creating archive with collected data
|
||||
16 of 18: Collecting log files
|
||||
.PP
|
||||
0 logfiles over 50 MB
|
||||
.PP
|
||||
17 of 18: Postprocessing
|
||||
.PP
|
||||
18 of 18: Finalizing: Creating archive with collected data
|
||||
.PP
|
||||
Collected data was saved to:
|
||||
.br
|
||||
>> /data\-collection/DBGINFO\-2021\-04\-20\-14\-00\-07\-host\-012345.tgz <<
|
||||
>> /data\-collection/DBGINFO\-2021\-08\-26\-15\-27\-58\-host\-012345.tgz <<
|
||||
.br
|
||||
Review the collected data before sending to your service organization.
|
||||
Please review all collected data before sending to your service organization.
|
||||
.SH HINTS
|
||||
Run the script with root authority.
|
||||
.br
|
||||
|
||||
1172
scripts/sclpdbf
Executable file
1172
scripts/sclpdbf
Executable file
File diff suppressed because it is too large
Load Diff
@@ -887,14 +887,13 @@ sub print_scsi_common
|
||||
print "FCP rsp inf cod: 0x", substr($rec->[2], 44, 2), "\n";
|
||||
print "FCP rsp IU : ", payload_format(substr($rec->[2], 114, 48));
|
||||
|
||||
if (defined($pay_sns)) {
|
||||
print "Sense len : ", $payload_length, "\n"
|
||||
if ($payload_length);
|
||||
print_payload($payload_length, $pay_sns, "Sense info")
|
||||
}
|
||||
if (defined($pay_riu) && ($payload_length > FCP_RESP_WITH_EXT)) {
|
||||
if ($payload_length && defined($pay_sns)) {
|
||||
print "Sense len : ", $payload_length, "\n";
|
||||
print_payload($payload_length, $pay_sns, "Sense info");
|
||||
} elsif ($payload_length) {
|
||||
print "FCP rsp IU len : ", $payload_length, "\n";
|
||||
print_payload($payload_length, $pay_riu, "FCP rsp IU all");
|
||||
print_payload($payload_length, $pay_riu, "FCP rsp IU all")
|
||||
if ($payload_length > FCP_RESP_WITH_EXT);
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
|
||||
@@ -1863,7 +1863,6 @@ static void close_ur_device(struct vmur *info)
|
||||
}
|
||||
cpcmd_cs(cmd, &response, &cprc, 0);
|
||||
memcpy(spoolid, &response[9], 4);
|
||||
free(response);
|
||||
if (cprc == 439) {
|
||||
if (info->action == PUNCH)
|
||||
sprintf(cmd, "PURGE * PUN %s", spoolid);
|
||||
@@ -1872,7 +1871,10 @@ static void close_ur_device(struct vmur *info)
|
||||
cpcmd(cmd, NULL, NULL, 0);
|
||||
ERR_EXIT("User %s spool fileid limit exceeded.\n"
|
||||
, info->user);
|
||||
} else if (cprc) {
|
||||
ERR_EXIT("CP command failed with rc=%i\n%s\n", cprc, response);
|
||||
}
|
||||
free(response);
|
||||
if (info->rdr_specified) {
|
||||
if (info->node_specified)
|
||||
printf("Reader file with spoolid %s created and "
|
||||
|
||||
@@ -463,7 +463,15 @@ static int fill_io_devid(struct util_rec *rec, char *path)
|
||||
util_scandir_free(de_vec, count);
|
||||
return 1;
|
||||
}
|
||||
strncpy(buf, "none", sizeof(buf));
|
||||
if (util_file_read_line(buf, sizeof(buf), "%s/dev_busid",
|
||||
path) == 0) {
|
||||
if (cmd.opt_short) {
|
||||
if (strncmp(buf, "0.0.", PREFIX_ID_LENGTH) != 0)
|
||||
return 1;
|
||||
memmove(buf, buf + PREFIX_ID_LENGTH,
|
||||
(sizeof(buf) - PREFIX_ID_LENGTH));
|
||||
}
|
||||
}
|
||||
fill_device_info(rec, NULL, NULL);
|
||||
}
|
||||
if (cmd.opt_uppercase)
|
||||
|
||||
@@ -203,6 +203,7 @@ $(readlink -e $HOST_PATH)/-"
|
||||
|
||||
read ONLINE < $ADAPTER_PATH/online
|
||||
read AVAILABILITY < $ADAPTER_PATH/availability
|
||||
[ -r "$SYSFS/class/fc_host/$SCSI_HOST/port_state" ] && read PORT_STATE < "$SYSFS/class/fc_host/$SCSI_HOST/port_state"
|
||||
[ -r $ADAPTER_PATH/failed ] && read FAILED < $ADAPTER_PATH/failed
|
||||
DEFUNCT=${ADAPTER_PATH%/*} # strip devbusid
|
||||
DEFUNCT=${DEFUNCT##*/} # basename
|
||||
@@ -212,6 +213,8 @@ $(readlink -e $HOST_PATH)/-"
|
||||
HOSTMARKER=" defunct"
|
||||
elif [ "$ONLINE" = "0" ]; then
|
||||
HOSTMARKER=" offline"
|
||||
elif [ "$PORT_STATE" = "Linkdown" ]; then
|
||||
HOSTMARKER=" linkdown"
|
||||
elif [ "$FAILED" = "1" ]; then
|
||||
HOSTMARKER=" failed"
|
||||
elif [ "$AVAILABILITY" != "good" ]; then
|
||||
|
||||
@@ -115,6 +115,11 @@ Displays version information and exits.
|
||||
Here is an explanation of the columns displayed. Please note that some
|
||||
of the columns show up in verbose mode only.
|
||||
.TP
|
||||
.B CARD.DOM
|
||||
The crypto card number in hexadecimal for a crypto card line or
|
||||
the crypto card number and the domain id both in hex separated by a single
|
||||
dot for a queue line.
|
||||
.TP
|
||||
.B TYPE and HWTYPE
|
||||
The HWTYPE is a numeric value showing which type of hardware the zcrypt
|
||||
device driver presumes that this crypto card is. The currently known values
|
||||
@@ -145,9 +150,16 @@ may be adjusted on the HMC or SE. The chzcrypt application can also
|
||||
trigger this state with the --config-on and --config-off options.
|
||||
.br
|
||||
lszcrypt shows 'online' when a card or queue is available for
|
||||
cryptograhic operations. 'offline' is displayed when a card or queue
|
||||
cryptographic operations. 'offline' is displayed when a card or queue
|
||||
is switched to (software) offline. If a card is 'deconfigured' via
|
||||
HMC, SE or chzcrypt the field shows 'deconfig'.
|
||||
.br
|
||||
If a queue is not bound to a device driver there is no detailed
|
||||
information available and thus the status shows only '-'.
|
||||
.br
|
||||
If a queue is bound to the vfio-ap device driver it is up to this driver
|
||||
to give some status information and what exactly this means. So lszcrypt
|
||||
shows the text retrieved from the underlying sysfs attribute here.
|
||||
.TP
|
||||
.B REQUESTS
|
||||
This is the counter value of successful processed requests on card or queue
|
||||
@@ -168,7 +180,7 @@ S - APSC available: card/queue can handle requests with the special bit
|
||||
enabled.
|
||||
.br
|
||||
M - Accelerator card/queue with support for RSA ME with up to 4k key size.
|
||||
.br
|
||||
.Sr
|
||||
C - Accelerator card/queue with support for RSA CRT with up to 4k key size.
|
||||
.br
|
||||
D - Card/queue is providing CCA functions (this is the CCA Coprocessor mode).
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "lib/util_scandir.h"
|
||||
#include "lib/zt_common.h"
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
/*
|
||||
* Private data
|
||||
*/
|
||||
@@ -331,13 +333,49 @@ static void show_capability(const char *id_str)
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Read driver entry in dir or in dir/subdir and store driver into buf.
|
||||
* Returns:
|
||||
* 0 if there is no driver link (no driver bound to this device or error)
|
||||
* 1 if one of the cexXcard or cexXqueue driver is bound to this device
|
||||
* 2 if the vfio is bound to this device
|
||||
*/
|
||||
static int read_driver(const char *dir, const char *subdir, char *buf, size_t buflen)
|
||||
{
|
||||
char drvlink[PATH_MAX], linktarget[PATH_MAX];
|
||||
char *p, driver[256];
|
||||
|
||||
if (subdir)
|
||||
snprintf(drvlink, sizeof(drvlink), "%s/%s/driver", dir, subdir);
|
||||
else
|
||||
snprintf(drvlink, sizeof(drvlink), "%s/driver", dir);
|
||||
drvlink[sizeof(drvlink) - 1] = '\0';
|
||||
|
||||
memset(linktarget, 0, sizeof(linktarget));
|
||||
|
||||
if (readlink(drvlink, linktarget, sizeof(linktarget)) > 0) {
|
||||
p = strrchr(linktarget, '/');
|
||||
if (p) {
|
||||
strncpy(driver, p + 1, sizeof(driver));
|
||||
driver[sizeof(driver) - 1] = '\0';
|
||||
strncpy(buf, driver, buflen);
|
||||
if (misc_regex_match(driver, "cex[0-9](card|queue)"))
|
||||
return 1;
|
||||
else if (misc_regex_match(driver, "vfio.ap"))
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read subdevice default attributes
|
||||
*/
|
||||
static void read_subdev_rec_default(struct util_rec *rec, const char *grp_dev,
|
||||
const char *sub_dev)
|
||||
{
|
||||
long value;
|
||||
long config = -1, online = -1;
|
||||
char buf[256];
|
||||
unsigned long facility;
|
||||
|
||||
@@ -346,24 +384,29 @@ static void read_subdev_rec_default(struct util_rec *rec, const char *grp_dev,
|
||||
else
|
||||
util_rec_set(rec, "type", buf);
|
||||
|
||||
if (util_path_is_readable("%s/%s/online", grp_dev, sub_dev)) {
|
||||
util_file_read_l(&value, 10, "%s/%s/online", grp_dev, sub_dev);
|
||||
if (value > 0)
|
||||
util_rec_set(rec, "online", "online");
|
||||
else {
|
||||
/* device is offline, check config (if available) */
|
||||
if (util_path_is_readable("%s/%s/config", grp_dev, sub_dev)) {
|
||||
util_file_read_l(&value, 10, "%s/%s/config", grp_dev, sub_dev);
|
||||
if (value > 0)
|
||||
util_rec_set(rec, "online", "offline");
|
||||
else
|
||||
util_rec_set(rec, "online", "deconfig");
|
||||
} else
|
||||
util_rec_set(rec, "online", "offline");
|
||||
}
|
||||
if (util_path_is_readable("%s/%s/config", grp_dev, sub_dev))
|
||||
util_file_read_l(&config, 10, "%s/%s/config", grp_dev, sub_dev);
|
||||
if (util_path_is_readable("%s/%s/online", grp_dev, sub_dev))
|
||||
util_file_read_l(&online, 10, "%s/%s/online", grp_dev, sub_dev);
|
||||
|
||||
util_rec_set(rec, "status", "-");
|
||||
if (config == 0) {
|
||||
util_rec_set(rec, "status", "deconfig");
|
||||
} else {
|
||||
/* no online attribute */
|
||||
util_rec_set(rec, "online", "-");
|
||||
if (online > 0)
|
||||
util_rec_set(rec, "status", "online");
|
||||
else if (online == 0)
|
||||
util_rec_set(rec, "status", "offline");
|
||||
else {
|
||||
/* no online attribute, maybe use status attribute */
|
||||
if (util_path_is_readable("%s/%s/status",
|
||||
grp_dev, sub_dev)) {
|
||||
util_file_read_line(buf, sizeof(buf),
|
||||
"%s/%s/status",
|
||||
grp_dev, sub_dev);
|
||||
util_rec_set(rec, "status", buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
util_file_read_ul(&facility, 16, "%s/ap_functions", grp_dev);
|
||||
@@ -376,9 +419,13 @@ static void read_subdev_rec_default(struct util_rec *rec, const char *grp_dev,
|
||||
else
|
||||
util_rec_set(rec, "mode", "Unknown");
|
||||
|
||||
util_file_read_line(buf, sizeof(buf), "%s/%s/request_count",
|
||||
grp_dev, sub_dev);
|
||||
util_rec_set(rec, "requests", buf);
|
||||
if (config == 0) {
|
||||
util_rec_set(rec, "requests", "-");
|
||||
} else {
|
||||
util_file_read_line(buf, sizeof(buf), "%s/%s/request_count",
|
||||
grp_dev, sub_dev);
|
||||
util_rec_set(rec, "requests", buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -387,19 +434,29 @@ static void read_subdev_rec_default(struct util_rec *rec, const char *grp_dev,
|
||||
static void read_subdev_rec_verbose(struct util_rec *rec, const char *grp_dev,
|
||||
const char *sub_dev)
|
||||
{
|
||||
int i;
|
||||
int i, drvinfo;
|
||||
unsigned long facility;
|
||||
char buf[256], afile[PATH_MAX];
|
||||
long depth, pending1, pending2;
|
||||
char buf[256];
|
||||
long depth, pending1, pending2, config = -1;
|
||||
|
||||
if (l.verbose == 0)
|
||||
return;
|
||||
|
||||
util_file_read_l(&pending1, 10, "%s/%s/pendingq_count",
|
||||
grp_dev, sub_dev);
|
||||
util_file_read_l(&pending2, 10, "%s/%s/requestq_count",
|
||||
grp_dev, sub_dev);
|
||||
util_rec_set(rec, "pending", "%ld", pending1 + pending2);
|
||||
drvinfo = read_driver(grp_dev, sub_dev, buf, sizeof(buf));
|
||||
util_rec_set(rec, "driver", drvinfo > 0 ? buf : "-no-driver-");
|
||||
|
||||
if (util_path_is_readable("%s/config", grp_dev))
|
||||
util_file_read_l(&config, 10, "%s/config", grp_dev);
|
||||
|
||||
if (config == 0 || drvinfo != 1) {
|
||||
util_rec_set(rec, "pending", "-");
|
||||
} else {
|
||||
util_file_read_l(&pending1, 10, "%s/%s/pendingq_count",
|
||||
grp_dev, sub_dev);
|
||||
util_file_read_l(&pending2, 10, "%s/%s/requestq_count",
|
||||
grp_dev, sub_dev);
|
||||
util_rec_set(rec, "pending", "%ld", pending1 + pending2);
|
||||
}
|
||||
|
||||
util_file_read_line(buf, sizeof(buf), "%s/hwtype", grp_dev);
|
||||
util_rec_set(rec, "hwtype", buf);
|
||||
@@ -412,14 +469,6 @@ static void read_subdev_rec_verbose(struct util_rec *rec, const char *grp_dev,
|
||||
buf[i] = facility & fac_bits[i].mask ? fac_bits[i].c : '-';
|
||||
buf[i] = '\0';
|
||||
util_rec_set(rec, "facility", buf);
|
||||
|
||||
snprintf(afile, sizeof(afile), "%s/%s/driver", grp_dev, sub_dev);
|
||||
afile[sizeof(afile) - 1] = '\0';
|
||||
memset(buf, 0, sizeof(buf));
|
||||
if (readlink(afile, buf, sizeof(buf)) > 0)
|
||||
util_rec_set(rec, "driver", strrchr(buf, '/') + 1);
|
||||
else
|
||||
util_rec_set(rec, "driver", "-no-driver-");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -467,7 +516,7 @@ static void show_subdevices(struct util_rec *rec, const char *grp_dev)
|
||||
*/
|
||||
static void read_rec_default(struct util_rec *rec, const char *grp_dev)
|
||||
{
|
||||
long value;
|
||||
long config = -1, online = -1;
|
||||
char buf[256];
|
||||
unsigned long facility;
|
||||
|
||||
@@ -486,24 +535,27 @@ static void read_rec_default(struct util_rec *rec, const char *grp_dev)
|
||||
else
|
||||
util_rec_set(rec, "mode", "Unknown");
|
||||
|
||||
if (util_path_is_readable("%s/online", grp_dev)) {
|
||||
util_file_read_l(&value, 10, "%s/online", grp_dev);
|
||||
if (value > 0)
|
||||
util_rec_set(rec, "online", "online");
|
||||
else {
|
||||
if (util_path_is_readable("%s/config", grp_dev)) {
|
||||
util_file_read_l(&value, 10, "%s/config", grp_dev);
|
||||
if (value > 0)
|
||||
util_rec_set(rec, "online", "offline");
|
||||
else
|
||||
util_rec_set(rec, "online", "deconfig");
|
||||
} else
|
||||
util_rec_set(rec, "online", "offline");
|
||||
}
|
||||
if (util_path_is_readable("%s/config", grp_dev))
|
||||
util_file_read_l(&config, 10, "%s/config", grp_dev);
|
||||
if (util_path_is_readable("%s/online", grp_dev))
|
||||
util_file_read_l(&online, 10, "%s/online", grp_dev);
|
||||
if (config == 0) {
|
||||
util_rec_set(rec, "status", "deconfig");
|
||||
} else {
|
||||
if (online > 0)
|
||||
util_rec_set(rec, "status", "online");
|
||||
else if (online == 0)
|
||||
util_rec_set(rec, "status", "offline");
|
||||
else
|
||||
util_rec_set(rec, "status", "-");
|
||||
}
|
||||
|
||||
util_file_read_line(buf, sizeof(buf), "%s/request_count", grp_dev);
|
||||
util_rec_set(rec, "requests", buf);
|
||||
if (config == 0) {
|
||||
util_rec_set(rec, "requests", "-");
|
||||
} else {
|
||||
util_file_read_line(buf, sizeof(buf), "%s/request_count", grp_dev);
|
||||
util_rec_set(rec, "requests", buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -513,15 +565,22 @@ static void read_rec_verbose(struct util_rec *rec, const char *grp_dev)
|
||||
{
|
||||
int i;
|
||||
unsigned long facility;
|
||||
char buf[256], afile[PATH_MAX];
|
||||
long depth, pending1, pending2;
|
||||
char buf[256];
|
||||
long depth, pending1, pending2, config = -1;
|
||||
|
||||
if (l.verbose == 0)
|
||||
return;
|
||||
|
||||
util_file_read_l(&pending1, 10, "%s/pendingq_count", grp_dev);
|
||||
util_file_read_l(&pending2, 10, "%s/requestq_count", grp_dev);
|
||||
util_rec_set(rec, "pending", "%ld", pending1 + pending2);
|
||||
if (util_path_is_readable("%s/config", grp_dev))
|
||||
util_file_read_l(&config, 10, "%s/config", grp_dev);
|
||||
|
||||
if (config == 0) {
|
||||
util_rec_set(rec, "pending", "-");
|
||||
} else {
|
||||
util_file_read_l(&pending1, 10, "%s/pendingq_count", grp_dev);
|
||||
util_file_read_l(&pending2, 10, "%s/requestq_count", grp_dev);
|
||||
util_rec_set(rec, "pending", "%ld", pending1 + pending2);
|
||||
}
|
||||
|
||||
util_file_read_line(buf, sizeof(buf), "%s/hwtype", grp_dev);
|
||||
util_rec_set(rec, "hwtype", buf);
|
||||
@@ -535,13 +594,8 @@ static void read_rec_verbose(struct util_rec *rec, const char *grp_dev)
|
||||
buf[i] = '\0';
|
||||
util_rec_set(rec, "facility", buf);
|
||||
|
||||
snprintf(afile, sizeof(afile), "%s/driver", grp_dev);
|
||||
afile[sizeof(afile) - 1] = '\0';
|
||||
memset(buf, 0, sizeof(buf));
|
||||
if (readlink(afile, buf, sizeof(buf)) > 0)
|
||||
util_rec_set(rec, "driver", strrchr(buf, '/') + 1);
|
||||
else
|
||||
util_rec_set(rec, "driver", "-no-driver-");
|
||||
i = read_driver(grp_dev, NULL, buf, sizeof(buf));
|
||||
util_rec_set(rec, "driver", i > 0 ? buf : "-no-driver-");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -581,10 +635,10 @@ out_free:
|
||||
*/
|
||||
static void define_rec_default(struct util_rec *rec)
|
||||
{
|
||||
util_rec_def(rec, "card", UTIL_REC_ALIGN_LEFT, 11, "CARD.DOMAIN");
|
||||
util_rec_def(rec, "card", UTIL_REC_ALIGN_LEFT, 8, "CARD.DOM");
|
||||
util_rec_def(rec, "type", UTIL_REC_ALIGN_LEFT, 5, "TYPE");
|
||||
util_rec_def(rec, "mode", UTIL_REC_ALIGN_LEFT, 11, "MODE");
|
||||
util_rec_def(rec, "online", UTIL_REC_ALIGN_LEFT, 8, "STATUS");
|
||||
util_rec_def(rec, "status", UTIL_REC_ALIGN_LEFT, 10, "STATUS");
|
||||
util_rec_def(rec, "requests", UTIL_REC_ALIGN_RIGHT, 8, "REQUESTS");
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ all:
|
||||
install: all
|
||||
$(MAKE) -C src install
|
||||
$(MAKE) -C man install
|
||||
$(MAKE) -C udev install
|
||||
$(MAKE) -C dracut install
|
||||
$(MAKE) -C initramfs install
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ check() {
|
||||
[ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1
|
||||
|
||||
# Ensure that required tools are available
|
||||
require_binaries chzdev lszdev || return 1
|
||||
require_binaries chzdev lszdev /lib/s390-tools/zdev_id || return 1
|
||||
|
||||
return 0
|
||||
}
|
||||
@@ -40,11 +40,14 @@ install() {
|
||||
local _tempfile
|
||||
|
||||
# Ensure that required tools are available
|
||||
inst_multiple chzdev lszdev vmcp
|
||||
inst_multiple chzdev lszdev vmcp /lib/s390-tools/zdev_id
|
||||
|
||||
# Hook to parse zdev kernel parameter
|
||||
inst_hook cmdline 95 "$moddir/parse-zdev.sh"
|
||||
|
||||
# Rule to automatically enable devices when running in DPM
|
||||
inst_rules "81-dpm.rules"
|
||||
|
||||
# Obtain early + root device configuration
|
||||
_tempfile=$(mktemp --tmpdir dracut-zdev.XXXXXX)
|
||||
chzdev --export "$_tempfile" --persistent --by-path / --quiet \
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright IBM Corp. 2017
|
||||
# Copyright IBM Corp. 2017,2021
|
||||
#
|
||||
# s390-tools is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the MIT license. See LICENSE for details.
|
||||
@@ -15,11 +15,14 @@
|
||||
# where
|
||||
#
|
||||
# no-auto: Indicates that firmware-provided I/O configuration data
|
||||
# should not be applied.
|
||||
# should not be applied. This also affects automatic
|
||||
# activation of PCI and crypto devices when running in a DPM
|
||||
# LPAR.
|
||||
#
|
||||
|
||||
zdev_fw_file="/sys/firmware/sclp_sd/config/data"
|
||||
zdev_base_args="--force --yes --no-root-update --no-settle --auto-conf --quiet"
|
||||
zdev_id="/lib/s390-tools/zdev_id"
|
||||
|
||||
if [ -e "$zdev_fw_file" ] ; then
|
||||
zdev_auto=1
|
||||
@@ -35,4 +38,22 @@ done
|
||||
|
||||
if [ $zdev_auto -eq 1 ] ; then
|
||||
chzdev --import "$zdev_fw_file" $zdev_base_args
|
||||
|
||||
# Get information about DPM environment
|
||||
for line in $($zdev_id) ; do
|
||||
eval "$line"
|
||||
done
|
||||
|
||||
if [ "$ZDEV_IS_DPM,$ZDEV_NEST_LEVEL,$ZDEV_HYPERVISOR_0" = "1,1,LPAR" ] ; then
|
||||
# Manually iterate over existing PCI devices - there is a udev rule
|
||||
# that handles this for PCI devices added at runtime but that doesn't
|
||||
# work for PCI devices defined before boot because there is no coldplug
|
||||
# trigger for /sys/bus/pci/slots
|
||||
for slot in /sys/bus/pci/slots/* ; do
|
||||
read power < "$slot/power"
|
||||
if [ "$power" = "0" ] ; then
|
||||
echo 1 > "$slot/power"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -38,6 +38,9 @@ done
|
||||
copy_exec /sbin/chzdev
|
||||
copy_exec /sbin/lszdev
|
||||
copy_exec /sbin/vmcp
|
||||
copy_exec /lib/s390-tools/zdev_id
|
||||
|
||||
cp -p /usr/lib/udev/rules.d/81-dpm.rules "$DESTDIR/usr/lib/udev/rules.d/"
|
||||
|
||||
_tempfile=$(mktemp --tmpdir initramfs-zdev.XXXXXX)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright IBM Corp. 2017
|
||||
# Copyright IBM Corp. 2017,2021
|
||||
#
|
||||
# s390-tools is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the MIT license. See LICENSE for details.
|
||||
@@ -15,7 +15,9 @@
|
||||
# where
|
||||
#
|
||||
# no-auto: Indicates that firmware-provided I/O configuration data
|
||||
# should not be applied.
|
||||
# should not be applied. This also affects automatic
|
||||
# activation of PCI and crypto devices when running in a DPM
|
||||
# LPAR.
|
||||
#
|
||||
|
||||
PREREQ="udev"
|
||||
@@ -36,6 +38,7 @@ esac
|
||||
|
||||
zdev_fw_file="/sys/firmware/sclp_sd/config/data"
|
||||
zdev_base_args="--force --yes --no-root-update --no-settle --auto-conf --quiet"
|
||||
zdev_id="/lib/s390-tools/zdev_id"
|
||||
|
||||
if [ -e "$zdev_fw_file" ] ; then
|
||||
zdev_auto=1
|
||||
@@ -64,4 +67,22 @@ if [ $zdev_auto -eq 1 ] ; then
|
||||
udevadm trigger --type=subsystems --action=add
|
||||
udevadm trigger --action=add
|
||||
udevadm settle || true
|
||||
|
||||
# Get information about DPM environment
|
||||
for line in $($zdev_id) ; do
|
||||
eval "$line"
|
||||
done
|
||||
|
||||
if [ "$ZDEV_IS_DPM,$ZDEV_NEST_LEVEL,$ZDEV_HYPERVISOR_0" = "1,1,LPAR" ] ; then
|
||||
# Manually iterate over existing PCI devices - there is a udev
|
||||
# rule that handles this for PCI devices added at runtime but
|
||||
# that doesn't work for PCI devices defined before boot because
|
||||
# there is no coldplug trigger for /sys/bus/pci/slots
|
||||
for slot in /sys/bus/pci/slots/* ; do
|
||||
read power < "$slot/power"
|
||||
if [ "$power" = "0" ] ; then
|
||||
echo 1 > "$slot/power"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -73,7 +73,7 @@ lszdev_objects += lcs.o lcs_auto.o
|
||||
# Generic CCW devtype
|
||||
lszdev_objects += generic_ccw.o
|
||||
|
||||
all: chzdev lszdev
|
||||
all: chzdev lszdev zdev_id
|
||||
|
||||
chzdev_usage.c: chzdev_usage.txt
|
||||
$(SED) $< >$@ -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/"/g' \
|
||||
@@ -95,16 +95,17 @@ libs = $(rootdir)/libutil/libutil.a
|
||||
chzdev: $(chzdev_objects) $(libs)
|
||||
lszdev: $(lszdev_objects) $(libs)
|
||||
|
||||
install: chzdev
|
||||
install: chzdev zdev_id
|
||||
$(INSTALL) -d -m 755 $(DESTDIR)$(BINDIR)
|
||||
$(INSTALL) -c chzdev $(DESTDIR)$(BINDIR)
|
||||
$(INSTALL) -c lszdev $(DESTDIR)$(BINDIR)
|
||||
$(INSTALL) -c zdev_id $(DESTDIR)$(TOOLS_LIBDIR)
|
||||
ifeq ($(HAVE_DRACUT),1)
|
||||
$(INSTALL) -m 755 zdev-root-update.dracut \
|
||||
$(DESTDIR)$(TOOLS_LIBDIR)/zdev-root-update
|
||||
endif
|
||||
|
||||
clean:
|
||||
@rm -f *.o chzdev lszdev chzdev_usage.c lszdev_usage.c gmon.out *.gcda *.gcno
|
||||
@rm -f *.o chzdev lszdev chzdev_usage.c lszdev_usage.c gmon.out *.gcda *.gcno zdev_id
|
||||
|
||||
.PHONY: all install clean
|
||||
|
||||
154
zdev/src/zdev_id.c
Normal file
154
zdev/src/zdev_id.c
Normal file
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* zdev_id - Determine system characteristics required by zdev udev rules
|
||||
*
|
||||
* Copyright IBM Corp. 2021
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define SYSINFO "/proc/sysinfo"
|
||||
#define CMDLINE "/proc/cmdline"
|
||||
#define WHITESPACE " \t\n"
|
||||
|
||||
static void array_add(char ***array_p, int *num_p, const char *str)
|
||||
{
|
||||
char **array = *array_p, *copy;
|
||||
int num = *num_p + 1;
|
||||
|
||||
array = realloc(array, num * sizeof(char *));
|
||||
copy = strdup(str);
|
||||
if (!array || !copy)
|
||||
err(1, "Could not allocate memory");
|
||||
array[num - 1] = copy;
|
||||
*array_p = array;
|
||||
*num_p = num;
|
||||
}
|
||||
|
||||
static void array_free(char **array, int num)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
free(array[i]);
|
||||
free(array);
|
||||
}
|
||||
|
||||
static void process_sysinfo(const char *filename)
|
||||
{
|
||||
char *line = NULL, *substr, **cps = NULL;
|
||||
int is_dpm = 0, num_cps = 0, level, i;
|
||||
FILE *fd;
|
||||
size_t n;
|
||||
|
||||
fd = fopen(filename, "r");
|
||||
if (!fd)
|
||||
err(1, "Could not open sysinfo file '%s'", filename);
|
||||
|
||||
while (getline(&line, &n, fd) != -1) {
|
||||
if (sscanf(line, "LPAR %m[^:]", &substr) == 1) {
|
||||
if (strcmp(substr, "UUID") == 0) {
|
||||
/* Heuristic: only DPM LPARs have UUIDs. */
|
||||
is_dpm = 1;
|
||||
} else if (strcmp(substr, "Number") == 0) {
|
||||
array_add(&cps, &num_cps, "LPAR");
|
||||
}
|
||||
free(substr);
|
||||
} else if (sscanf(line, "VM%*d Control Program: %ms ",
|
||||
&substr) == 1) {
|
||||
array_add(&cps, &num_cps, substr);
|
||||
free(substr);
|
||||
}
|
||||
}
|
||||
|
||||
free(line);
|
||||
fclose(fd);
|
||||
|
||||
/*
|
||||
* ZDEV_NEST_LEVEL=n
|
||||
*
|
||||
* Virtualization nesting level of running system:
|
||||
* 1: LPAR
|
||||
* 2: first level VM
|
||||
* 3: second level VM
|
||||
*/
|
||||
printf("ZDEV_NEST_LEVEL=%d\n", num_cps);
|
||||
|
||||
/*
|
||||
* ZDEV_HYPERVISOR_<n>=LPAR|z/VM|KVM/Linux
|
||||
*
|
||||
* Type of hypervisor that provides virtualization at nesting level <n>.
|
||||
*/
|
||||
for (i = 0; i < num_cps; i++) {
|
||||
/* Sysinfo lists VMs in reverse order .*/
|
||||
level = (i == 0) ? i : (num_cps - i);
|
||||
printf("ZDEV_HYPERVISOR_%d=\"%s\"\n", i, cps[level]);
|
||||
}
|
||||
array_free(cps, num_cps);
|
||||
|
||||
/*
|
||||
* ZDEV_IS_DPM=0|1
|
||||
*
|
||||
* Indicator if top-level LPAR is managed by Dynamic Partition
|
||||
* Manager (DPM):
|
||||
* 0: Classic mode
|
||||
* 1: DPM mode
|
||||
*/
|
||||
printf("ZDEV_IS_DPM=%d\n", is_dpm);
|
||||
}
|
||||
|
||||
static void process_cmdline(const char *filename)
|
||||
{
|
||||
char *line = NULL, *substr, *next = NULL, *value;
|
||||
int no_auto = 0;
|
||||
size_t n;
|
||||
FILE *fd;
|
||||
|
||||
fd = fopen(filename, "r");
|
||||
if (!fd)
|
||||
err(1, "Could not open cmdline file '%s'", filename);
|
||||
|
||||
if (getline(&line, &n, fd) == -1)
|
||||
goto out;
|
||||
|
||||
for (substr = strtok_r(line, WHITESPACE, &next); substr;
|
||||
substr = strtok_r(NULL, WHITESPACE, &next)) {
|
||||
if (sscanf(substr, "rd.zdev=%ms ", &value) != 1)
|
||||
continue;
|
||||
if (strstr(value, "no-auto"))
|
||||
no_auto = 1;
|
||||
|
||||
free(value);
|
||||
}
|
||||
|
||||
out:
|
||||
free(line);
|
||||
fclose(fd);
|
||||
|
||||
/*
|
||||
* ZDEV_NO_AUTO=0|1
|
||||
*
|
||||
* Indicator if auto-configuration is requested.
|
||||
* 0: Perform auto-configuration
|
||||
* 1: Skip auto-configuration
|
||||
*/
|
||||
printf("ZDEV_NO_AUTO=%d\n", no_auto);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *sysinfo, *cmdline;
|
||||
|
||||
sysinfo = argc < 2 ? SYSINFO : argv[1];
|
||||
cmdline = argc < 3 ? CMDLINE : argv[2];
|
||||
|
||||
process_sysinfo(sysinfo);
|
||||
process_cmdline(cmdline);
|
||||
|
||||
return 0;
|
||||
}
|
||||
40
zdev/udev/81-dpm.rules
Normal file
40
zdev/udev/81-dpm.rules
Normal file
@@ -0,0 +1,40 @@
|
||||
# Automatically activate certain s390-specific device types that are attached
|
||||
# in offline state when running in an LPAR managed by the Dynamic Partition
|
||||
# Manager (DPM).
|
||||
#
|
||||
# Note that processing is restricted to DPM as there may be use cases for
|
||||
# not enabling these device types in non-DPM mode.
|
||||
#
|
||||
# To deactivate this processing, specify the following on the kernel command
|
||||
# line:
|
||||
#
|
||||
# rd.zdev=no-auto
|
||||
|
||||
ACTION!="add", GOTO="end_dpm"
|
||||
|
||||
# Handle newly added PCI devices in offline state
|
||||
SUBSYSTEM=="slots", ATTR{power}=="0", GOTO="check_dpm"
|
||||
# Handle newly added crypto devices in offline state
|
||||
SUBSYSTEM=="ap", ENV{DEVTYPE}=="ap_card", ATTR{config}=="0", GOTO="check_dpm"
|
||||
|
||||
GOTO="end_dpm"
|
||||
|
||||
LABEL="check_dpm"
|
||||
|
||||
IMPORT{program}="/lib/s390-tools/zdev_id"
|
||||
|
||||
# Check for off-switch
|
||||
ENV{ZDEV_NO_AUTO}=="1", GOTO="end_dpm"
|
||||
|
||||
# Check for DPM LPAR
|
||||
ENV{ZDEV_IS_DPM}!="1", GOTO="end_dpm"
|
||||
ENV{ZDEV_NEST_LEVEL}!="1", GOTO="end_dpm"
|
||||
ENV{ZDEV_HYPERVISOR_0}!="LPAR", GOTO="end_dpm"
|
||||
|
||||
# Enable PCI device
|
||||
SUBSYSTEM=="slots", ATTR{power}="1"
|
||||
# Enable crypto device
|
||||
SUBSYSTEM=="ap", ATTR{config}="1"
|
||||
|
||||
# End of rule
|
||||
LABEL="end_dpm"
|
||||
9
zdev/udev/Makefile
Normal file
9
zdev/udev/Makefile
Normal file
@@ -0,0 +1,9 @@
|
||||
# Common definitions
|
||||
include ../../common.mak
|
||||
|
||||
UDEVDIR := /usr/lib/udev/rules.d/
|
||||
RULES := 81-dpm.rules
|
||||
|
||||
install:
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(UDEVDIR)
|
||||
$(INSTALL) -m 644 $(RULES) $(DESTDIR)$(UDEVDIR)/
|
||||
@@ -1,5 +1,7 @@
|
||||
include ../common.mak
|
||||
|
||||
ALL_CFLAGS += -Wno-address-of-packed-member
|
||||
|
||||
#
|
||||
# HAVE_FUSE: Allow to build zgetdump without mount support
|
||||
#
|
||||
@@ -40,7 +42,7 @@ check_dep_zlib:
|
||||
all: check_dep_fuse check_dep_zlib zgetdump
|
||||
|
||||
OBJECTS = zgetdump.o opts.o zg.o \
|
||||
dfi.o dfi_vmcoreinfo.o \
|
||||
dfi.o dfi_mem_chunk.o dfi_vmcoreinfo.o \
|
||||
dfi_lkcd.o dfi_elf.o \
|
||||
dfi_s390.o dfi_s390_ext.o\
|
||||
dfi_s390mv.o dfi_s390mv_ext.o \
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "zgetdump.h"
|
||||
#include "df_s390.h"
|
||||
|
||||
/*
|
||||
* Check, if we can access the lowcore information in the dump
|
||||
@@ -37,9 +37,10 @@ static int check_addr_max(struct df_s390_hdr *hdr, u64 addr_max)
|
||||
/*
|
||||
* Convert lowcore information into internal CPU representation
|
||||
*/
|
||||
void df_s390_cpu_info_add(struct df_s390_hdr *hdr, u64 addr_max)
|
||||
int df_s390_cpu_info_add(struct df_s390_hdr *hdr, u64 addr_max)
|
||||
{
|
||||
unsigned int i;
|
||||
int rc;
|
||||
|
||||
if (hdr->version < 5 && hdr->magic == DF_S390_MAGIC) {
|
||||
/* No Prefix registers in header */
|
||||
@@ -53,8 +54,13 @@ void df_s390_cpu_info_add(struct df_s390_hdr *hdr, u64 addr_max)
|
||||
dfi_cpu_info_init(DFI_CPU_CONTENT_ALL);
|
||||
}
|
||||
|
||||
for (i = 0; i < hdr->cpu_cnt; i++)
|
||||
dfi_cpu_add_from_lc(hdr->lc_vec[i]);
|
||||
for (i = 0; i < hdr->cpu_cnt; i++) {
|
||||
rc = dfi_cpu_add_from_lc(hdr->lc_vec[i]);
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -127,7 +127,7 @@ struct df_s390_dumper {
|
||||
*/
|
||||
extern void df_s390_hdr_add(struct df_s390_hdr *hdr);
|
||||
extern void df_s390_em_add(struct df_s390_em *em);
|
||||
extern void df_s390_cpu_info_add(struct df_s390_hdr *hdr, u64 addr_max);
|
||||
extern int df_s390_cpu_info_add(struct df_s390_hdr *hdr, u64 addr_max);
|
||||
extern int df_s390_em_verify(struct df_s390_em *em, struct df_s390_hdr *hdr);
|
||||
extern void df_s390_dumper_read(struct zg_fh *fh, int32_t blk_size,
|
||||
struct df_s390_dumper *dumper);
|
||||
|
||||
550
zdump/dfi.c
550
zdump/dfi.c
@@ -9,12 +9,19 @@
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
#include "lib/util_log.h"
|
||||
|
||||
#include "zgetdump.h"
|
||||
#include "dfi_mem_chunk.h"
|
||||
#include "dfi_vmcoreinfo.h"
|
||||
#include "dfi.h"
|
||||
|
||||
#define TIME_FMT_STR "%a, %d %b %Y %H:%M:%S %z"
|
||||
#define PROGRESS_HASH_CNT 50
|
||||
|
||||
#define KDUMP_OLDMEM_BASE 0x10418
|
||||
#define KDUMP_OLDMEM_SIZE 0x10420
|
||||
|
||||
/*
|
||||
* DFI vector - ensure that tape is the first in the list and devmem the second!
|
||||
*/
|
||||
@@ -47,17 +54,6 @@ struct cpus {
|
||||
unsigned int cnt;
|
||||
};
|
||||
|
||||
/*
|
||||
* Memory information
|
||||
*/
|
||||
struct mem {
|
||||
struct dfi_mem_chunk *chunk_cache;
|
||||
u64 start_addr;
|
||||
u64 end_addr;
|
||||
unsigned int chunk_cnt;
|
||||
struct util_list chunk_list;
|
||||
};
|
||||
|
||||
/*
|
||||
* Dump header attribute information
|
||||
*/
|
||||
@@ -81,8 +77,6 @@ struct attr {
|
||||
static struct {
|
||||
enum dfi_arch arch;
|
||||
struct attr attr;
|
||||
struct mem mem_phys;
|
||||
struct mem mem_virt;
|
||||
struct cpus cpus;
|
||||
struct dfi *dfi;
|
||||
unsigned long kdump_base;
|
||||
@@ -109,125 +103,6 @@ static void date_print(void)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize DFI memory chunks
|
||||
*/
|
||||
static void mem_init(struct mem *mem)
|
||||
{
|
||||
mem->start_addr = U64_MAX;
|
||||
mem->end_addr = 0;
|
||||
util_list_init(&mem->chunk_list, struct dfi_mem_chunk, list);
|
||||
}
|
||||
|
||||
/*
|
||||
* Memory chunk compare function for list sorting
|
||||
*/
|
||||
static int mem_chunk_cmp_fn(void *a, void *b, void *UNUSED(data))
|
||||
{
|
||||
struct dfi_mem_chunk *mem_chunk1 = a;
|
||||
struct dfi_mem_chunk *mem_chunk2 = b;
|
||||
|
||||
return mem_chunk1->start < mem_chunk2->start ? -1 : 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Update DFI memory chunks
|
||||
*/
|
||||
static void mem_update(struct mem *mem)
|
||||
{
|
||||
struct dfi_mem_chunk *mem_chunk;
|
||||
|
||||
util_list_sort(&mem->chunk_list, mem_chunk_cmp_fn, NULL);
|
||||
mem->start_addr = U64_MAX;
|
||||
mem->end_addr = 0;
|
||||
util_list_iterate(&mem->chunk_list, mem_chunk) {
|
||||
mem->start_addr = MIN(mem->start_addr, mem_chunk->start);
|
||||
mem->end_addr = MAX(mem->end_addr, mem_chunk->end);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Print memory map
|
||||
*/
|
||||
static void mem_map_print(void)
|
||||
{
|
||||
struct dfi_mem_chunk *mem_chunk;
|
||||
u64 print_start = 0, print_end = 0;
|
||||
const char *zero_str;
|
||||
u32 volnr = 0;
|
||||
|
||||
STDERR("\nMemory map:\n");
|
||||
/*
|
||||
* Print each memory chunk if verbose specified
|
||||
*/
|
||||
if (g.opts.verbose_specified) {
|
||||
dfi_mem_chunk_iterate(mem_chunk) {
|
||||
zero_str = "";
|
||||
if (mem_chunk->read_fn == dfi_mem_chunk_read_zero)
|
||||
zero_str = " zeroes";
|
||||
STDERR(" %016llx - %016llx (%llu MB%s)\n",
|
||||
mem_chunk->start, mem_chunk->end,
|
||||
TO_MIB(mem_chunk->size), zero_str);
|
||||
}
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* Merge adjacent memory chunks from the same volume
|
||||
*/
|
||||
dfi_mem_chunk_iterate(mem_chunk) {
|
||||
if (print_end == 0) {
|
||||
print_start = mem_chunk->start;
|
||||
print_end = mem_chunk->end;
|
||||
volnr = mem_chunk->volnr;
|
||||
continue;
|
||||
}
|
||||
if (mem_chunk->start != print_end + 1 ||
|
||||
mem_chunk->volnr != volnr) {
|
||||
STDERR(" %016llx - %016llx (%llu MB)\n", print_start,
|
||||
print_end, TO_MIB(print_end - print_start + 1));
|
||||
print_start = mem_chunk->start;
|
||||
volnr = mem_chunk->volnr;
|
||||
}
|
||||
print_end = mem_chunk->end;
|
||||
}
|
||||
STDERR(" %016llx - %016llx (%llu MB)\n", print_start,
|
||||
print_end, TO_MIB(print_end - print_start + 1));
|
||||
}
|
||||
|
||||
/*
|
||||
* Is memory range valid?
|
||||
*/
|
||||
int dfi_mem_range_valid(u64 addr, u64 len)
|
||||
{
|
||||
struct dfi_mem_chunk *mem_chunk;
|
||||
u64 addr_end = addr + len;
|
||||
|
||||
do {
|
||||
mem_chunk = dfi_mem_chunk_find(addr);
|
||||
if (!mem_chunk)
|
||||
return 0;
|
||||
addr += MIN(len, mem_chunk->end - addr + 1);
|
||||
} while (addr < addr_end);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Is memory already mapped at range?
|
||||
*/
|
||||
static int mem_range_mapped(u64 start, u64 size)
|
||||
{
|
||||
struct dfi_mem_chunk *mem_chunk;
|
||||
u64 end = start + size - 1;
|
||||
|
||||
dfi_mem_chunk_iterate(mem_chunk) {
|
||||
if (mem_chunk->start > end)
|
||||
continue;
|
||||
if (mem_chunk->end < start)
|
||||
continue;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Print dump information (--info option)
|
||||
*/
|
||||
@@ -236,7 +111,7 @@ void dfi_info_print(void)
|
||||
STDERR("General dump info:\n");
|
||||
STDERR(" Dump format........: %s\n", l.dfi->name);
|
||||
if (l.attr.dfi_version)
|
||||
STDERR(" Version............: %d\n", *l.attr.dfi_version);
|
||||
STDERR(" Version............: %u\n", *l.attr.dfi_version);
|
||||
date_print();
|
||||
if (l.attr.dump_method)
|
||||
STDERR(" Dump method........: %s\n", l.attr.dump_method);
|
||||
@@ -248,259 +123,32 @@ void dfi_info_print(void)
|
||||
STDERR(" UTS kernel version.: %s\n", l.attr.utsname->version);
|
||||
}
|
||||
if (l.attr.vol_nr)
|
||||
STDERR(" Volume number......: %d\n", *l.attr.vol_nr);
|
||||
STDERR(" Volume number......: %u\n", *l.attr.vol_nr);
|
||||
if (l.attr.build_arch)
|
||||
STDERR(" Build arch.........: %s\n",
|
||||
dfi_arch_str(*l.attr.build_arch));
|
||||
dfi_arch_str(*l.attr.build_arch));
|
||||
STDERR(" System arch........: %s\n", dfi_arch_str(l.arch));
|
||||
if (l.cpus.cnt)
|
||||
STDERR(" CPU count (online).: %d\n", l.cpus.cnt);
|
||||
STDERR(" CPU count (online).: %u\n", l.cpus.cnt);
|
||||
if (l.attr.real_cpu_cnt)
|
||||
STDERR(" CPU count (real)...: %d\n", *l.attr.real_cpu_cnt);
|
||||
STDERR(" CPU count (real)...: %u\n", *l.attr.real_cpu_cnt);
|
||||
if (dfi_mem_range())
|
||||
STDERR(" Dump memory range..: %lld MB\n",
|
||||
TO_MIB(dfi_mem_range()));
|
||||
if (l.attr.mem_size_real)
|
||||
STDERR(" Real memory range..: %lld MB\n",
|
||||
TO_MIB(*l.attr.mem_size_real));
|
||||
TO_MIB(*l.attr.mem_size_real));
|
||||
if (l.attr.file_size)
|
||||
STDERR(" Dump file size.....: %lld MB\n",
|
||||
TO_MIB(*l.attr.file_size));
|
||||
TO_MIB(*l.attr.file_size));
|
||||
if (dfi_mem_range())
|
||||
mem_map_print();
|
||||
dfi_mem_map_print(g.opts.verbose);
|
||||
if (l.dfi->info_dump) {
|
||||
STDERR("\nDump device info:\n");
|
||||
l.dfi->info_dump();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Add memory chunk to memory
|
||||
*/
|
||||
static void mem_chunk_create(struct mem *mem, u64 start, u64 size, void *data,
|
||||
dfi_mem_chunk_read_fn read_fn,
|
||||
dfi_mem_chunk_free_fn free_fn)
|
||||
{
|
||||
struct dfi_mem_chunk *mem_chunk;
|
||||
|
||||
mem_chunk = zg_alloc(sizeof(*mem_chunk));
|
||||
mem_chunk->start = start;
|
||||
mem_chunk->end = start + size - 1;
|
||||
mem_chunk->size = size;
|
||||
mem_chunk->read_fn = read_fn;
|
||||
mem_chunk->free_fn = free_fn;
|
||||
mem_chunk->data = data;
|
||||
|
||||
util_list_add_tail(&mem->chunk_list, mem_chunk);
|
||||
mem->start_addr = MIN(mem->start_addr, mem_chunk->start);
|
||||
mem->end_addr = MAX(mem->end_addr, mem_chunk->end);
|
||||
mem->chunk_cache = mem_chunk;
|
||||
mem->chunk_cnt++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if memory chunk contains address
|
||||
*/
|
||||
static int mem_chunk_has_addr(struct dfi_mem_chunk *mem_chunk, u64 addr)
|
||||
{
|
||||
return (addr >= mem_chunk->start && addr <= mem_chunk->end);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find memory chunk that contains address
|
||||
*/
|
||||
static struct dfi_mem_chunk *mem_chunk_find(struct mem *mem, u64 addr)
|
||||
{
|
||||
struct dfi_mem_chunk *mem_chunk;
|
||||
|
||||
if (mem_chunk_has_addr(mem->chunk_cache, addr))
|
||||
return mem->chunk_cache;
|
||||
util_list_iterate(&mem->chunk_list, mem_chunk) {
|
||||
if (mem_chunk_has_addr(mem_chunk, addr)) {
|
||||
mem->chunk_cache = mem_chunk;
|
||||
return mem_chunk;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read memory at given address
|
||||
*/
|
||||
static void mem_read(struct mem *mem, u64 addr, void *buf, size_t cnt)
|
||||
{
|
||||
struct dfi_mem_chunk *mem_chunk;
|
||||
u64 size, off, copied = 0;
|
||||
|
||||
while (copied != cnt) {
|
||||
mem_chunk = mem_chunk_find(mem, addr);
|
||||
size = MIN(cnt - copied, mem_chunk->end - addr + 1);
|
||||
off = addr - mem_chunk->start;
|
||||
mem_chunk->read_fn(mem_chunk, off, buf + copied, size);
|
||||
copied += size;
|
||||
addr += size;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Read memory for virtual map memory chunk
|
||||
*/
|
||||
static void mem_chunk_map_read_fn(struct dfi_mem_chunk *mem_chunk, u64 off,
|
||||
void *buf, u64 cnt)
|
||||
{
|
||||
u64 *start = mem_chunk->data;
|
||||
|
||||
dfi_mem_phys_read(*start + off, buf, cnt);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if memory chunk is a virtual mapping
|
||||
*/
|
||||
static int mem_chunk_is_map(struct dfi_mem_chunk *mem_chunk)
|
||||
{
|
||||
return mem_chunk->read_fn == mem_chunk_map_read_fn;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return physical start address for memory chunk
|
||||
*/
|
||||
static u64 mem_chunk_start_phys(struct dfi_mem_chunk *mem_chunk)
|
||||
{
|
||||
if (mem_chunk_is_map(mem_chunk))
|
||||
return *((u64 *) mem_chunk->data);
|
||||
else
|
||||
return mem_chunk->start;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add virtual memory chunk with simple virtual mapping
|
||||
*/
|
||||
static void mem_chunk_map_add(u64 start, u64 size, u64 start_p)
|
||||
{
|
||||
u64 *data = zg_alloc(sizeof(*data));
|
||||
|
||||
*data = start_p;
|
||||
dfi_mem_chunk_virt_add(start, size, data, mem_chunk_map_read_fn,
|
||||
zg_free);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add virtual memory chunk
|
||||
*/
|
||||
void dfi_mem_chunk_virt_add(u64 start, u64 size, void *data,
|
||||
dfi_mem_chunk_read_fn read_fn,
|
||||
dfi_mem_chunk_free_fn free_fn)
|
||||
{
|
||||
if (size == 0)
|
||||
return;
|
||||
mem_chunk_create(&l.mem_virt, start, size, data, read_fn, free_fn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add memory chunk with volume index
|
||||
*/
|
||||
void dfi_mem_chunk_add_vol(u64 start, u64 size, void *data,
|
||||
dfi_mem_chunk_read_fn read_fn,
|
||||
dfi_mem_chunk_free_fn free_fn,
|
||||
u32 volnr)
|
||||
{
|
||||
if (size == 0)
|
||||
return;
|
||||
mem_chunk_create(&l.mem_phys, start, size, data, read_fn, free_fn);
|
||||
mem_chunk_create(&l.mem_virt, start, size, data, read_fn, NULL);
|
||||
l.mem_virt.chunk_cache->volnr = volnr;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Add memory chunk
|
||||
*/
|
||||
void dfi_mem_chunk_add(u64 start, u64 size, void *data,
|
||||
dfi_mem_chunk_read_fn read_fn,
|
||||
dfi_mem_chunk_free_fn free_fn)
|
||||
{
|
||||
dfi_mem_chunk_add_vol(start, size, data, read_fn, free_fn, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read zero pages
|
||||
*/
|
||||
void dfi_mem_chunk_read_zero(struct dfi_mem_chunk *UNUSED(mem_chunk),
|
||||
u64 UNUSED(off), void *buf, u64 cnt)
|
||||
{
|
||||
memset(buf, 0, cnt);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return mem_chunk list head
|
||||
*/
|
||||
struct util_list *dfi_mem_chunk_list(void)
|
||||
{
|
||||
return &l.mem_virt.chunk_list;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return number of memory chunks in input dump
|
||||
*/
|
||||
unsigned int dfi_mem_chunk_cnt(void)
|
||||
{
|
||||
return l.mem_virt.chunk_cnt;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return maximum memory range
|
||||
*/
|
||||
u64 dfi_mem_range(void)
|
||||
{
|
||||
if (l.mem_virt.start_addr == U64_MAX)
|
||||
return 0;
|
||||
return l.mem_virt.end_addr - l.mem_virt.start_addr + 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return first memory chunk
|
||||
*/
|
||||
struct dfi_mem_chunk *dfi_mem_chunk_first(void)
|
||||
{
|
||||
if (util_list_is_empty(&l.mem_virt.chunk_list))
|
||||
return NULL;
|
||||
return util_list_start(&l.mem_virt.chunk_list);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return last memory chunk
|
||||
*/
|
||||
struct dfi_mem_chunk *dfi_mem_chunk_last(void)
|
||||
{
|
||||
if (util_list_is_empty(&l.mem_virt.chunk_list))
|
||||
return NULL;
|
||||
return util_list_end(&l.mem_virt.chunk_list);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return next memory chunk
|
||||
*/
|
||||
struct dfi_mem_chunk *dfi_mem_chunk_next(struct dfi_mem_chunk *mem_chunk)
|
||||
{
|
||||
return util_list_next(&l.mem_virt.chunk_list, mem_chunk);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return previous memory chunk
|
||||
*/
|
||||
struct dfi_mem_chunk *dfi_mem_chunk_prev(struct dfi_mem_chunk *mem_chunk)
|
||||
{
|
||||
return util_list_prev(&l.mem_virt.chunk_list, mem_chunk);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find memory chunk for given address
|
||||
*/
|
||||
struct dfi_mem_chunk *dfi_mem_chunk_find(u64 addr)
|
||||
{
|
||||
return mem_chunk_find(&l.mem_virt, addr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize CPU info
|
||||
*/
|
||||
@@ -600,33 +248,6 @@ struct util_list *dfi_cpu_list(void)
|
||||
return &l.cpus.list;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read memory at given address and do kdump swap if necessary
|
||||
*/
|
||||
void dfi_mem_read(u64 addr, void *buf, size_t cnt)
|
||||
{
|
||||
mem_read(&l.mem_virt, addr, buf, cnt);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read physical memory at given address
|
||||
*/
|
||||
void dfi_mem_phys_read(u64 addr, void *buf, size_t cnt)
|
||||
{
|
||||
mem_read(&l.mem_phys, addr, buf, cnt);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read memory at given address with return code
|
||||
*/
|
||||
int dfi_mem_read_rc(u64 addr, void *buf, size_t cnt)
|
||||
{
|
||||
if (!dfi_mem_range_valid(addr, cnt))
|
||||
return -EINVAL;
|
||||
dfi_mem_read(addr, buf, cnt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get input dump format name
|
||||
*/
|
||||
@@ -886,7 +507,7 @@ static void lc2cpu_64(struct dfi_cpu *cpu, struct dfi_lowcore_64 *lc)
|
||||
/* Add VX registers if available */
|
||||
if (!dfi_cpu_lc_has_vx_sa(lc))
|
||||
return;
|
||||
if (dfi_mem_read_rc(lc->vector_save_area_addr, &vx_sa, sizeof(vx_sa))) {
|
||||
if (dfi_mem_virt_read(lc->vector_save_area_addr, &vx_sa, sizeof(vx_sa))) {
|
||||
STDERR("zgetdump: Vector registers save area is beyond dump memory limit for CPU %d\n", cpu->cpu_id);
|
||||
return;
|
||||
}
|
||||
@@ -917,7 +538,7 @@ static void lc2cpu_32(struct dfi_cpu_32 *cpu, struct dfi_lowcore_32 *lc)
|
||||
* Note: When this function is called, the memory chunks have to be already
|
||||
* defined by the DFI dump specific code.
|
||||
*/
|
||||
void dfi_cpu_add_from_lc(u32 lc_addr)
|
||||
int dfi_cpu_add_from_lc(u32 lc_addr)
|
||||
{
|
||||
struct dfi_cpu *cpu = dfi_cpu_alloc();
|
||||
|
||||
@@ -930,12 +551,14 @@ void dfi_cpu_add_from_lc(u32 lc_addr)
|
||||
if (l.arch == DFI_ARCH_32) {
|
||||
struct dfi_cpu_32 cpu_32;
|
||||
struct dfi_lowcore_32 lc;
|
||||
dfi_mem_read(lc_addr, &lc, sizeof(lc));
|
||||
if (dfi_mem_virt_read(lc_addr, &lc, sizeof(lc)))
|
||||
return -EINVAL;
|
||||
lc2cpu_32(&cpu_32, &lc);
|
||||
cpu_32_to_64(cpu, &cpu_32);
|
||||
} else {
|
||||
struct dfi_lowcore_64 lc;
|
||||
dfi_mem_read(lc_addr, &lc, sizeof(lc));
|
||||
if (dfi_mem_virt_read(lc_addr, &lc, sizeof(lc)))
|
||||
return -EINVAL;
|
||||
lc2cpu_64(cpu, &lc);
|
||||
}
|
||||
break;
|
||||
@@ -943,6 +566,7 @@ void dfi_cpu_add_from_lc(u32 lc_addr)
|
||||
ABORT("dfi_cpu_add_from_lc() called for CONTENT_NONE");
|
||||
}
|
||||
dfi_cpu_add(cpu);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -984,89 +608,6 @@ unsigned long dfi_kdump_base(void)
|
||||
return l.kdump_base;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unmap memory region
|
||||
*/
|
||||
static void mem_unmap(u64 start, u64 size)
|
||||
{
|
||||
u64 start_phys, end_phys, addr_phys, addr_virt, size_virt;
|
||||
struct dfi_mem_chunk *mem_chunk, *tmp;
|
||||
u64 end = start + size - 1;
|
||||
|
||||
util_list_iterate_safe(&l.mem_virt.chunk_list, mem_chunk, tmp) {
|
||||
/*
|
||||
* Chunk not hit?
|
||||
*/
|
||||
if (mem_chunk->start >= start + size)
|
||||
continue;
|
||||
if (mem_chunk->end < start)
|
||||
continue;
|
||||
/*
|
||||
* Chunk completely unmapped
|
||||
*
|
||||
* UNMAP: UUUUUUUUU || UUUUUU
|
||||
* CHUNK: CCCC || CCCCCC
|
||||
* TO:
|
||||
*/
|
||||
if (mem_chunk->start >= start && mem_chunk->end <= end)
|
||||
goto free;
|
||||
|
||||
/*
|
||||
* Get real start and end addresses
|
||||
*/
|
||||
start_phys = mem_chunk_start_phys(mem_chunk);
|
||||
end_phys = start_phys + mem_chunk->size - 1;
|
||||
|
||||
/*
|
||||
* Chunk hit at start or in the middle?
|
||||
*
|
||||
* UNMAP: UUUUUU || UU || UUU
|
||||
* CHUNK: CCCCC || CCCCCC || CCCC
|
||||
* TO: NN || NN || NNN
|
||||
*/
|
||||
if (mem_chunk->end > end) {
|
||||
addr_virt = end + 1;
|
||||
size_virt = mem_chunk->end - end;
|
||||
addr_phys = end_phys - size_virt + 1;
|
||||
mem_chunk_map_add(addr_virt, size_virt, addr_phys);
|
||||
}
|
||||
/*
|
||||
* Chunk hit at end or in the middle?
|
||||
*
|
||||
* UNMAP: UUUUUU || UU || UUU
|
||||
* CHUNK: CCCCC || CCCCCC || CCC
|
||||
* TO: NN || NN || NN
|
||||
*/
|
||||
if (mem_chunk->start < start) {
|
||||
addr_virt = mem_chunk->start;
|
||||
size_virt = start - addr_virt;
|
||||
addr_phys = start_phys;
|
||||
mem_chunk_map_add(addr_virt, size_virt, addr_phys);
|
||||
}
|
||||
free:
|
||||
util_list_remove(&l.mem_virt.chunk_list, mem_chunk);
|
||||
l.mem_virt.chunk_cnt--;
|
||||
if (mem_chunk->data && mem_chunk->free_fn)
|
||||
mem_chunk->free_fn(mem_chunk->data);
|
||||
zg_free(mem_chunk);
|
||||
}
|
||||
mem_update(&l.mem_virt);
|
||||
}
|
||||
|
||||
/*
|
||||
* Map memory region
|
||||
*/
|
||||
static void mem_map(u64 start, u64 size, u64 start_phys)
|
||||
{
|
||||
if (mem_range_mapped(start, size)) {
|
||||
mem_map_print();
|
||||
ABORT("Map request for already mapped region (%llx/%llx/%llx)",
|
||||
start, size, start_phys);
|
||||
}
|
||||
mem_chunk_map_add(start, size, start_phys);
|
||||
mem_update(&l.mem_virt);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if dump contains a kdump dump and initialize kdump_base and kdump_size
|
||||
*/
|
||||
@@ -1074,8 +615,12 @@ static void kdump_init(void)
|
||||
{
|
||||
unsigned long base, size;
|
||||
|
||||
dfi_mem_phys_read(0x10418, &base, sizeof(base));
|
||||
dfi_mem_phys_read(0x10420, &size, sizeof(size));
|
||||
util_log_print(UTIL_LOG_TRACE, "DFI kdump initialization\n");
|
||||
|
||||
if (dfi_mem_phys_read(KDUMP_OLDMEM_BASE, &base, sizeof(base)))
|
||||
return;
|
||||
if (dfi_mem_phys_read(KDUMP_OLDMEM_SIZE, &size, sizeof(size)))
|
||||
return;
|
||||
if (base == 0 || size == 0)
|
||||
return;
|
||||
if (base % MIB || size % MIB)
|
||||
@@ -1084,6 +629,9 @@ static void kdump_init(void)
|
||||
return;
|
||||
l.kdump_base = base;
|
||||
l.kdump_size = size;
|
||||
util_log_print(UTIL_LOG_INFO,
|
||||
"DFI found valid kdump base 0x%016lx size 0x%016lx\n",
|
||||
l.kdump_base, l.kdump_size);
|
||||
/*
|
||||
* For dumped kdump and user has selected "prod" we swap
|
||||
* the crashkernel memory with old memory. If user selected "kdump",
|
||||
@@ -1093,11 +641,11 @@ static void kdump_init(void)
|
||||
if (!g.opts.select_specified)
|
||||
return;
|
||||
if (g.opts.select == OPTS_SELECT_PROD) {
|
||||
mem_unmap(0, size);
|
||||
mem_unmap(base, size);
|
||||
mem_map(0, size, base);
|
||||
dfi_mem_unmap(0, size);
|
||||
dfi_mem_unmap(base, size);
|
||||
dfi_mem_map(0, size, base);
|
||||
} else if (g.opts.select == OPTS_SELECT_KDUMP) {
|
||||
mem_unmap(l.kdump_size, U64_MAX - l.kdump_size);
|
||||
dfi_mem_unmap(l.kdump_size, U64_MAX - l.kdump_size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1126,8 +674,8 @@ static void kdump_select_prod_init(void)
|
||||
}
|
||||
dfi_cpu_info_init(DFI_CPU_CONTENT_ALL);
|
||||
for (i = 0; i < count; i++) {
|
||||
if (dfi_mem_read_rc(ptr + i * sizeof(long), &prefix,
|
||||
sizeof(prefix)))
|
||||
if (dfi_mem_virt_read(ptr + i * sizeof(long), &prefix,
|
||||
sizeof(prefix)))
|
||||
continue;
|
||||
if (prefix == 0)
|
||||
continue;
|
||||
@@ -1146,9 +694,11 @@ static void utsname_init(void)
|
||||
unsigned long ptr;
|
||||
char buf[1024];
|
||||
|
||||
util_log_print(UTIL_LOG_TRACE, "DFI utsname initialization\n");
|
||||
|
||||
if (dfi_vmcoreinfo_symbol(&ptr, "init_uts_ns"))
|
||||
return;
|
||||
if (dfi_mem_read_rc(ptr, buf, sizeof(buf)))
|
||||
if (dfi_mem_virt_read(ptr, buf, sizeof(buf)))
|
||||
return;
|
||||
utsname = memchr(buf, 'L', sizeof(buf) - sizeof(*utsname));
|
||||
if (!utsname)
|
||||
@@ -1156,6 +706,8 @@ static void utsname_init(void)
|
||||
if (strncmp(utsname->sysname, "Linux", sizeof(utsname->version)) != 0)
|
||||
return;
|
||||
dfi_attr_utsname_set(utsname);
|
||||
util_log_print(UTIL_LOG_INFO, "DFI utsname release %s version %s\n",
|
||||
utsname->release, utsname->version);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1165,7 +717,9 @@ static void livedump_init(void)
|
||||
{
|
||||
u64 magic;
|
||||
|
||||
if (dfi_mem_read_rc(0, &magic, sizeof(magic)))
|
||||
util_log_print(UTIL_LOG_TRACE, "DFI livedump initialization\n");
|
||||
|
||||
if (dfi_mem_virt_read(0, &magic, sizeof(magic)))
|
||||
return;
|
||||
if (magic == dfi_live_dump_magic)
|
||||
dfi_attr_dump_method_set(DFI_DUMP_METHOD_LIVE);
|
||||
@@ -1201,12 +755,16 @@ int dfi_init(void)
|
||||
struct dfi *dfi;
|
||||
int i = 0, rc;
|
||||
|
||||
util_log_print(UTIL_LOG_TRACE, "DFI initialization\n");
|
||||
|
||||
l.arch = DFI_ARCH_UNKNOWN;
|
||||
mem_init(&l.mem_virt);
|
||||
mem_init(&l.mem_phys);
|
||||
rc = dfi_mem_chunk_init();
|
||||
if (rc)
|
||||
return rc;
|
||||
attr_init();
|
||||
dfi_cpu_info_init(DFI_CPU_CONTENT_NONE);
|
||||
while ((dfi = dfi_vec[i])) {
|
||||
util_log_print(UTIL_LOG_DEBUG, "DFI trying %s\n", dfi->name);
|
||||
l.dfi = dfi;
|
||||
g.fh = dfi_dump_open(g.opts.device);
|
||||
rc = dfi->init();
|
||||
@@ -1218,6 +776,8 @@ int dfi_init(void)
|
||||
utsname_init();
|
||||
livedump_init();
|
||||
}
|
||||
util_log_print(UTIL_LOG_DEBUG, "DFI %s returned with rc %d\n",
|
||||
dfi->name, rc);
|
||||
if (rc == 0 || rc == -EINVAL)
|
||||
return rc;
|
||||
zg_close(g.fh);
|
||||
@@ -1231,6 +791,8 @@ int dfi_init(void)
|
||||
*/
|
||||
void dfi_exit(void)
|
||||
{
|
||||
util_log_print(UTIL_LOG_TRACE, "DFI exit\n");
|
||||
|
||||
if (l.dfi && l.dfi->exit)
|
||||
l.dfi->exit();
|
||||
}
|
||||
|
||||
172
zdump/dfi.h
172
zdump/dfi.h
@@ -12,13 +12,12 @@
|
||||
#ifndef DFI_H
|
||||
#define DFI_H
|
||||
|
||||
#include <time.h>
|
||||
#include <linux/utsname.h>
|
||||
|
||||
#include "lib/zt_common.h"
|
||||
#include "lib/util_list.h"
|
||||
|
||||
#include "zg.h"
|
||||
|
||||
/*
|
||||
* CPU info functions and definitions
|
||||
*/
|
||||
@@ -116,11 +115,11 @@ struct dfi_cpu_32 {
|
||||
struct dfi_vxrs vxrs_high[16];
|
||||
};
|
||||
|
||||
extern void dfi_cpu_64_to_32(struct dfi_cpu_32 *cpu_32, struct dfi_cpu *cpu_64);
|
||||
void dfi_cpu_64_to_32(struct dfi_cpu_32 *cpu_32, struct dfi_cpu *cpu_64);
|
||||
|
||||
extern enum dfi_arch dfi_arch(void);
|
||||
extern void dfi_arch_set(enum dfi_arch arch);
|
||||
extern const char *dfi_arch_str(enum dfi_arch arch);
|
||||
enum dfi_arch dfi_arch(void);
|
||||
void dfi_arch_set(enum dfi_arch arch);
|
||||
const char *dfi_arch_str(enum dfi_arch arch);
|
||||
|
||||
enum dfi_cpu_content {
|
||||
DFI_CPU_CONTENT_NONE, /* No register information available */
|
||||
@@ -129,113 +128,62 @@ enum dfi_cpu_content {
|
||||
};
|
||||
|
||||
#define DFI_CPU_CONTENT_FAC_VX 0x00000001
|
||||
extern int dfi_cpu_content_fac_check(int flags);
|
||||
extern void dfi_cpu_content_fac_add(int flags);
|
||||
int dfi_cpu_content_fac_check(int flags);
|
||||
void dfi_cpu_content_fac_add(int flags);
|
||||
|
||||
#define dfi_cpu_iterate(cpu) \
|
||||
util_list_iterate(dfi_cpu_list(), cpu)
|
||||
|
||||
extern struct util_list *dfi_cpu_list(void);
|
||||
extern void dfi_cpu_info_init(enum dfi_cpu_content content);
|
||||
extern struct dfi_cpu *dfi_cpu_alloc(void);
|
||||
extern struct dfi_cpu *dfi_cpu(unsigned int cpu_nr);
|
||||
extern void dfi_cpu_add(struct dfi_cpu *cpu);
|
||||
extern unsigned int dfi_cpu_cnt(void);
|
||||
extern enum dfi_cpu_content dfi_cpu_content(void);
|
||||
extern void dfi_cpu_add_from_lc(u32 lc_addr);
|
||||
struct util_list *dfi_cpu_list(void);
|
||||
void dfi_cpu_info_init(enum dfi_cpu_content content);
|
||||
struct dfi_cpu *dfi_cpu_alloc(void);
|
||||
struct dfi_cpu *dfi_cpu(unsigned int cpu_nr);
|
||||
void dfi_cpu_add(struct dfi_cpu *cpu);
|
||||
unsigned int dfi_cpu_cnt(void);
|
||||
enum dfi_cpu_content dfi_cpu_content(void);
|
||||
int dfi_cpu_add_from_lc(u32 lc_addr);
|
||||
|
||||
#define DFI_VX_SA_SIZE (32 * 16)
|
||||
extern int dfi_cpu_lc_has_vx_sa(void *lc);
|
||||
extern void dfi_cpu_vx_copy(void *buf, struct dfi_cpu *cpu);
|
||||
|
||||
/*
|
||||
* Mem chunk functions and definitions
|
||||
*/
|
||||
struct dfi_mem_chunk;
|
||||
|
||||
typedef void (*dfi_mem_chunk_read_fn)(struct dfi_mem_chunk *mem_chunk,
|
||||
u64 off, void *buf, u64 cnt);
|
||||
typedef void (*dfi_mem_chunk_free_fn)(void *data);
|
||||
|
||||
struct dfi_mem_chunk {
|
||||
struct util_list_node list; /* List */
|
||||
u64 start; /* Start address in memory */
|
||||
u64 end; /* End address in memory */
|
||||
u64 size; /* Size of chunk in dump file */
|
||||
dfi_mem_chunk_read_fn read_fn; /* Chunk read callback */
|
||||
dfi_mem_chunk_free_fn free_fn; /* Free data callback */
|
||||
void *data; /* Data for callback */
|
||||
u32 volnr; /* Volume id where chunk resides */
|
||||
};
|
||||
|
||||
extern void dfi_mem_chunk_read_zero(struct dfi_mem_chunk *UNUSED(mem_chunk),
|
||||
u64 UNUSED(off), void *buf, u64 cnt);
|
||||
extern void dfi_mem_chunk_add_vol(u64 start, u64 size, void *data,
|
||||
dfi_mem_chunk_read_fn read_fn,
|
||||
dfi_mem_chunk_free_fn free_fn,
|
||||
u32 volnr);
|
||||
extern void dfi_mem_chunk_add(u64 start, u64 size, void *data,
|
||||
dfi_mem_chunk_read_fn read_fn,
|
||||
dfi_mem_chunk_free_fn free_fn);
|
||||
extern void dfi_mem_chunk_virt_add(u64 start, u64 size, void *data,
|
||||
dfi_mem_chunk_read_fn read_fn,
|
||||
dfi_mem_chunk_free_fn free_fn);
|
||||
extern u64 dfi_mem_range(void);
|
||||
extern int dfi_mem_range_valid(u64 addr, u64 len);
|
||||
extern unsigned int dfi_mem_chunk_cnt(void);
|
||||
extern struct dfi_mem_chunk *dfi_mem_chunk_first(void);
|
||||
extern struct dfi_mem_chunk *dfi_mem_chunk_last(void);
|
||||
extern struct dfi_mem_chunk *dfi_mem_chunk_next(struct dfi_mem_chunk *chunk);
|
||||
extern struct dfi_mem_chunk *dfi_mem_chunk_prev(struct dfi_mem_chunk *chunk);
|
||||
extern struct dfi_mem_chunk *dfi_mem_chunk_find(u64 addr);
|
||||
|
||||
extern struct util_list *dfi_mem_chunk_list(void);
|
||||
#define dfi_mem_chunk_iterate(mem_chunk) \
|
||||
util_list_iterate(dfi_mem_chunk_list(), mem_chunk)
|
||||
int dfi_cpu_lc_has_vx_sa(void *lc);
|
||||
void dfi_cpu_vx_copy(void *buf, struct dfi_cpu *cpu);
|
||||
|
||||
/*
|
||||
* Dump header attribute set/get functions
|
||||
*/
|
||||
extern void dfi_attr_time_set(struct timeval *time);
|
||||
extern struct timeval *dfi_attr_time(void);
|
||||
void dfi_attr_time_set(struct timeval *time);
|
||||
struct timeval *dfi_attr_time(void);
|
||||
|
||||
extern void dfi_attr_time_end_set(struct timeval *time_end);
|
||||
extern struct timeval *dfi_attr_time_end(void);
|
||||
void dfi_attr_time_end_set(struct timeval *time_end);
|
||||
struct timeval *dfi_attr_time_end(void);
|
||||
|
||||
extern void dfi_attr_cpu_id_set(u64 cpu_id);
|
||||
extern u64 *dfi_attr_cpu_id(void);
|
||||
void dfi_attr_cpu_id_set(u64 cpu_id);
|
||||
u64 *dfi_attr_cpu_id(void);
|
||||
|
||||
extern void dfi_attr_utsname_set(struct new_utsname *utsname);
|
||||
extern struct new_utsname *dfi_attr_utsname(void);
|
||||
void dfi_attr_utsname_set(struct new_utsname *utsname);
|
||||
struct new_utsname *dfi_attr_utsname(void);
|
||||
|
||||
extern void dfi_attr_dump_method_set(char *dump_method);
|
||||
extern char *dfi_attr_dump_method(void);
|
||||
void dfi_attr_dump_method_set(char *dump_method);
|
||||
char *dfi_attr_dump_method(void);
|
||||
|
||||
extern void dfi_attr_mem_size_real_set(u64 mem_size_real);
|
||||
extern u64 *dfi_attr_mem_size_real(void);
|
||||
void dfi_attr_mem_size_real_set(u64 mem_size_real);
|
||||
u64 *dfi_attr_mem_size_real(void);
|
||||
|
||||
extern void dfi_attr_file_size_set(u64 dump_size);
|
||||
extern u64 *dfi_attr_file_size(void);
|
||||
void dfi_attr_file_size_set(u64 dump_size);
|
||||
u64 *dfi_attr_file_size(void);
|
||||
|
||||
extern void dfi_attr_vol_nr_set(unsigned int vol_nr);
|
||||
extern unsigned int *dfi_attr_vol_nr(void);
|
||||
void dfi_attr_vol_nr_set(unsigned int vol_nr);
|
||||
unsigned int *dfi_attr_vol_nr(void);
|
||||
|
||||
extern void dfi_attr_version_set(unsigned int dfi_version);
|
||||
extern unsigned int *dfi_attr_dfi_version(void);
|
||||
void dfi_attr_version_set(unsigned int dfi_version);
|
||||
unsigned int *dfi_attr_dfi_version(void);
|
||||
|
||||
extern void dfi_attr_build_arch_set(enum dfi_arch build_arch);
|
||||
extern enum dfi_arch *dfi_attr_build_arch(void);
|
||||
void dfi_attr_build_arch_set(enum dfi_arch build_arch);
|
||||
enum dfi_arch *dfi_attr_build_arch(void);
|
||||
|
||||
extern void dfi_attr_real_cpu_cnt_set(u32 real_cpu_cnt);
|
||||
extern u32 *dfi_attr_real_cpu_cnt(void);
|
||||
void dfi_attr_real_cpu_cnt_set(u32 real_cpu_cnt);
|
||||
u32 *dfi_attr_real_cpu_cnt(void);
|
||||
|
||||
/*
|
||||
* DFI external functions
|
||||
*/
|
||||
extern void dfi_mem_read(u64 addr, void *buf, size_t cnt);
|
||||
extern int dfi_mem_read_rc(u64 addr, void *buf, size_t cnt);
|
||||
extern void dfi_mem_phys_read(u64 addr, void *buf, size_t cnt);
|
||||
extern void dfi_info_print(void);
|
||||
void dfi_info_print(void);
|
||||
|
||||
/*
|
||||
* DFI feature bits
|
||||
@@ -243,25 +191,13 @@ extern void dfi_info_print(void);
|
||||
#define DFI_FEAT_SEEK 0x1 /* Necessary for fuse mount */
|
||||
#define DFI_FEAT_COPY 0x2 /* Necessary for stdout */
|
||||
|
||||
extern int dfi_feat_seek(void);
|
||||
extern int dfi_feat_copy(void);
|
||||
int dfi_feat_seek(void);
|
||||
int dfi_feat_copy(void);
|
||||
|
||||
/*
|
||||
* DFI kdump functions
|
||||
*/
|
||||
extern unsigned long dfi_kdump_base(void);
|
||||
|
||||
/*
|
||||
* DFI vmcoreinfo functions
|
||||
*/
|
||||
extern void dfi_vmcoreinfo_init(void);
|
||||
extern char *dfi_vmcoreinfo_get(void);
|
||||
extern int dfi_vmcoreinfo_tag(char *str, int len, const char *sym);
|
||||
extern int dfi_vmcoreinfo_symbol(unsigned long *val, const char *sym);
|
||||
extern int dfi_vmcoreinfo_offset(unsigned long *offs, const char *sym);
|
||||
extern int dfi_vmcoreinfo_size(unsigned long *size, const char *sym);
|
||||
extern int dfi_vmcoreinfo_length(unsigned long *len, const char *sym);
|
||||
extern int dfi_vmcoreinfo_val(unsigned long *val, const char *sym);
|
||||
unsigned long dfi_kdump_base(void);
|
||||
|
||||
/*
|
||||
* DFI operations
|
||||
@@ -274,14 +210,14 @@ struct dfi {
|
||||
int feat_bits;
|
||||
};
|
||||
|
||||
extern const char *dfi_name(void);
|
||||
extern int dfi_init(void);
|
||||
extern void dfi_exit(void);
|
||||
const char *dfi_name(void);
|
||||
int dfi_init(void);
|
||||
void dfi_exit(void);
|
||||
|
||||
/*
|
||||
* Dump access
|
||||
*/
|
||||
extern struct zg_fh *dfi_dump_open(const char *path);
|
||||
struct zg_fh *dfi_dump_open(const char *path);
|
||||
|
||||
/*
|
||||
* Live dump memory magic
|
||||
@@ -293,4 +229,18 @@ extern u64 dfi_live_dump_magic;
|
||||
*/
|
||||
#define DFI_DUMP_METHOD_LIVE "live"
|
||||
|
||||
/*
|
||||
* Supported DFI dump formats
|
||||
*/
|
||||
extern struct dfi dfi_s390tape;
|
||||
extern struct dfi dfi_s390mv;
|
||||
extern struct dfi dfi_s390mv_ext;
|
||||
extern struct dfi dfi_s390;
|
||||
extern struct dfi dfi_s390_ext;
|
||||
extern struct dfi dfi_lkcd;
|
||||
extern struct dfi dfi_elf;
|
||||
extern struct dfi dfi_kdump;
|
||||
extern struct dfi dfi_kdump_flat;
|
||||
extern struct dfi dfi_devmem;
|
||||
|
||||
#endif /* DFI_H */
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "zgetdump.h"
|
||||
#include "df_s390.h"
|
||||
#include "dfi.h"
|
||||
#include "dfi_mem_chunk.h"
|
||||
|
||||
/*
|
||||
* Add live dump magic to buffer
|
||||
|
||||
113
zdump/dfi_elf.c
113
zdump/dfi_elf.c
@@ -16,7 +16,14 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "lib/util_libc.h"
|
||||
#include "lib/util_log.h"
|
||||
|
||||
#include "zgetdump.h"
|
||||
#include "zg.h"
|
||||
#include "df_elf.h"
|
||||
#include "dfi.h"
|
||||
#include "dfi_mem_chunk.h"
|
||||
|
||||
/*
|
||||
* Read memory for given memory chunk
|
||||
@@ -37,56 +44,68 @@ static int pt_load_add(Elf64_Phdr *phdr)
|
||||
{
|
||||
u64 *off_ptr;
|
||||
|
||||
util_log_print(UTIL_LOG_DEBUG,
|
||||
"DFI ELF p_paddr 0x%016lx p_vaddr 0x%016lx p_offset 0x%016lx p_filesz 0x%016lx p_memsz 0x%016lx\n",
|
||||
phdr->p_paddr, phdr->p_vaddr, phdr->p_offset,
|
||||
phdr->p_filesz, phdr->p_memsz);
|
||||
|
||||
if (phdr->p_paddr != phdr->p_vaddr) {
|
||||
phdr->p_paddr = phdr->p_vaddr;
|
||||
STDERR("Dump file \"%s\" is a user space core dump\n",
|
||||
g.opts.device);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (phdr->p_memsz == 0)
|
||||
return -EINVAL;
|
||||
if (phdr->p_offset + phdr->p_filesz > zg_size(g.fh))
|
||||
return -EINVAL;
|
||||
if (phdr->p_filesz == 0) {
|
||||
/* Add zero memory chunk */
|
||||
dfi_mem_chunk_add(phdr->p_paddr, phdr->p_memsz, NULL,
|
||||
dfi_mem_chunk_read_zero, NULL);
|
||||
} else {
|
||||
if (phdr->p_filesz > phdr->p_memsz)
|
||||
return -EINVAL;
|
||||
if (phdr->p_filesz > 0) {
|
||||
off_ptr = zg_alloc(sizeof(*off_ptr));
|
||||
*off_ptr = phdr->p_offset;
|
||||
dfi_mem_chunk_add(phdr->p_paddr, phdr->p_memsz, off_ptr,
|
||||
dfi_mem_chunk_add(phdr->p_paddr, phdr->p_filesz, off_ptr,
|
||||
dfi_elf_mem_chunk_read_fn, zg_free);
|
||||
}
|
||||
if (phdr->p_memsz - phdr->p_filesz > 0) {
|
||||
/* Add zero memory chunk */
|
||||
dfi_mem_chunk_add(phdr->p_paddr + phdr->p_filesz,
|
||||
phdr->p_memsz - phdr->p_filesz, NULL,
|
||||
dfi_mem_chunk_read_zero, NULL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Skip name of note
|
||||
*/
|
||||
static void nt_name_skip(Elf64_Nhdr *note)
|
||||
{
|
||||
zg_seek_cur(g.fh, ROUNDUP(note->n_namesz, 4), ZG_CHECK);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read note
|
||||
*/
|
||||
static int nt_read(Elf64_Nhdr *note, void *buf)
|
||||
static int nt_read(const Elf64_Nhdr *note, void *buf, size_t buf_len)
|
||||
{
|
||||
off_t buf_len = ROUNDUP(note->n_descsz, 4);
|
||||
char tmp_buf[buf_len];
|
||||
ssize_t nread;
|
||||
|
||||
nt_name_skip(note);
|
||||
if (zg_read(g.fh, tmp_buf, buf_len, ZG_CHECK_ERR) != buf_len)
|
||||
/* We cannot read more than the current note provides */
|
||||
if (note->n_descsz < buf_len)
|
||||
return -EINVAL;
|
||||
if (buf)
|
||||
memcpy(buf, tmp_buf, note->n_descsz);
|
||||
/* Skip note's name and position file at note's descriptor */
|
||||
zg_seek_cur(g.fh, ROUNDUP(note->n_namesz, 4), ZG_CHECK);
|
||||
/* Read note's descriptor */
|
||||
nread = zg_read(g.fh, buf, buf_len, ZG_CHECK_ERR);
|
||||
if (nread < 0 || (size_t)nread != buf_len)
|
||||
return -EINVAL;
|
||||
/* Skip the rest of note's descriptor until the next note */
|
||||
zg_seek_cur(g.fh, ROUNDUP(note->n_descsz, 4) - buf_len, ZG_CHECK);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Skip note
|
||||
*/
|
||||
static int nt_skip(Elf64_Nhdr *note)
|
||||
static void nt_skip(const Elf64_Nhdr *note)
|
||||
{
|
||||
return nt_read(note, NULL);
|
||||
/* Skip note's name + descriptor and position file at the next note */
|
||||
zg_seek_cur(g.fh,
|
||||
ROUNDUP(note->n_namesz, 4) + ROUNDUP(note->n_descsz, 4),
|
||||
ZG_CHECK);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -107,7 +126,7 @@ static struct dfi_cpu *nt_prstatus_read(Elf64_Nhdr *note)
|
||||
struct dfi_cpu *cpu = dfi_cpu_alloc();
|
||||
struct nt_prstatus_64 nt_prstatus;
|
||||
|
||||
if (nt_read(note, &nt_prstatus))
|
||||
if (nt_read(note, &nt_prstatus, sizeof(nt_prstatus)))
|
||||
return NULL;
|
||||
|
||||
memcpy(cpu->gprs, &nt_prstatus.gprs, sizeof(cpu->gprs));
|
||||
@@ -126,7 +145,7 @@ static int nt_fpregset_read(struct dfi_cpu *cpu, Elf64_Nhdr *note)
|
||||
struct nt_fpregset_64 nt_fpregset;
|
||||
|
||||
check_cpu(cpu, "FPREGSET");
|
||||
if (nt_read(note, &nt_fpregset))
|
||||
if (nt_read(note, &nt_fpregset, sizeof(nt_fpregset)))
|
||||
return -EINVAL;
|
||||
|
||||
memcpy(&cpu->fpc, &nt_fpregset.fpc, sizeof(cpu->fpc));
|
||||
@@ -140,7 +159,7 @@ static int nt_fpregset_read(struct dfi_cpu *cpu, Elf64_Nhdr *note)
|
||||
static int nt_s390_timer_read(struct dfi_cpu *cpu, Elf64_Nhdr *note)
|
||||
{
|
||||
check_cpu(cpu, "S390_TIMER");
|
||||
return nt_read(note, &cpu->timer);
|
||||
return nt_read(note, &cpu->timer, sizeof(cpu->timer));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -149,7 +168,7 @@ static int nt_s390_timer_read(struct dfi_cpu *cpu, Elf64_Nhdr *note)
|
||||
static int nt_s390_todcmp_read(struct dfi_cpu *cpu, Elf64_Nhdr *note)
|
||||
{
|
||||
check_cpu(cpu, "S390_TODCMP");
|
||||
return nt_read(note, &cpu->todcmp);
|
||||
return nt_read(note, &cpu->todcmp, sizeof(cpu->todcmp));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -158,7 +177,7 @@ static int nt_s390_todcmp_read(struct dfi_cpu *cpu, Elf64_Nhdr *note)
|
||||
static int nt_s390_todpreg_read(struct dfi_cpu *cpu, Elf64_Nhdr *note)
|
||||
{
|
||||
check_cpu(cpu, "S390_TODPREG");
|
||||
return nt_read(note, &cpu->todpreg);
|
||||
return nt_read(note, &cpu->todpreg, sizeof(cpu->todpreg));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -167,7 +186,7 @@ static int nt_s390_todpreg_read(struct dfi_cpu *cpu, Elf64_Nhdr *note)
|
||||
static int nt_s390_ctrs_read(struct dfi_cpu *cpu, Elf64_Nhdr *note)
|
||||
{
|
||||
check_cpu(cpu, "S390_CTRS");
|
||||
return nt_read(note, &cpu->ctrs);
|
||||
return nt_read(note, &cpu->ctrs, sizeof(cpu->ctrs));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -176,7 +195,7 @@ static int nt_s390_ctrs_read(struct dfi_cpu *cpu, Elf64_Nhdr *note)
|
||||
static int nt_s390_prefix_read(struct dfi_cpu *cpu, Elf64_Nhdr *note)
|
||||
{
|
||||
check_cpu(cpu, "S390_PREFIX");
|
||||
return nt_read(note, &cpu->prefix);
|
||||
return nt_read(note, &cpu->prefix, sizeof(cpu->prefix));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -185,7 +204,7 @@ static int nt_s390_prefix_read(struct dfi_cpu *cpu, Elf64_Nhdr *note)
|
||||
static int nt_s390_vxrs_low_read(struct dfi_cpu *cpu, Elf64_Nhdr *note)
|
||||
{
|
||||
check_cpu(cpu, "S390_VXRS_LOW");
|
||||
return nt_read(note, &cpu->vxrs_low);
|
||||
return nt_read(note, &cpu->vxrs_low, sizeof(cpu->vxrs_low));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -194,7 +213,7 @@ static int nt_s390_vxrs_low_read(struct dfi_cpu *cpu, Elf64_Nhdr *note)
|
||||
static int nt_s390_vxrs_high_read(struct dfi_cpu *cpu, Elf64_Nhdr *note)
|
||||
{
|
||||
check_cpu(cpu, "S390_VXRS_HIGH");
|
||||
return nt_read(note, &cpu->vxrs_high);
|
||||
return nt_read(note, &cpu->vxrs_high, sizeof(cpu->vxrs_high));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -202,7 +221,6 @@ static int nt_s390_vxrs_high_read(struct dfi_cpu *cpu, Elf64_Nhdr *note)
|
||||
*/
|
||||
static int pt_notes_add(Elf64_Phdr *phdr)
|
||||
{
|
||||
u64 start_off = zg_tell(g.fh, ZG_CHECK);
|
||||
struct dfi_cpu *cpu_current = NULL;
|
||||
u64 notes_start_off;
|
||||
Elf64_Nhdr note;
|
||||
@@ -214,6 +232,8 @@ static int pt_notes_add(Elf64_Phdr *phdr)
|
||||
rc = zg_read(g.fh, ¬e, sizeof(note), ZG_CHECK_ERR);
|
||||
if (rc != sizeof(note))
|
||||
return -EINVAL;
|
||||
util_log_print(UTIL_LOG_DEBUG, "DFI ELF n_type 0x%x\n",
|
||||
note.n_type);
|
||||
switch (note.n_type) {
|
||||
case NT_PRSTATUS:
|
||||
cpu_current = nt_prstatus_read(¬e);
|
||||
@@ -255,12 +275,10 @@ static int pt_notes_add(Elf64_Phdr *phdr)
|
||||
dfi_cpu_content_fac_add(DFI_CPU_CONTENT_FAC_VX);
|
||||
break;
|
||||
default:
|
||||
if (nt_skip(¬e))
|
||||
return -EINVAL;
|
||||
nt_skip(¬e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
zg_seek(g.fh, start_off, ZG_CHECK);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -287,9 +305,11 @@ static int read_elf_hdr(Elf64_Ehdr *ehdr)
|
||||
static int dfi_elf_init(void)
|
||||
{
|
||||
Elf64_Ehdr ehdr;
|
||||
Elf64_Phdr phdr;
|
||||
Elf64_Phdr *phdr;
|
||||
int i;
|
||||
|
||||
util_log_print(UTIL_LOG_DEBUG, "DFI ELF initialization\n");
|
||||
|
||||
if (read_elf_hdr(&ehdr) != 0)
|
||||
return -ENODEV;
|
||||
|
||||
@@ -297,21 +317,32 @@ static int dfi_elf_init(void)
|
||||
dfi_arch_set(DFI_ARCH_64);
|
||||
dfi_cpu_info_init(DFI_CPU_CONTENT_ALL);
|
||||
|
||||
phdr = util_malloc(sizeof(*phdr) * ehdr.e_phnum);
|
||||
zg_seek(g.fh, ehdr.e_phoff, ZG_CHECK);
|
||||
zg_read(g.fh, phdr, sizeof(*phdr) * ehdr.e_phnum, ZG_CHECK);
|
||||
util_log_print(UTIL_LOG_DEBUG, "DFI ELF e_phnum %u\n", ehdr.e_phnum);
|
||||
for (i = 0; i < ehdr.e_phnum; i++) {
|
||||
zg_read(g.fh, &phdr, sizeof(phdr), ZG_CHECK);
|
||||
switch (phdr.p_type) {
|
||||
util_log_print(UTIL_LOG_DEBUG, "DFI ELF p_type[%d] 0x%lx\n",
|
||||
i, phdr[i].p_type);
|
||||
switch (phdr[i].p_type) {
|
||||
case PT_LOAD:
|
||||
if (pt_load_add(&phdr))
|
||||
if (pt_load_add(&phdr[i])) {
|
||||
free(phdr);
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
case PT_NOTE:
|
||||
if (pt_notes_add(&phdr))
|
||||
if (pt_notes_add(&phdr[i])) {
|
||||
free(phdr);
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(phdr);
|
||||
|
||||
dfi_attr_version_set(ehdr.e_ident[EI_VERSION]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,12 @@
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "zgetdump.h"
|
||||
#include "zg.h"
|
||||
#include "dfi.h"
|
||||
#include "dfi_mem_chunk.h"
|
||||
|
||||
struct df_kdump_hdr {
|
||||
char signature[8];
|
||||
|
||||
@@ -9,8 +9,15 @@
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#include "zgetdump.h"
|
||||
#include "zg.h"
|
||||
#include "df_lkcd.h"
|
||||
#include "dfi.h"
|
||||
#include "dfi_mem_chunk.h"
|
||||
|
||||
#define MEM_HOLE_SIZE_MIN (1024 * 1024)
|
||||
#define IDX_KIB 64 /* One index entry per IDX_KIB */
|
||||
@@ -267,19 +274,25 @@ static int mem_init(void)
|
||||
/*
|
||||
* Initialize CPU information
|
||||
*/
|
||||
static void cpu_init(void)
|
||||
static int cpu_init(void)
|
||||
{
|
||||
unsigned int i;
|
||||
int rc;
|
||||
|
||||
if (l.hdr_asm.magic != DF_LKCD_MAGIC_ASM) {
|
||||
/* Old LKCD dump without asm header */
|
||||
dfi_cpu_info_init(DFI_CPU_CONTENT_NONE);
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
dfi_cpu_info_init(DFI_CPU_CONTENT_ALL);
|
||||
for (i = 0; i < l.hdr_asm.cpu_cnt; i++)
|
||||
dfi_cpu_add_from_lc(l.hdr_asm.lc_vec[i]);
|
||||
for (i = 0; i < l.hdr_asm.cpu_cnt; i++) {
|
||||
rc = dfi_cpu_add_from_lc(l.hdr_asm.lc_vec[i]);
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -321,7 +334,8 @@ static int dfi_lkcd_init(void)
|
||||
return -ENODEV;
|
||||
if (mem_init() != 0)
|
||||
return -EINVAL;
|
||||
cpu_init();
|
||||
if (cpu_init() != 0)
|
||||
return -EINVAL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
527
zdump/dfi_mem_chunk.c
Normal file
527
zdump/dfi_mem_chunk.c
Normal file
@@ -0,0 +1,527 @@
|
||||
/*
|
||||
* Copyright IBM Corp. 2001, 2018
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "lib/util_libc.h"
|
||||
#include "lib/util_log.h"
|
||||
|
||||
#include "zg.h"
|
||||
#include "dfi_mem_chunk.h"
|
||||
|
||||
/*
|
||||
* Memory information
|
||||
*/
|
||||
struct mem {
|
||||
struct dfi_mem_chunk *chunk_cache;
|
||||
u64 start_addr;
|
||||
u64 end_addr;
|
||||
unsigned int chunk_cnt;
|
||||
struct util_list chunk_list;
|
||||
};
|
||||
|
||||
/*
|
||||
* File local static data
|
||||
*/
|
||||
static struct {
|
||||
struct mem mem_phys;
|
||||
struct mem mem_virt;
|
||||
} l;
|
||||
|
||||
/*
|
||||
* Initialize DFI memory chunks
|
||||
*/
|
||||
static void mem_init(struct mem *mem)
|
||||
{
|
||||
mem->start_addr = U64_MAX;
|
||||
mem->end_addr = 0;
|
||||
util_list_init(&mem->chunk_list, struct dfi_mem_chunk, list);
|
||||
}
|
||||
|
||||
/*
|
||||
* Memory chunk compare function for list sorting
|
||||
*/
|
||||
static int mem_chunk_cmp_fn(void *a, void *b, void *UNUSED(data))
|
||||
{
|
||||
struct dfi_mem_chunk *mem_chunk1 = a;
|
||||
struct dfi_mem_chunk *mem_chunk2 = b;
|
||||
|
||||
return mem_chunk1->start < mem_chunk2->start ? -1 : 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Update DFI memory chunks
|
||||
*/
|
||||
static void mem_update(struct mem *mem)
|
||||
{
|
||||
struct dfi_mem_chunk *mem_chunk;
|
||||
|
||||
util_list_sort(&mem->chunk_list, mem_chunk_cmp_fn, NULL);
|
||||
mem->start_addr = U64_MAX;
|
||||
mem->end_addr = 0;
|
||||
util_list_iterate(&mem->chunk_list, mem_chunk) {
|
||||
mem->start_addr = MIN(mem->start_addr, mem_chunk->start);
|
||||
mem->end_addr = MAX(mem->end_addr, mem_chunk->end);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Print memory map
|
||||
*/
|
||||
void dfi_mem_map_print(bool verbose)
|
||||
{
|
||||
struct dfi_mem_chunk *mem_chunk;
|
||||
u64 print_start = 0, print_end = 0;
|
||||
const char *zero_str;
|
||||
u32 volnr = 0;
|
||||
|
||||
STDERR("\nMemory map:\n");
|
||||
/*
|
||||
* Print each memory chunk if verbose specified
|
||||
*/
|
||||
if (verbose) {
|
||||
dfi_mem_chunk_iterate(mem_chunk) {
|
||||
zero_str = "";
|
||||
if (mem_chunk->read_fn == dfi_mem_chunk_read_zero)
|
||||
zero_str = " zeroes";
|
||||
STDERR(" %016llx - %016llx (%llu MB%s)\n",
|
||||
mem_chunk->start, mem_chunk->end,
|
||||
TO_MIB(mem_chunk->size), zero_str);
|
||||
}
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* Merge adjacent memory chunks from the same volume
|
||||
*/
|
||||
dfi_mem_chunk_iterate(mem_chunk) {
|
||||
if (print_end == 0) {
|
||||
print_start = mem_chunk->start;
|
||||
print_end = mem_chunk->end;
|
||||
volnr = mem_chunk->volnr;
|
||||
continue;
|
||||
}
|
||||
if (mem_chunk->start != print_end + 1 ||
|
||||
mem_chunk->volnr != volnr) {
|
||||
STDERR(" %016llx - %016llx (%llu MB)\n", print_start,
|
||||
print_end, TO_MIB(print_end - print_start + 1));
|
||||
print_start = mem_chunk->start;
|
||||
volnr = mem_chunk->volnr;
|
||||
}
|
||||
print_end = mem_chunk->end;
|
||||
}
|
||||
STDERR(" %016llx - %016llx (%llu MB)\n", print_start,
|
||||
print_end, TO_MIB(print_end - print_start + 1));
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if memory chunk contains address
|
||||
*/
|
||||
static int mem_chunk_has_addr(struct dfi_mem_chunk *mem_chunk, u64 addr)
|
||||
{
|
||||
return (addr >= mem_chunk->start && addr <= mem_chunk->end);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find memory chunk that contains address
|
||||
*/
|
||||
static struct dfi_mem_chunk *mem_chunk_find(struct mem *mem, u64 addr)
|
||||
{
|
||||
struct dfi_mem_chunk *mem_chunk;
|
||||
|
||||
if (mem->chunk_cache && mem_chunk_has_addr(mem->chunk_cache, addr))
|
||||
return mem->chunk_cache;
|
||||
util_list_iterate(&mem->chunk_list, mem_chunk) {
|
||||
if (mem_chunk_has_addr(mem_chunk, addr)) {
|
||||
mem->chunk_cache = mem_chunk;
|
||||
return mem_chunk;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Is memory range valid?
|
||||
*/
|
||||
static int mem_range_valid(struct mem *mem, u64 addr, u64 len)
|
||||
{
|
||||
struct dfi_mem_chunk *mem_chunk;
|
||||
u64 addr_end = addr + len;
|
||||
|
||||
/* check for unsigned wrap */
|
||||
if (addr_end < addr)
|
||||
return 0;
|
||||
|
||||
do {
|
||||
mem_chunk = mem_chunk_find(mem, addr);
|
||||
if (!mem_chunk)
|
||||
return 0;
|
||||
addr += MIN(len, mem_chunk->end - addr + 1);
|
||||
} while (addr < addr_end);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Is memory already mapped at range?
|
||||
*/
|
||||
static int mem_range_mapped(u64 start, u64 size)
|
||||
{
|
||||
struct dfi_mem_chunk *mem_chunk;
|
||||
u64 end = start + size - 1;
|
||||
|
||||
dfi_mem_chunk_iterate(mem_chunk) {
|
||||
if (mem_chunk->start > end)
|
||||
continue;
|
||||
if (mem_chunk->end < start)
|
||||
continue;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add memory chunk to memory
|
||||
*/
|
||||
static void mem_chunk_create(struct mem *mem, u64 start, u64 size, void *data,
|
||||
dfi_mem_chunk_read_fn read_fn,
|
||||
dfi_mem_chunk_free_fn free_fn)
|
||||
{
|
||||
struct dfi_mem_chunk *mem_chunk;
|
||||
|
||||
mem_chunk = util_malloc(sizeof(*mem_chunk));
|
||||
mem_chunk->start = start;
|
||||
mem_chunk->end = start + size - 1;
|
||||
mem_chunk->size = size;
|
||||
mem_chunk->read_fn = read_fn;
|
||||
mem_chunk->free_fn = free_fn;
|
||||
mem_chunk->data = data;
|
||||
|
||||
util_list_add_tail(&mem->chunk_list, mem_chunk);
|
||||
mem->start_addr = MIN(mem->start_addr, mem_chunk->start);
|
||||
mem->end_addr = MAX(mem->end_addr, mem_chunk->end);
|
||||
mem->chunk_cache = mem_chunk;
|
||||
mem->chunk_cnt++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read memory at given address
|
||||
*/
|
||||
static void mem_read(struct mem *mem, u64 addr, void *buf, size_t cnt)
|
||||
{
|
||||
struct dfi_mem_chunk *mem_chunk;
|
||||
u64 size, off, copied = 0;
|
||||
|
||||
while (copied != cnt) {
|
||||
mem_chunk = mem_chunk_find(mem, addr);
|
||||
size = MIN(cnt - copied, mem_chunk->end - addr + 1);
|
||||
off = addr - mem_chunk->start;
|
||||
mem_chunk->read_fn(mem_chunk, off, buf + copied, size);
|
||||
copied += size;
|
||||
addr += size;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Read memory for virtual map memory chunk
|
||||
*/
|
||||
static void mem_chunk_map_read_fn(struct dfi_mem_chunk *mem_chunk, u64 off,
|
||||
void *buf, u64 cnt)
|
||||
{
|
||||
u64 *start = mem_chunk->data;
|
||||
|
||||
dfi_mem_phys_read(*start + off, buf, cnt);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if memory chunk is a virtual mapping
|
||||
*/
|
||||
static int mem_chunk_is_map(struct dfi_mem_chunk *mem_chunk)
|
||||
{
|
||||
return mem_chunk->read_fn == mem_chunk_map_read_fn;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return physical start address for memory chunk
|
||||
*/
|
||||
static u64 mem_chunk_start_phys(struct dfi_mem_chunk *mem_chunk)
|
||||
{
|
||||
if (mem_chunk_is_map(mem_chunk))
|
||||
return *((u64 *) mem_chunk->data);
|
||||
else
|
||||
return mem_chunk->start;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add virtual memory chunk
|
||||
*/
|
||||
static void mem_chunk_virt_add(u64 start, u64 size, void *data,
|
||||
dfi_mem_chunk_read_fn read_fn,
|
||||
dfi_mem_chunk_free_fn free_fn)
|
||||
{
|
||||
util_log_print(UTIL_LOG_DEBUG,
|
||||
"DFI add %svirt mem chunk start 0x%016lx size 0x%016lx\n",
|
||||
read_fn == dfi_mem_chunk_read_zero ? "zero " : "",
|
||||
start, size);
|
||||
|
||||
if (size == 0)
|
||||
return;
|
||||
mem_chunk_create(&l.mem_virt, start, size, data, read_fn, free_fn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add virtual memory chunk with simple virtual mapping
|
||||
*/
|
||||
static void mem_chunk_map_add(u64 start, u64 size, u64 start_p)
|
||||
{
|
||||
u64 *data = util_malloc(sizeof(*data));
|
||||
|
||||
*data = start_p;
|
||||
mem_chunk_virt_add(start, size, data, mem_chunk_map_read_fn, free);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add memory chunk with volume index
|
||||
*/
|
||||
void dfi_mem_chunk_add_vol(u64 start, u64 size, void *data,
|
||||
dfi_mem_chunk_read_fn read_fn,
|
||||
dfi_mem_chunk_free_fn free_fn,
|
||||
u32 volnr)
|
||||
{
|
||||
util_log_print(UTIL_LOG_DEBUG,
|
||||
"DFI add %svol mem chunk start 0x%016lx size 0x%016lx volnr %u\n",
|
||||
read_fn == dfi_mem_chunk_read_zero ? "zero " : "",
|
||||
start, size, volnr);
|
||||
|
||||
if (size == 0)
|
||||
return;
|
||||
mem_chunk_create(&l.mem_phys, start, size, data, read_fn, free_fn);
|
||||
mem_chunk_create(&l.mem_virt, start, size, data, read_fn, NULL);
|
||||
l.mem_virt.chunk_cache->volnr = volnr;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Add memory chunk
|
||||
*/
|
||||
void dfi_mem_chunk_add(u64 start, u64 size, void *data,
|
||||
dfi_mem_chunk_read_fn read_fn,
|
||||
dfi_mem_chunk_free_fn free_fn)
|
||||
{
|
||||
dfi_mem_chunk_add_vol(start, size, data, read_fn, free_fn, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read zero pages
|
||||
*/
|
||||
void dfi_mem_chunk_read_zero(struct dfi_mem_chunk *UNUSED(mem_chunk),
|
||||
u64 UNUSED(off), void *buf, u64 cnt)
|
||||
{
|
||||
memset(buf, 0, cnt);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return mem_chunk list head
|
||||
*/
|
||||
struct util_list *dfi_mem_chunk_list(void)
|
||||
{
|
||||
return &l.mem_virt.chunk_list;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return number of memory chunks in input dump
|
||||
*/
|
||||
unsigned int dfi_mem_chunk_cnt(void)
|
||||
{
|
||||
return l.mem_virt.chunk_cnt;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return maximum memory range
|
||||
*/
|
||||
u64 dfi_mem_range(void)
|
||||
{
|
||||
if (l.mem_virt.start_addr == U64_MAX)
|
||||
return 0;
|
||||
return l.mem_virt.end_addr - l.mem_virt.start_addr + 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Is memory range valid?
|
||||
*/
|
||||
int dfi_mem_range_valid(u64 addr, u64 len)
|
||||
{
|
||||
return mem_range_valid(&l.mem_virt, addr, len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return first memory chunk
|
||||
*/
|
||||
struct dfi_mem_chunk *dfi_mem_chunk_first(void)
|
||||
{
|
||||
if (util_list_is_empty(&l.mem_virt.chunk_list))
|
||||
return NULL;
|
||||
return util_list_start(&l.mem_virt.chunk_list);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return last memory chunk
|
||||
*/
|
||||
struct dfi_mem_chunk *dfi_mem_chunk_last(void)
|
||||
{
|
||||
if (util_list_is_empty(&l.mem_virt.chunk_list))
|
||||
return NULL;
|
||||
return util_list_end(&l.mem_virt.chunk_list);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return next memory chunk
|
||||
*/
|
||||
struct dfi_mem_chunk *dfi_mem_chunk_next(struct dfi_mem_chunk *mem_chunk)
|
||||
{
|
||||
return util_list_next(&l.mem_virt.chunk_list, mem_chunk);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return previous memory chunk
|
||||
*/
|
||||
struct dfi_mem_chunk *dfi_mem_chunk_prev(struct dfi_mem_chunk *mem_chunk)
|
||||
{
|
||||
return util_list_prev(&l.mem_virt.chunk_list, mem_chunk);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find memory chunk for given address
|
||||
*/
|
||||
struct dfi_mem_chunk *dfi_mem_chunk_find(u64 addr)
|
||||
{
|
||||
return mem_chunk_find(&l.mem_virt, addr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read physical memory at given address
|
||||
*/
|
||||
int dfi_mem_phys_read(u64 addr, void *buf, size_t cnt)
|
||||
{
|
||||
util_log_print(UTIL_LOG_TRACE,
|
||||
"DFI phys mem read addr 0x%016lx size 0x%016lx\n",
|
||||
addr, cnt);
|
||||
if (!mem_range_valid(&l.mem_phys, addr, cnt))
|
||||
return -EINVAL;
|
||||
mem_read(&l.mem_phys, addr, buf, cnt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read virtual memory at given address
|
||||
*/
|
||||
int dfi_mem_virt_read(u64 addr, void *buf, size_t cnt)
|
||||
{
|
||||
util_log_print(UTIL_LOG_TRACE,
|
||||
"DFI virt mem read addr 0x%016lx size 0x%016lx\n",
|
||||
addr, cnt);
|
||||
if (!mem_range_valid(&l.mem_virt, addr, cnt))
|
||||
return -EINVAL;
|
||||
mem_read(&l.mem_virt, addr, buf, cnt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unmap memory region
|
||||
*/
|
||||
void dfi_mem_unmap(u64 start, u64 size)
|
||||
{
|
||||
u64 start_phys, end_phys, addr_phys, addr_virt, size_virt;
|
||||
struct dfi_mem_chunk *mem_chunk, *tmp;
|
||||
u64 end = start + size - 1;
|
||||
|
||||
util_list_iterate_safe(&l.mem_virt.chunk_list, mem_chunk, tmp) {
|
||||
/*
|
||||
* Chunk not hit?
|
||||
*/
|
||||
if (mem_chunk->start >= start + size)
|
||||
continue;
|
||||
if (mem_chunk->end < start)
|
||||
continue;
|
||||
/*
|
||||
* Chunk completely unmapped
|
||||
*
|
||||
* UNMAP: UUUUUUUUU || UUUUUU
|
||||
* CHUNK: CCCC || CCCCCC
|
||||
* TO:
|
||||
*/
|
||||
if (mem_chunk->start >= start && mem_chunk->end <= end)
|
||||
goto free;
|
||||
|
||||
/*
|
||||
* Get real start and end addresses
|
||||
*/
|
||||
start_phys = mem_chunk_start_phys(mem_chunk);
|
||||
end_phys = start_phys + mem_chunk->size - 1;
|
||||
|
||||
/*
|
||||
* Chunk hit at start or in the middle?
|
||||
*
|
||||
* UNMAP: UUUUUU || UU || UUU
|
||||
* CHUNK: CCCCC || CCCCCC || CCCC
|
||||
* TO: NN || NN || NNN
|
||||
*/
|
||||
if (mem_chunk->end > end) {
|
||||
addr_virt = end + 1;
|
||||
size_virt = mem_chunk->end - end;
|
||||
addr_phys = end_phys - size_virt + 1;
|
||||
mem_chunk_map_add(addr_virt, size_virt, addr_phys);
|
||||
}
|
||||
/*
|
||||
* Chunk hit at end or in the middle?
|
||||
*
|
||||
* UNMAP: UUUUUU || UU || UUU
|
||||
* CHUNK: CCCCC || CCCCCC || CCC
|
||||
* TO: NN || NN || NN
|
||||
*/
|
||||
if (mem_chunk->start < start) {
|
||||
addr_virt = mem_chunk->start;
|
||||
size_virt = start - addr_virt;
|
||||
addr_phys = start_phys;
|
||||
mem_chunk_map_add(addr_virt, size_virt, addr_phys);
|
||||
}
|
||||
free:
|
||||
util_list_remove(&l.mem_virt.chunk_list, mem_chunk);
|
||||
l.mem_virt.chunk_cnt--;
|
||||
if (mem_chunk->data && mem_chunk->free_fn)
|
||||
mem_chunk->free_fn(mem_chunk->data);
|
||||
free(mem_chunk);
|
||||
}
|
||||
mem_update(&l.mem_virt);
|
||||
}
|
||||
|
||||
/*
|
||||
* Map memory region
|
||||
*/
|
||||
void dfi_mem_map(u64 start, u64 size, u64 start_phys)
|
||||
{
|
||||
if (mem_range_mapped(start, size)) {
|
||||
dfi_mem_map_print(false);
|
||||
ABORT("Map request for already mapped region (%llx/%llx/%llx)",
|
||||
start, size, start_phys);
|
||||
}
|
||||
mem_chunk_map_add(start, size, start_phys);
|
||||
mem_update(&l.mem_virt);
|
||||
}
|
||||
|
||||
int dfi_mem_chunk_init(void)
|
||||
{
|
||||
mem_init(&l.mem_virt);
|
||||
mem_init(&l.mem_phys);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dfi_mem_chunk_deinit(void)
|
||||
{
|
||||
memset(&l, 0, sizeof(l));
|
||||
}
|
||||
69
zdump/dfi_mem_chunk.h
Normal file
69
zdump/dfi_mem_chunk.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright IBM Corp. 2001, 2018
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef DFI_MEM_CHUNK_H
|
||||
#define DFI_MEM_CHUNK_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "lib/zt_common.h"
|
||||
#include "lib/util_list.h"
|
||||
|
||||
/*
|
||||
* Mem chunk functions and definitions
|
||||
*/
|
||||
struct dfi_mem_chunk;
|
||||
|
||||
typedef void (*dfi_mem_chunk_read_fn)(struct dfi_mem_chunk *mem_chunk,
|
||||
u64 off, void *buf, u64 cnt);
|
||||
typedef void (*dfi_mem_chunk_free_fn)(void *data);
|
||||
|
||||
struct dfi_mem_chunk {
|
||||
struct util_list_node list; /* List */
|
||||
u64 start; /* Start address in memory */
|
||||
u64 end; /* End address in memory */
|
||||
u64 size; /* Size of chunk in dump file */
|
||||
dfi_mem_chunk_read_fn read_fn; /* Chunk read callback */
|
||||
dfi_mem_chunk_free_fn free_fn; /* Free data callback */
|
||||
void *data; /* Data for callback */
|
||||
u32 volnr; /* Volume id where chunk resides */
|
||||
};
|
||||
|
||||
void dfi_mem_chunk_read_zero(struct dfi_mem_chunk *UNUSED(mem_chunk),
|
||||
u64 UNUSED(off), void *buf, u64 cnt);
|
||||
void dfi_mem_chunk_add_vol(u64 start, u64 size, void *data,
|
||||
dfi_mem_chunk_read_fn read_fn,
|
||||
dfi_mem_chunk_free_fn free_fn,
|
||||
u32 volnr);
|
||||
void dfi_mem_chunk_add(u64 start, u64 size, void *data,
|
||||
dfi_mem_chunk_read_fn read_fn,
|
||||
dfi_mem_chunk_free_fn free_fn);
|
||||
u64 dfi_mem_range(void);
|
||||
int dfi_mem_range_valid(u64 addr, u64 len);
|
||||
unsigned int dfi_mem_chunk_cnt(void);
|
||||
struct dfi_mem_chunk *dfi_mem_chunk_first(void);
|
||||
struct dfi_mem_chunk *dfi_mem_chunk_last(void);
|
||||
struct dfi_mem_chunk *dfi_mem_chunk_next(struct dfi_mem_chunk *chunk);
|
||||
struct dfi_mem_chunk *dfi_mem_chunk_prev(struct dfi_mem_chunk *chunk);
|
||||
struct dfi_mem_chunk *dfi_mem_chunk_find(u64 addr);
|
||||
|
||||
struct util_list *dfi_mem_chunk_list(void);
|
||||
#define dfi_mem_chunk_iterate(mem_chunk) \
|
||||
util_list_iterate(dfi_mem_chunk_list(), mem_chunk)
|
||||
|
||||
int dfi_mem_virt_read(u64 addr, void *buf, size_t cnt);
|
||||
int dfi_mem_phys_read(u64 addr, void *buf, size_t cnt);
|
||||
|
||||
void dfi_mem_map_print(bool verbose);
|
||||
|
||||
void dfi_mem_unmap(u64 start, u64 size);
|
||||
void dfi_mem_map(u64 start, u64 size, u64 start_phys);
|
||||
|
||||
int dfi_mem_chunk_init(void);
|
||||
void dfi_mem_chunk_deinit(void);
|
||||
|
||||
#endif /* DFI_MEM_CHUNK_H */
|
||||
@@ -17,8 +17,16 @@
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "lib/util_log.h"
|
||||
|
||||
#include "zgetdump.h"
|
||||
#include "zg.h"
|
||||
#include "dfi.h"
|
||||
#include "dfi_mem_chunk.h"
|
||||
#include "df_elf.h"
|
||||
#include "df_s390.h"
|
||||
|
||||
/*
|
||||
* File local static data
|
||||
@@ -68,6 +76,9 @@ static int read_s390_hdr(void)
|
||||
return -ENODEV;
|
||||
if (l.hdr.magic != magic_number)
|
||||
return -ENODEV;
|
||||
if (l.hdr.cpu_cnt > DF_S390_CPU_MAX)
|
||||
return -ENODEV;
|
||||
util_log_print(UTIL_LOG_INFO, "DFI S390 version %u\n", l.hdr.version);
|
||||
df_s390_hdr_add(&l.hdr);
|
||||
return 0;
|
||||
}
|
||||
@@ -95,6 +106,9 @@ static int mem_chunks_add(void)
|
||||
{
|
||||
u64 rc;
|
||||
|
||||
util_log_print(UTIL_LOG_DEBUG, "DFI S390 mem_size 0x%016lx\n",
|
||||
l.hdr.mem_size);
|
||||
|
||||
/* Single memory chunk for non-extended dump format */
|
||||
dfi_mem_chunk_add(0, l.hdr.mem_size, NULL,
|
||||
dfi_s390_mem_chunk_read,
|
||||
@@ -112,39 +126,43 @@ static int mem_chunks_add(void)
|
||||
*/
|
||||
static int mem_chunks_add_ext(void)
|
||||
{
|
||||
struct df_s390_dump_segm_hdr dump_segm;
|
||||
u64 rc, *off_ptr, old = 0, dump_size = 0;
|
||||
struct df_s390_dump_segm_hdr dump_segm = { 0 };
|
||||
u64 rc, off, old = 0, dump_size = 0;
|
||||
|
||||
off_ptr = zg_alloc(sizeof(*off_ptr));
|
||||
*off_ptr = zg_seek(g.fh, DF_S390_HDR_SIZE, ZG_CHECK_NONE);
|
||||
if (*off_ptr != DF_S390_HDR_SIZE)
|
||||
off = zg_seek(g.fh, DF_S390_HDR_SIZE, ZG_CHECK_NONE);
|
||||
if (off != DF_S390_HDR_SIZE)
|
||||
return -EINVAL;
|
||||
while (*off_ptr < DF_S390_HDR_SIZE + l.hdr.mem_size - PAGE_SIZE) {
|
||||
while (off < DF_S390_HDR_SIZE + l.hdr.mem_size - PAGE_SIZE) {
|
||||
rc = zg_read(g.fh, &dump_segm, PAGE_SIZE, ZG_CHECK_ERR);
|
||||
if (rc != PAGE_SIZE)
|
||||
return -EINVAL;
|
||||
*off_ptr += PAGE_SIZE;
|
||||
util_log_print(UTIL_LOG_DEBUG,
|
||||
"DFI S390 dump segment start 0x%016lx size 0x%016lx stop marker %d\n",
|
||||
dump_segm.start, dump_segm.len, dump_segm.stop_marker);
|
||||
off += PAGE_SIZE;
|
||||
/* Add zero memory chunk */
|
||||
dfi_mem_chunk_add(old, dump_segm.start - old, NULL,
|
||||
dfi_mem_chunk_read_zero, NULL);
|
||||
/* Add memory chunk for a dump segment */
|
||||
u64 *off_ptr = zg_alloc(sizeof(*off_ptr));
|
||||
*off_ptr = off;
|
||||
dfi_mem_chunk_add(dump_segm.start, dump_segm.len, off_ptr,
|
||||
dfi_s390_ext_mem_chunk_read, zg_free);
|
||||
off_ptr = NULL;
|
||||
old = dump_segm.start + dump_segm.len;
|
||||
dump_size += dump_segm.len;
|
||||
off_ptr = zg_alloc(sizeof(*off_ptr));
|
||||
*off_ptr = zg_seek_cur(g.fh, dump_segm.len, ZG_CHECK_NONE);
|
||||
off = zg_seek_cur(g.fh, dump_segm.len, ZG_CHECK_NONE);
|
||||
if (dump_segm.stop_marker)
|
||||
break;
|
||||
}
|
||||
/* Check if the last dump segment found */
|
||||
if (!dump_segm.stop_marker)
|
||||
return -EINVAL;
|
||||
/* Add zero memory chunk at the end */
|
||||
dfi_mem_chunk_add(old, l.hdr.mem_size - old, NULL,
|
||||
dfi_mem_chunk_read_zero, NULL);
|
||||
/* Set the actual size of the dump file */
|
||||
dfi_attr_file_size_set(dump_size);
|
||||
/* Check if the last dump segment found */
|
||||
if (!dump_segm.stop_marker)
|
||||
return -EINVAL;
|
||||
/* Read and verify the end marker */
|
||||
return read_s390_em();
|
||||
}
|
||||
@@ -156,6 +174,9 @@ int dfi_s390_init_gen(bool extended)
|
||||
{
|
||||
int rc;
|
||||
|
||||
util_log_print(UTIL_LOG_DEBUG, "DFI S390 %sinitialization\n",
|
||||
extended ? "extended " : "");
|
||||
|
||||
l.extended = extended;
|
||||
if (read_s390_hdr() != 0)
|
||||
return -ENODEV;
|
||||
@@ -165,7 +186,9 @@ int dfi_s390_init_gen(bool extended)
|
||||
rc = mem_chunks_add_ext();
|
||||
if (rc)
|
||||
return rc;
|
||||
df_s390_cpu_info_add(&l.hdr, l.hdr.mem_size);
|
||||
rc = df_s390_cpu_info_add(&l.hdr, l.hdr.mem_size);
|
||||
if (rc)
|
||||
return rc;
|
||||
zg_seek(g.fh, sizeof(l.hdr), ZG_CHECK);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#include "zgetdump.h"
|
||||
#include "dt.h"
|
||||
#include "df_s390.h"
|
||||
#include "dfi.h"
|
||||
|
||||
/*
|
||||
* Initialize s390 input dump format (extended)
|
||||
|
||||
@@ -20,12 +20,17 @@
|
||||
#include <sys/sysmacros.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "lib/util_file.h"
|
||||
#include "lib/util_path.h"
|
||||
|
||||
#include "zgetdump.h"
|
||||
#include "dt.h"
|
||||
#include "df_s390.h"
|
||||
#include "dfi.h"
|
||||
#include "dfi_s390mv.h"
|
||||
#include "dfi_mem_chunk.h"
|
||||
|
||||
/*
|
||||
* Volume information
|
||||
@@ -574,6 +579,8 @@ static void set_magic_numbers(void)
|
||||
*/
|
||||
int dfi_s390mv_init_gen(bool extended)
|
||||
{
|
||||
int rc;
|
||||
|
||||
l.extended = extended;
|
||||
set_magic_numbers();
|
||||
if (open_dump() != 0)
|
||||
@@ -590,7 +597,9 @@ int dfi_s390mv_init_gen(bool extended)
|
||||
return -EINVAL;
|
||||
if (l.dump_incomplete)
|
||||
return -EINVAL;
|
||||
df_s390_cpu_info_add(&l.hdr, l.hdr.mem_end);
|
||||
rc = df_s390_cpu_info_add(&l.hdr, l.hdr.mem_end);
|
||||
if (rc)
|
||||
return rc;
|
||||
df_s390_em_add(&l.em);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
*/
|
||||
|
||||
#include "zgetdump.h"
|
||||
#include "dt.h"
|
||||
#include "df_s390.h"
|
||||
#include "dfi.h"
|
||||
|
||||
/*
|
||||
* Initialize s390 multi-volume input dump format (extedend)
|
||||
|
||||
@@ -17,8 +17,12 @@
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "zgetdump.h"
|
||||
#include "df_s390.h"
|
||||
#include "dfi.h"
|
||||
#include "dfi_mem_chunk.h"
|
||||
|
||||
#define TAPE_BLK_SIZE 32768 /* Defined by zipl tape dumper */
|
||||
|
||||
@@ -166,7 +170,9 @@ static int vol_init(void)
|
||||
|
||||
/* Init memory read & CPU info */
|
||||
mem_read_init();
|
||||
df_s390_cpu_info_add(&hdr, hdr.mem_size - 1);
|
||||
rc = df_s390_cpu_info_add(&hdr, hdr.mem_size - 1);
|
||||
if (rc)
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,11 +9,16 @@
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <elf.h>
|
||||
|
||||
#include "lib/zt_common.h"
|
||||
#include "lib/util_log.h"
|
||||
|
||||
#include "zgetdump.h"
|
||||
#include "zg.h"
|
||||
#include "dfi_mem_chunk.h"
|
||||
#include "dfi_vmcoreinfo.h"
|
||||
|
||||
#ifdef __s390x__
|
||||
#define LC_VMCORE_INFO 0xe0c
|
||||
@@ -22,7 +27,7 @@
|
||||
#endif
|
||||
|
||||
#define LC_OS_INFO 0xe18
|
||||
#define OS_INFO_MAGIC 0x4f53494e464f535aULL /* OSINFOSZ */
|
||||
#define OS_INFO_MAGIC 0x4f53494e464f535aULL /* OSINFOSZ */
|
||||
|
||||
struct os_info {
|
||||
u64 magic;
|
||||
@@ -62,10 +67,13 @@ static struct os_info *os_info_get(void)
|
||||
static struct os_info os_info;
|
||||
unsigned long addr;
|
||||
|
||||
dfi_mem_read(LC_OS_INFO, &addr, sizeof(addr));
|
||||
util_log_print(UTIL_LOG_TRACE, "DFI get osinfo\n");
|
||||
|
||||
if (dfi_mem_virt_read(LC_OS_INFO, &addr, sizeof(addr)))
|
||||
return NULL;
|
||||
if (addr % 0x1000)
|
||||
return NULL;
|
||||
if (dfi_mem_read_rc(addr, &os_info, sizeof(os_info)))
|
||||
if (dfi_mem_virt_read(addr, &os_info, sizeof(os_info)))
|
||||
return NULL;
|
||||
if (os_info.magic != OS_INFO_MAGIC)
|
||||
return NULL;
|
||||
@@ -83,32 +91,42 @@ void dfi_vmcoreinfo_init(void)
|
||||
Elf64_Nhdr note;
|
||||
char str[128];
|
||||
|
||||
util_log_print(UTIL_LOG_TRACE, "DFI vmcoreinfo initialization\n");
|
||||
|
||||
l.os_info = os_info_get();
|
||||
|
||||
if (l.os_info && l.os_info->vmcoreinfo_size) {
|
||||
util_log_print(UTIL_LOG_DEBUG, "DFI found valid osinfo\n");
|
||||
addr = l.os_info->vmcoreinfo_addr;
|
||||
size = l.os_info->vmcoreinfo_size;
|
||||
} else {
|
||||
dfi_mem_read(LC_VMCORE_INFO, &addr, sizeof(addr));
|
||||
if (dfi_mem_virt_read(LC_VMCORE_INFO, &addr, sizeof(addr)))
|
||||
return;
|
||||
if (addr == 0)
|
||||
return;
|
||||
if (dfi_mem_read_rc(addr, ¬e, sizeof(note)))
|
||||
if (dfi_mem_virt_read(addr, ¬e, sizeof(note)))
|
||||
return;
|
||||
if (note.n_namesz == 0 || note.n_namesz > sizeof(str))
|
||||
return;
|
||||
memset(str, 0, sizeof(str));
|
||||
if (dfi_mem_read_rc(addr + sizeof(note), str, note.n_namesz))
|
||||
if (dfi_mem_virt_read(addr + sizeof(note), str, note.n_namesz))
|
||||
return;
|
||||
if (memcmp(str, "VMCOREINFO", sizeof("VMCOREINFO")) != 0)
|
||||
return;
|
||||
size = note.n_descsz;
|
||||
addr += 24;
|
||||
}
|
||||
util_log_print(UTIL_LOG_DEBUG,
|
||||
"DFI vmcoreinfo addr 0x%016lx size 0x%016lx\n",
|
||||
addr, size);
|
||||
l.vmcoreinfo = zg_alloc(size + 1);
|
||||
if (dfi_mem_read_rc(addr, l.vmcoreinfo, size)) {
|
||||
if (dfi_mem_virt_read(addr, l.vmcoreinfo, size)) {
|
||||
zg_free(l.vmcoreinfo);
|
||||
l.vmcoreinfo = NULL;
|
||||
return;
|
||||
}
|
||||
l.vmcoreinfo[size] = 0;
|
||||
util_log_print(UTIL_LOG_INFO, "DFI found valid vmcoreinfo\n");
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
20
zdump/dfi_vmcoreinfo.h
Normal file
20
zdump/dfi_vmcoreinfo.h
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright IBM Corp. 2001, 2018
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef DFI_VMCOREINFO_H
|
||||
#define DFI_VMCOREINFO_H
|
||||
|
||||
void dfi_vmcoreinfo_init(void);
|
||||
char *dfi_vmcoreinfo_get(void);
|
||||
int dfi_vmcoreinfo_tag(char *str, int len, const char *sym);
|
||||
int dfi_vmcoreinfo_symbol(unsigned long *val, const char *sym);
|
||||
int dfi_vmcoreinfo_offset(unsigned long *offs, const char *sym);
|
||||
int dfi_vmcoreinfo_size(unsigned long *size, const char *sym);
|
||||
int dfi_vmcoreinfo_length(unsigned long *len, const char *sym);
|
||||
int dfi_vmcoreinfo_val(unsigned long *val, const char *sym);
|
||||
|
||||
#endif /* DFI_VMCOREINFO_H */
|
||||
@@ -10,7 +10,11 @@
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
#include "zgetdump.h"
|
||||
|
||||
#include "lib/util_list.h"
|
||||
|
||||
#include "dfi_mem_chunk.h"
|
||||
#include "dfo.h"
|
||||
|
||||
#define dfo_chunk_iterate(dfo_chunk) \
|
||||
util_list_iterate(&l.dump.chunk_list, dfo_chunk)
|
||||
|
||||
@@ -52,4 +52,10 @@ struct dfo {
|
||||
void (*init)(void);
|
||||
};
|
||||
|
||||
/*
|
||||
* Supported DFO dump formats
|
||||
*/
|
||||
extern struct dfo dfo_s390;
|
||||
extern struct dfo dfo_elf;
|
||||
|
||||
#endif /* DFO_H */
|
||||
|
||||
@@ -16,7 +16,11 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "zgetdump.h"
|
||||
#include "df_elf.h"
|
||||
#include "dfi.h"
|
||||
#include "dfi_mem_chunk.h"
|
||||
#include "dfi_vmcoreinfo.h"
|
||||
#include "dfo.h"
|
||||
|
||||
#define HDR_PER_CPU_SIZE 0x4a0
|
||||
#define HDR_PER_MEMC_SIZE 0x100
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "zgetdump.h"
|
||||
#include "df_s390.h"
|
||||
#include "dfi_mem_chunk.h"
|
||||
#include "dfo.h"
|
||||
|
||||
/*
|
||||
* File local static data
|
||||
@@ -98,7 +100,8 @@ static void dfo_s390_dump_chunk_lc_fn(struct dfo_chunk *dump_chunk,
|
||||
struct dfi_cpu *cpu = dump_chunk->data;
|
||||
char lc[0x2000];
|
||||
|
||||
dfi_mem_read(cpu->prefix + off, &lc[off], cnt);
|
||||
if (dfi_mem_virt_read(cpu->prefix + off, &lc[off], cnt))
|
||||
return;
|
||||
if (dfi_arch() == DFI_ARCH_64)
|
||||
cpu2lc_64(lc, cpu);
|
||||
else
|
||||
@@ -142,7 +145,8 @@ static void add_cpu_to_dfo(struct dfi_cpu *cpu)
|
||||
return;
|
||||
if (!dfi_cpu_content_fac_check(DFI_CPU_CONTENT_FAC_VX))
|
||||
return;
|
||||
dfi_mem_read(cpu->prefix, &lc, sizeof(lc));
|
||||
if (dfi_mem_virt_read(cpu->prefix, &lc, sizeof(lc)))
|
||||
return;
|
||||
if (!dfi_cpu_lc_has_vx_sa(&lc))
|
||||
return;
|
||||
vx_regs = zg_alloc(DFI_VX_SA_SIZE);
|
||||
@@ -181,8 +185,8 @@ static void dump_chunks_init(void)
|
||||
dfi_cpu_iterate(cpu)
|
||||
add_cpu_to_dfo(cpu);
|
||||
dfo_chunk_add(dfi_mem_range() + DF_S390_HDR_SIZE,
|
||||
DF_S390_EM_SIZE,
|
||||
&l.em, dfo_chunk_buf_fn);
|
||||
DF_S390_EM_SIZE,
|
||||
&l.em, dfo_chunk_buf_fn);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
*/
|
||||
|
||||
#include "zgetdump.h"
|
||||
#include "zg.h"
|
||||
#include "dt.h"
|
||||
|
||||
/*
|
||||
* Supported dump tools
|
||||
|
||||
26
zdump/dt.h
26
zdump/dt.h
@@ -12,9 +12,10 @@
|
||||
#ifndef DT_H
|
||||
#define DT_H
|
||||
|
||||
#include "dfi.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "dfi.h"
|
||||
|
||||
#define DUMP_EXTENDED true
|
||||
#define DUMP_NON_EXTENDED false
|
||||
|
||||
@@ -24,12 +25,21 @@ struct dt {
|
||||
void (*info)(void);
|
||||
};
|
||||
|
||||
extern void dt_init(void);
|
||||
extern void dt_info_print(void);
|
||||
extern void dt_arch_set(enum dfi_arch arch);
|
||||
extern void dt_version_set(int version);
|
||||
extern void dt_attr_mem_limit_set(u64 mem_limit);
|
||||
extern void dt_attr_force_set(int value);
|
||||
extern void dt_attr_dasd_type_set(const char *dasd_type);
|
||||
void dt_init(void);
|
||||
void dt_info_print(void);
|
||||
void dt_arch_set(enum dfi_arch arch);
|
||||
void dt_version_set(int version);
|
||||
void dt_attr_mem_limit_set(u64 mem_limit);
|
||||
void dt_attr_force_set(int value);
|
||||
void dt_attr_dasd_type_set(const char *dasd_type);
|
||||
|
||||
/*
|
||||
* Supported s390 dumpers
|
||||
*/
|
||||
extern struct dt dt_s390mv;
|
||||
extern struct dt dt_s390mv_ext;
|
||||
extern struct dt dt_s390sv;
|
||||
extern struct dt dt_s390sv_ext;
|
||||
extern struct dt dt_scsi;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#include "zgetdump.h"
|
||||
#include "dt.h"
|
||||
#include "df_s390.h"
|
||||
|
||||
/*
|
||||
* Initialize s390 multi-volume dump tool (for -d option)
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#include "zgetdump.h"
|
||||
#include "dt.h"
|
||||
#include "df_s390.h"
|
||||
|
||||
/*
|
||||
* Initialize s390 multi-volume dump tool (extedend) for -d option
|
||||
|
||||
@@ -9,8 +9,13 @@
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <linux/fs.h>
|
||||
|
||||
#include "zgetdump.h"
|
||||
#include "zg.h"
|
||||
#include "dt.h"
|
||||
#include "df_s390.h"
|
||||
|
||||
/*
|
||||
* File local static data
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
*/
|
||||
|
||||
#include <linux/fs.h>
|
||||
#include "zgetdump.h"
|
||||
|
||||
#include "dt.h"
|
||||
#include "df_s390.h"
|
||||
|
||||
/*
|
||||
* Initialize s390 single-volume extended dump tool (for -d option)
|
||||
|
||||
@@ -9,13 +9,16 @@
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#include <linux/fs.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <linux/fs.h>
|
||||
|
||||
#include "lib/zt_common.h"
|
||||
#include "lib/util_part.h"
|
||||
|
||||
#include "zgetdump.h"
|
||||
#include "zg.h"
|
||||
#include "dt.h"
|
||||
|
||||
/*
|
||||
* Single volume SCSI dump superblock
|
||||
|
||||
228
zdump/opts.c
228
zdump/opts.c
@@ -15,39 +15,60 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "lib/zt_common.h"
|
||||
#include "zgetdump.h"
|
||||
#include "lib/util_log.h"
|
||||
|
||||
#include "opts.h"
|
||||
|
||||
static struct option long_opts[] = {
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{"version", no_argument, NULL, 'v'},
|
||||
{"info", no_argument, NULL, 'i'},
|
||||
{"device", no_argument, NULL, 'd'},
|
||||
{"mount", no_argument, NULL, 'm'},
|
||||
{"umount", no_argument, NULL, 'u'},
|
||||
{"fmt", required_argument, NULL, 'f'},
|
||||
{"select", required_argument, NULL, 's'},
|
||||
{"debug", no_argument, NULL, 'X'},
|
||||
{"verbose", no_argument, NULL, 'V'},
|
||||
{NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
static const char optstr[] = "hvVidmus:f:X";
|
||||
|
||||
/*
|
||||
* Text for --help option
|
||||
*/
|
||||
static char help_text[] =
|
||||
"Usage: zgetdump DUMP [-s SYS] [-f FMT] > DUMP_FILE\n"
|
||||
" -m DUMP [-s SYS] [-f FMT] DIR\n"
|
||||
" -i DUMP [-s SYS]\n"
|
||||
" -d DUMPDEV\n"
|
||||
" -u DIR\n"
|
||||
"\n"
|
||||
"The zgetdump tool can read different dump formats from a dump device or from\n"
|
||||
"a dump file. You can use zgetdump to:\n"
|
||||
"\n"
|
||||
" - Write the dump content to standard output or to a file\n"
|
||||
" - Mount the dump content to a Linux directory\n"
|
||||
" - Convert a dump to a different dump format\n"
|
||||
" - Check if a dump is valid\n"
|
||||
" - Check if a DASD contains a valid dump tool.\n"
|
||||
"\n"
|
||||
"In the syntax description, DUMP specifies a dump device or dump file to be\n"
|
||||
"read. The following options are available:\n"
|
||||
"\n"
|
||||
"-m, --mount Mount DUMP to mount point DIR\n"
|
||||
"-u, --umount Unmount dump from mount point DIR\n"
|
||||
"-i, --info Print DUMP information\n"
|
||||
"-f, --fmt Specify target dump format FMT (\"elf\" or \"s390\")\n"
|
||||
"-s, --select Select system data SYS (\"kdump\", \"prod\", or \"all\")\n"
|
||||
"-d, --device Print DUMPDEV (dump device) information\n"
|
||||
"-v, --version Print version information, then exit\n"
|
||||
"-V, --verbose Show detailed layout of memory map on printing DUMP information\n"
|
||||
"-h, --help Print this help, then exit\n";
|
||||
static const char help_text[] =
|
||||
"Usage: zgetdump DUMP [-s SYS] [-f FMT] > DUMP_FILE\n"
|
||||
" -m DUMP [-s SYS] [-f FMT] DIR\n"
|
||||
" -i DUMP [-s SYS]\n"
|
||||
" -d DUMPDEV\n"
|
||||
" -u DIR\n"
|
||||
"\n"
|
||||
"The zgetdump tool can read different dump formats from a dump device or from\n"
|
||||
"a dump file. You can use zgetdump to:\n"
|
||||
"\n"
|
||||
" - Write the dump content to standard output or to a file\n"
|
||||
" - Mount the dump content to a Linux directory\n"
|
||||
" - Convert a dump to a different dump format\n"
|
||||
" - Check if a dump is valid\n"
|
||||
" - Check if a DASD contains a valid dump tool.\n"
|
||||
"\n"
|
||||
"In the syntax description, DUMP specifies a dump device or dump file to be\n"
|
||||
"read. The following options are available:\n"
|
||||
"\n"
|
||||
"-m, --mount Mount DUMP to mount point DIR\n"
|
||||
"-u, --umount Unmount dump from mount point DIR\n"
|
||||
"-i, --info Print DUMP information\n"
|
||||
"-f, --fmt Specify target dump format FMT (\"elf\" or \"s390\")\n"
|
||||
"-s, --select Select system data SYS (\"kdump\", \"prod\", or \"all\")\n"
|
||||
"-d, --device Print DUMPDEV (dump device) information\n"
|
||||
"-v, --version Print version information, then exit\n"
|
||||
"-V, --verbose Print verbose messages to stdout. Repeat this option\n"
|
||||
" for increased verbosity from just error messages to\n"
|
||||
" also include warning, information, debug, and trace\n"
|
||||
" messages. This option is intended for debugging\n"
|
||||
"-h, --help Print this help, then exit\n";
|
||||
|
||||
static const char copyright_str[] = "Copyright IBM Corp. 2001, 2018";
|
||||
|
||||
@@ -61,24 +82,26 @@ const char *OPTS_SELECT_ALL = "all";
|
||||
/*
|
||||
* Initialize default settings
|
||||
*/
|
||||
static void init_defaults(void)
|
||||
static void init_defaults(struct options *opts)
|
||||
{
|
||||
g.prog_name = "zgetdump";
|
||||
g.opts.action = ZG_ACTION_STDOUT;
|
||||
opts->prog_name = "zgetdump";
|
||||
opts->action = ZG_ACTION_COPY;
|
||||
#ifdef __s390x__
|
||||
g.opts.fmt = "elf";
|
||||
opts->fmt = "elf";
|
||||
#else
|
||||
g.opts.fmt = "s390";
|
||||
opts->fmt = "s390";
|
||||
#endif
|
||||
dfo_set(g.opts.fmt);
|
||||
/* Verbose logging */
|
||||
opts->verbose = UTIL_LOG_ERROR;
|
||||
util_log_set_level(opts->verbose);
|
||||
}
|
||||
|
||||
/*
|
||||
* Print "help" hint
|
||||
*/
|
||||
static void __noreturn print_usage_exit(void)
|
||||
static void __noreturn print_usage_exit(const char *prog_name)
|
||||
{
|
||||
STDERR("Try '%s --help' for more information.\n", g.prog_name);
|
||||
STDERR("Try '%s --help' for more information.\n", prog_name);
|
||||
zg_exit(1);
|
||||
}
|
||||
|
||||
@@ -94,10 +117,10 @@ static void __noreturn print_help_exit(void)
|
||||
/*
|
||||
* Print version information
|
||||
*/
|
||||
static void __noreturn print_version_exit(void)
|
||||
static void __noreturn print_version_exit(const char *prog_name)
|
||||
{
|
||||
STDOUT("%s: Tool for copying and converting dumps version %s\n",
|
||||
g.prog_name, RELEASE_STRING);
|
||||
prog_name, RELEASE_STRING);
|
||||
STDOUT("%s\n", copyright_str);
|
||||
zg_exit(0);
|
||||
}
|
||||
@@ -105,96 +128,94 @@ static void __noreturn print_version_exit(void)
|
||||
/*
|
||||
* Set "--fmt" option
|
||||
*/
|
||||
static void fmt_set(const char *fmt)
|
||||
static void fmt_set(struct options *opts, const char *fmt)
|
||||
{
|
||||
if (dfo_set(fmt) != 0)
|
||||
ERR_EXIT("Invalid target format \"%s\" specified", fmt);
|
||||
g.opts.fmt_specified = 1;
|
||||
g.opts.fmt = fmt;
|
||||
opts->fmt_specified = 1;
|
||||
opts->fmt = fmt;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set "--select" option
|
||||
*/
|
||||
static void select_set(const char *select)
|
||||
static void select_set(struct options *opts, const char *select)
|
||||
{
|
||||
if (strcmp(select, OPTS_SELECT_KDUMP) == 0)
|
||||
g.opts.select = OPTS_SELECT_KDUMP;
|
||||
opts->select = OPTS_SELECT_KDUMP;
|
||||
else if (strcmp(select, OPTS_SELECT_PROD) == 0)
|
||||
g.opts.select = OPTS_SELECT_PROD;
|
||||
opts->select = OPTS_SELECT_PROD;
|
||||
else if (strcmp(select, OPTS_SELECT_ALL) == 0)
|
||||
g.opts.select = OPTS_SELECT_ALL;
|
||||
opts->select = OPTS_SELECT_ALL;
|
||||
else
|
||||
ERR_EXIT("Invalid select argument \"%s\" specified", select);
|
||||
g.opts.select_specified = 1;
|
||||
opts->select_specified = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set mount point
|
||||
*/
|
||||
static void mount_point_set(const char *mount_point)
|
||||
static void mount_point_set(struct options *opts, const char *mount_point)
|
||||
{
|
||||
g.opts.mount_point = zg_strdup(mount_point);
|
||||
opts->mount_point = zg_strdup(mount_point);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set device
|
||||
*/
|
||||
static void device_set(const char *path)
|
||||
static void device_set(struct options *opts, const char *path)
|
||||
{
|
||||
g.opts.device = zg_strdup(path);
|
||||
opts->device = zg_strdup(path);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set FUSE debug options
|
||||
*/
|
||||
static void argv_fuse_set(char **argv, int argc)
|
||||
static void argv_fuse_set(struct options *opts, char **argv, int argc)
|
||||
{
|
||||
int i;
|
||||
|
||||
g.opts.argv_fuse = argv;
|
||||
g.opts.argc_fuse = argc;
|
||||
opts->argv_fuse = argv;
|
||||
opts->argc_fuse = argc;
|
||||
|
||||
STDERR_PR("Fuse Options: ");
|
||||
for (i = 0; i < argc; i++)
|
||||
STDERR("%s ", g.opts.argv_fuse[i]);
|
||||
STDERR("%s ", opts->argv_fuse[i]);
|
||||
STDERR("\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Set action
|
||||
*/
|
||||
static void action_set(enum zg_action action)
|
||||
static void action_set(struct options *opts, enum zg_action action)
|
||||
{
|
||||
if (g.opts.action_specified)
|
||||
if (opts->action_specified)
|
||||
ERR_EXIT("Please specify only one of the \"-i\", \"-d\", "
|
||||
"\"-m\" or \"-u\" option");
|
||||
g.opts.action = action;
|
||||
g.opts.action_specified = 1;
|
||||
opts->action = action;
|
||||
opts->action_specified = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify option combinations
|
||||
*/
|
||||
static void verify_opts(void)
|
||||
static void verify_opts(struct options *opts)
|
||||
{
|
||||
if (g.opts.select_specified) {
|
||||
if (g.opts.action != ZG_ACTION_MOUNT &&
|
||||
g.opts.action != ZG_ACTION_STDOUT &&
|
||||
g.opts.action != ZG_ACTION_DUMP_INFO)
|
||||
if (opts->select_specified) {
|
||||
if (opts->action != ZG_ACTION_MOUNT &&
|
||||
opts->action != ZG_ACTION_COPY &&
|
||||
opts->action != ZG_ACTION_DUMP_INFO)
|
||||
ERR_EXIT("The \"--select\" option can only be "
|
||||
"specified for info, mount, or copy");
|
||||
}
|
||||
if (!g.opts.fmt_specified)
|
||||
if (!opts->fmt_specified)
|
||||
return;
|
||||
|
||||
if (g.opts.action == ZG_ACTION_DUMP_INFO)
|
||||
if (opts->action == ZG_ACTION_DUMP_INFO)
|
||||
ERR_EXIT("The \"--fmt\" option cannot be specified "
|
||||
"together with \"--info\"");
|
||||
if (g.opts.action == ZG_ACTION_DEVICE_INFO)
|
||||
if (opts->action == ZG_ACTION_DEVICE_INFO)
|
||||
ERR_EXIT("The \"--fmt\" option cannot be specified "
|
||||
"together with \"--device\"");
|
||||
if (g.opts.action == ZG_ACTION_UMOUNT)
|
||||
if (opts->action == ZG_ACTION_UMOUNT)
|
||||
ERR_EXIT("The \"--fmt\" option cannot be specified "
|
||||
"together with \"--umount\"");
|
||||
}
|
||||
@@ -202,36 +223,38 @@ static void verify_opts(void)
|
||||
/*
|
||||
* Parse positional arguments
|
||||
*/
|
||||
static void parse_pos_args(char *argv[], int argc)
|
||||
static void parse_pos_args(struct options *opts, char *argv[], int argc)
|
||||
{
|
||||
int pos_args = argc - optind;
|
||||
|
||||
switch (g.opts.action) {
|
||||
case ZG_ACTION_STDOUT:
|
||||
switch (opts->action) {
|
||||
case ZG_ACTION_COPY:
|
||||
case ZG_ACTION_DUMP_INFO:
|
||||
case ZG_ACTION_DEVICE_INFO:
|
||||
if (pos_args == 0)
|
||||
ERR_EXIT("No device or dump specified");
|
||||
if (pos_args > 1 && !g.opts.debug_specified)
|
||||
if (pos_args > 1)
|
||||
ERR_EXIT("Too many positional parameters specified");
|
||||
device_set(argv[optind]);
|
||||
device_set(opts, argv[optind]);
|
||||
break;
|
||||
case ZG_ACTION_MOUNT:
|
||||
if (pos_args == 0)
|
||||
ERR_EXIT("No dump specified");
|
||||
if (pos_args == 1)
|
||||
ERR_EXIT("No mount point specified");
|
||||
if (pos_args > 2 && !g.opts.debug_specified)
|
||||
if (pos_args > 2 && !opts->debug_specified)
|
||||
ERR_EXIT("Too many positional parameters specified");
|
||||
device_set(argv[optind]);
|
||||
mount_point_set(argv[optind + 1]);
|
||||
if (g.opts.debug_specified && pos_args > 2)
|
||||
argv_fuse_set(&argv[optind + 2], pos_args - 2);
|
||||
device_set(opts, argv[optind]);
|
||||
mount_point_set(opts, argv[optind + 1]);
|
||||
if (opts->debug_specified && pos_args > 2)
|
||||
argv_fuse_set(opts, &argv[optind + 2], pos_args - 2);
|
||||
break;
|
||||
case ZG_ACTION_UMOUNT:
|
||||
if (pos_args == 0)
|
||||
ERR_EXIT("No mount point specified");
|
||||
mount_point_set(argv[optind]);
|
||||
if (pos_args > 1)
|
||||
ERR_EXIT("Too many positional parameters specified");
|
||||
mount_point_set(opts, argv[optind]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -239,59 +262,46 @@ static void parse_pos_args(char *argv[], int argc)
|
||||
/*
|
||||
* Main command line parsing function
|
||||
*/
|
||||
void opts_parse(int argc, char *argv[])
|
||||
void opts_parse(int argc, char *argv[], struct options *opts)
|
||||
{
|
||||
int opt, idx;
|
||||
static struct option long_opts[] = {
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{"version", no_argument, NULL, 'v'},
|
||||
{"info", no_argument, NULL, 'i'},
|
||||
{"device", no_argument, NULL, 'd'},
|
||||
{"mount", no_argument, NULL, 'm'},
|
||||
{"umount", no_argument, NULL, 'u'},
|
||||
{"fmt", required_argument, NULL, 'f'},
|
||||
{"select", required_argument, NULL, 's'},
|
||||
{"debug", no_argument, NULL, 'X'},
|
||||
{"verbose", no_argument, NULL, 'V'},
|
||||
{NULL, 0, NULL, 0 }
|
||||
};
|
||||
static const char optstr[] = "hvVidmus:f:X";
|
||||
|
||||
init_defaults();
|
||||
init_defaults(opts);
|
||||
while ((opt = getopt_long(argc, argv, optstr, long_opts, &idx)) != -1) {
|
||||
switch (opt) {
|
||||
case 'h':
|
||||
print_help_exit();
|
||||
case 'v':
|
||||
print_version_exit();
|
||||
print_version_exit(opts->prog_name);
|
||||
case 'V':
|
||||
g.opts.verbose_specified = 1;
|
||||
opts->verbose++;
|
||||
util_log_set_level(opts->verbose);
|
||||
break;
|
||||
case 'i':
|
||||
action_set(ZG_ACTION_DUMP_INFO);
|
||||
action_set(opts, ZG_ACTION_DUMP_INFO);
|
||||
break;
|
||||
case 'd':
|
||||
action_set(ZG_ACTION_DEVICE_INFO);
|
||||
action_set(opts, ZG_ACTION_DEVICE_INFO);
|
||||
break;
|
||||
case 'm':
|
||||
action_set(ZG_ACTION_MOUNT);
|
||||
action_set(opts, ZG_ACTION_MOUNT);
|
||||
break;
|
||||
case 'u':
|
||||
action_set(ZG_ACTION_UMOUNT);
|
||||
action_set(opts, ZG_ACTION_UMOUNT);
|
||||
break;
|
||||
case 'f':
|
||||
fmt_set(optarg);
|
||||
fmt_set(opts, optarg);
|
||||
break;
|
||||
case 's':
|
||||
select_set(optarg);
|
||||
select_set(opts, optarg);
|
||||
break;
|
||||
case 'X':
|
||||
g.opts.debug_specified = 1;
|
||||
opts->debug_specified = 1;
|
||||
break;
|
||||
default:
|
||||
print_usage_exit();
|
||||
print_usage_exit(opts->prog_name);
|
||||
}
|
||||
}
|
||||
parse_pos_args(argv, argc);
|
||||
verify_opts();
|
||||
parse_pos_args(opts, argv, argc);
|
||||
verify_opts(opts);
|
||||
}
|
||||
|
||||
38
zdump/opts.h
Normal file
38
zdump/opts.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright IBM Corp. 2001, 2018
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef OPTS_H
|
||||
#define OPTS_H
|
||||
|
||||
#include "zg.h"
|
||||
|
||||
/*
|
||||
* zgetdump options
|
||||
*/
|
||||
struct options {
|
||||
const char *prog_name;
|
||||
int action_specified;
|
||||
enum zg_action action;
|
||||
char *device;
|
||||
char *mount_point;
|
||||
int fmt_specified;
|
||||
const char *fmt;
|
||||
int debug_specified;
|
||||
char **argv_fuse;
|
||||
int argc_fuse;
|
||||
const char *select;
|
||||
int select_specified;
|
||||
int verbose;
|
||||
};
|
||||
|
||||
extern const char *OPTS_SELECT_KDUMP;
|
||||
extern const char *OPTS_SELECT_PROD;
|
||||
extern const char *OPTS_SELECT_ALL;
|
||||
|
||||
void opts_parse(int argc, char *argv[], struct options *opts);
|
||||
|
||||
#endif /* OPTS_H */
|
||||
@@ -9,13 +9,16 @@
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#include "zgetdump.h"
|
||||
#include "zg.h"
|
||||
#include "dfi.h"
|
||||
#include "dfo.h"
|
||||
#include "stdout.h"
|
||||
|
||||
int stdout_write_dump(void)
|
||||
{
|
||||
u64 cnt, written = 0;
|
||||
char buf[32768];
|
||||
ssize_t rc;
|
||||
const u64 output_size = dfo_size();
|
||||
char buf[8UL * PAGE_SIZE];
|
||||
u64 written = 0;
|
||||
|
||||
if (!dfi_feat_copy())
|
||||
ERR_EXIT("Copying not possible for %s dumps", dfi_name());
|
||||
@@ -23,8 +26,11 @@ int stdout_write_dump(void)
|
||||
STDERR(" Source: %s\n", dfi_name());
|
||||
STDERR(" Target: %s\n", dfo_name());
|
||||
STDERR("\n");
|
||||
zg_progress_init("Copying dump", dfo_size());
|
||||
do {
|
||||
zg_progress_init("Copying dump", output_size);
|
||||
while (written != output_size) {
|
||||
ssize_t rc;
|
||||
u64 cnt;
|
||||
|
||||
cnt = dfo_read(buf, sizeof(buf));
|
||||
rc = write(STDOUT_FILENO, buf, cnt);
|
||||
if (rc == -1)
|
||||
@@ -33,7 +39,7 @@ int stdout_write_dump(void)
|
||||
ERR_EXIT("Error: Could not write full block");
|
||||
written += cnt;
|
||||
zg_progress(written);
|
||||
} while (written != dfo_size());
|
||||
};
|
||||
STDERR("\n");
|
||||
STDERR("Success: Dump has been copied\n");
|
||||
return 0;
|
||||
|
||||
13
zdump/stdout.h
Normal file
13
zdump/stdout.h
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright IBM Corp. 2001, 2018
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef STDOUT_H
|
||||
#define STDOUT_H
|
||||
|
||||
int stdout_write_dump(void);
|
||||
|
||||
#endif /* STDOUT_H */
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <fuse.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
@@ -23,6 +24,10 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "zgetdump.h"
|
||||
#include "zg.h"
|
||||
#include "dfi.h"
|
||||
#include "dfo.h"
|
||||
#include "zfuse.h"
|
||||
|
||||
#define DUMP_PATH_MAX 100
|
||||
|
||||
|
||||
25
zdump/zfuse.h
Normal file
25
zdump/zfuse.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright IBM Corp. 2001, 2018
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef ZFUSE_H
|
||||
#define ZFUSE_H
|
||||
|
||||
#if HAVE_FUSE == 0
|
||||
static inline int zfuse_mount_dump(void)
|
||||
{
|
||||
ERR_EXIT("Program compiled without fuse support");
|
||||
}
|
||||
static inline void zfuse_umount(void)
|
||||
{
|
||||
ERR_EXIT("Program compiled without fuse support");
|
||||
}
|
||||
#else
|
||||
int zfuse_mount_dump(void);
|
||||
void zfuse_umount(void);
|
||||
#endif
|
||||
|
||||
#endif /* ZFUSE_H */
|
||||
@@ -188,7 +188,7 @@ extern enum zg_type zg_type(struct zg_fh *zg_fh);
|
||||
* zgetdump actions
|
||||
*/
|
||||
enum zg_action {
|
||||
ZG_ACTION_STDOUT,
|
||||
ZG_ACTION_COPY,
|
||||
ZG_ACTION_DUMP_INFO,
|
||||
ZG_ACTION_DEVICE_INFO,
|
||||
ZG_ACTION_MOUNT,
|
||||
|
||||
@@ -27,6 +27,11 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "zgetdump.h"
|
||||
#include "dt.h"
|
||||
#include "dfi.h"
|
||||
#include "dfo.h"
|
||||
#include "stdout.h"
|
||||
#include "zfuse.h"
|
||||
|
||||
/*
|
||||
* Globals
|
||||
@@ -49,7 +54,7 @@ static void sig_exit(int sig)
|
||||
*/
|
||||
static void sig_handler_init(void)
|
||||
{
|
||||
struct sigaction sigact;
|
||||
struct sigaction sigact = { 0 };
|
||||
|
||||
/* Ignore signals SIGUSR1 and SIGUSR2 */
|
||||
if (sigemptyset(&sigact.sa_mask) < 0)
|
||||
@@ -154,7 +159,7 @@ static int do_mount(void)
|
||||
/*
|
||||
* Run "copy to stdout" action
|
||||
*/
|
||||
static int do_stdout(void)
|
||||
static int do_copy(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
@@ -173,11 +178,14 @@ static int do_stdout(void)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
sig_handler_init();
|
||||
opts_parse(argc, argv);
|
||||
opts_parse(argc, argv, &g.opts);
|
||||
|
||||
if (dfo_set(g.opts.fmt) != 0)
|
||||
ERR_EXIT("Invalid target format \"%s\" specified", g.opts.fmt);
|
||||
|
||||
switch (g.opts.action) {
|
||||
case ZG_ACTION_STDOUT:
|
||||
return do_stdout();
|
||||
case ZG_ACTION_COPY:
|
||||
return do_copy();
|
||||
case ZG_ACTION_DUMP_INFO:
|
||||
return do_dump_info();
|
||||
case ZG_ACTION_DEVICE_INFO:
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
/*
|
||||
* zgetdump - Tool for copying and converting System z dumps
|
||||
*
|
||||
* Main include file - Should be included by all source files
|
||||
*
|
||||
* Copyright IBM Corp. 2001, 2018
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
@@ -12,92 +10,17 @@
|
||||
#ifndef ZGETDUMP_H
|
||||
#define ZGETDUMP_H
|
||||
|
||||
#include "df_elf.h"
|
||||
#include "df_lkcd.h"
|
||||
#include "df_s390.h"
|
||||
#include "dfi.h"
|
||||
#include "dfo.h"
|
||||
#include "dt.h"
|
||||
#include "zg.h"
|
||||
|
||||
/*
|
||||
* zgetdump options
|
||||
*/
|
||||
struct options {
|
||||
int action_specified;
|
||||
enum zg_action action;
|
||||
char *device;
|
||||
char *mount_point;
|
||||
int fmt_specified;
|
||||
const char *fmt;
|
||||
int debug_specified;
|
||||
char **argv_fuse;
|
||||
int argc_fuse;
|
||||
const char *select;
|
||||
int select_specified;
|
||||
int verbose_specified;
|
||||
};
|
||||
|
||||
extern const char *OPTS_SELECT_KDUMP;
|
||||
extern const char *OPTS_SELECT_PROD;
|
||||
extern const char *OPTS_SELECT_ALL;
|
||||
#include "opts.h"
|
||||
|
||||
/*
|
||||
* zgetdump globals
|
||||
*/
|
||||
extern struct zgetdump_globals {
|
||||
struct zgetdump_globals {
|
||||
struct zg_fh *fh;
|
||||
const char *prog_name;
|
||||
struct options opts;
|
||||
} g;
|
||||
};
|
||||
|
||||
/*
|
||||
* Misc fuctions
|
||||
*/
|
||||
extern void opts_parse(int argc, char *argv[]);
|
||||
extern int stdout_write_dump(void);
|
||||
|
||||
#if HAVE_FUSE == 0
|
||||
static inline int zfuse_mount_dump(void)
|
||||
{
|
||||
ERR_EXIT("Program compiled without fuse support");
|
||||
}
|
||||
static inline void zfuse_umount(void)
|
||||
{
|
||||
ERR_EXIT("Program compiled without fuse support");
|
||||
}
|
||||
#else
|
||||
int zfuse_mount_dump(void);
|
||||
void zfuse_umount(void);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Supported DFI dump formats
|
||||
*/
|
||||
extern struct dfi dfi_s390tape;
|
||||
extern struct dfi dfi_s390mv;
|
||||
extern struct dfi dfi_s390mv_ext;
|
||||
extern struct dfi dfi_s390;
|
||||
extern struct dfi dfi_s390_ext;
|
||||
extern struct dfi dfi_lkcd;
|
||||
extern struct dfi dfi_elf;
|
||||
extern struct dfi dfi_kdump;
|
||||
extern struct dfi dfi_kdump_flat;
|
||||
extern struct dfi dfi_devmem;
|
||||
|
||||
/*
|
||||
* Supported DFO dump formats
|
||||
*/
|
||||
extern struct dfo dfo_s390;
|
||||
extern struct dfo dfo_elf;
|
||||
|
||||
/*
|
||||
* Supported s390 dumpers
|
||||
*/
|
||||
extern struct dt dt_s390mv;
|
||||
extern struct dt dt_s390mv_ext;
|
||||
extern struct dt dt_s390sv;
|
||||
extern struct dt dt_s390sv_ext;
|
||||
extern struct dt dt_scsi;
|
||||
extern struct zgetdump_globals g;
|
||||
|
||||
#endif /* ZGETDUMP_H */
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Utility classes to print framsets
|
||||
*
|
||||
* Copyright IBM Corp. 2008, 2017
|
||||
* Copyright IBM Corp. 2008, 2021
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
@@ -478,21 +478,22 @@ void VirtAdapterPrinter::print_failures(FILE *fp, const struct ioerr_cnt *cnt)
|
||||
}
|
||||
|
||||
void VirtAdapterPrinter::print_throughput(FILE *fp,
|
||||
const struct blkiomon_stat *stat)
|
||||
const struct blkiomon_stat *stat,
|
||||
const __u64 interval)
|
||||
{
|
||||
double tmp;
|
||||
|
||||
if (!stat || stat->d2c_r.num <= 0 || stat->size_r.num <= 0)
|
||||
if (!stat || interval == 0 || stat->size_r.num <= 0)
|
||||
tmp = 0;
|
||||
else
|
||||
tmp = stat->size_r.sum/(double)stat->d2c_r.sum;
|
||||
tmp = calc_avg(stat->size_r.sum, interval);
|
||||
print_delimiter(fp);
|
||||
print_abbrev_num(fp, tmp);
|
||||
|
||||
if (!stat || stat->d2c_w.num <= 0 || stat->size_w.num <= 0)
|
||||
if (!stat || interval == 0 || stat->size_w.num <= 0)
|
||||
tmp = 0;
|
||||
else
|
||||
tmp = stat->size_w.sum/(double)stat->d2c_w.sum;
|
||||
tmp = calc_avg(stat->size_w.sum, interval);
|
||||
print_delimiter(fp);
|
||||
print_abbrev_num(fp, tmp);
|
||||
}
|
||||
@@ -536,6 +537,12 @@ int VirtAdapterPrinter::print_frame(FILE *fp,
|
||||
const struct blkiomon_stat *blk_stat;
|
||||
const struct zfcpdd_dstat *zfcp_stat;
|
||||
|
||||
/**
|
||||
* Receive Frameset interval and convert it
|
||||
* from seconds to microseconds
|
||||
*/
|
||||
__u64 interval = frameset.get_duration() * 1000000;
|
||||
|
||||
list<__u32> devnos;
|
||||
devnos = ((StagedDeviceFilter*)&dev_filt)->get_filter_devnos();
|
||||
|
||||
@@ -557,7 +564,7 @@ int VirtAdapterPrinter::print_frame(FILE *fp,
|
||||
print_queue_fill(fp, zfcp_stat, util);
|
||||
print_queue_full(fp, util);
|
||||
print_failures(fp, ioerr);
|
||||
print_throughput(fp, blk_stat);
|
||||
print_throughput(fp, blk_stat, interval);
|
||||
print_num_requests(fp, blk_stat);
|
||||
if (lrc) {
|
||||
fprintf(stderr, "%s: Did not find matching data in"
|
||||
@@ -810,6 +817,12 @@ int TrafficPrinter::print_frame(FILE *fp, const Frameset &frameset,
|
||||
const struct zfcpdd_dstat *zfcp_stat = NULL;
|
||||
const AggregationCollapser *agg_col;
|
||||
|
||||
/**
|
||||
* Receive Frameset interval and convert it
|
||||
* from seconds to microseconds
|
||||
*/
|
||||
__u64 interval = frameset.get_duration() * 1000000;
|
||||
|
||||
switch (m_agg_crit) {
|
||||
case none:
|
||||
get_device_list(lst_32, dev_filt);
|
||||
@@ -847,7 +860,7 @@ int TrafficPrinter::print_frame(FILE *fp, const Frameset &frameset,
|
||||
blk_stat = frameset.get_blkiomon_stat_by_wwpn(*i);
|
||||
zfcp_stat = frameset.get_zfcpdd_stat_by_wwpn(*i);
|
||||
print_device_wwpn(fp, *i);
|
||||
print_data_row(fp, blk_stat, zfcp_stat);
|
||||
print_data_row(fp, blk_stat, zfcp_stat, interval);
|
||||
}
|
||||
}
|
||||
else if (m_agg_crit == all) {
|
||||
@@ -856,7 +869,7 @@ int TrafficPrinter::print_frame(FILE *fp, const Frameset &frameset,
|
||||
blk_stat = frameset.get_first_blkiomon_stat();
|
||||
zfcp_stat = frameset.get_first_zfcpdd_stat();
|
||||
print_device_all(fp);
|
||||
print_data_row(fp, blk_stat, zfcp_stat);
|
||||
print_data_row(fp, blk_stat, zfcp_stat, interval);
|
||||
}
|
||||
else {
|
||||
for (list<__u32>::const_iterator i = lst_32.begin();
|
||||
@@ -894,7 +907,7 @@ int TrafficPrinter::print_frame(FILE *fp, const Frameset &frameset,
|
||||
}
|
||||
if (rc )
|
||||
return -1;
|
||||
print_data_row(fp, blk_stat, zfcp_stat);
|
||||
print_data_row(fp, blk_stat, zfcp_stat, interval);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -930,7 +943,8 @@ void SummaryTrafficPrinter::print_topline(FILE *fp)
|
||||
}
|
||||
|
||||
|
||||
void SummaryTrafficPrinter::print_throughput(FILE *fp, const struct blkiomon_stat *stat)
|
||||
void SummaryTrafficPrinter::print_throughput(FILE *fp, const struct blkiomon_stat *stat,
|
||||
const __u64 interval)
|
||||
{
|
||||
struct minmax thrp_data, total_size, total_latency;
|
||||
double tmp;
|
||||
@@ -968,7 +982,7 @@ void SummaryTrafficPrinter::print_throughput(FILE *fp, const struct blkiomon_sta
|
||||
|
||||
tmp = 0;
|
||||
if (stat && total_size.sum > 0)
|
||||
tmp = calc_avg(total_size.sum, total_latency.sum);
|
||||
tmp = calc_avg(total_size.sum, interval);
|
||||
print_delimiter(fp);
|
||||
print_abbrev_num(fp, tmp);
|
||||
|
||||
@@ -1101,14 +1115,15 @@ void SummaryTrafficPrinter::print_fabric_latency(FILE *fp, const struct zfcpdd_d
|
||||
|
||||
void SummaryTrafficPrinter::print_data_row(FILE *fp,
|
||||
const struct blkiomon_stat *blk_stat,
|
||||
const struct zfcpdd_dstat *zfcp_stat)
|
||||
const struct zfcpdd_dstat *zfcp_stat,
|
||||
const __u64 interval)
|
||||
{
|
||||
if (!blk_stat)
|
||||
blk_stat = get_empty_blkiomon_stat();
|
||||
if (!zfcp_stat)
|
||||
zfcp_stat = get_empty_zfcpdd_dstat();
|
||||
|
||||
print_throughput(fp, blk_stat);
|
||||
print_throughput(fp, blk_stat, interval);
|
||||
print_request_stats(fp, blk_stat);
|
||||
print_io_subsystem_latency(fp, blk_stat);
|
||||
print_channel_latency(fp, zfcp_stat);
|
||||
@@ -1177,7 +1192,8 @@ void DetailedTrafficPrinter::print_topline(FILE *fp)
|
||||
|
||||
void DetailedTrafficPrinter::print_data_row(FILE *fp,
|
||||
const struct blkiomon_stat *blk_stat,
|
||||
const struct zfcpdd_dstat *zfcp_stat)
|
||||
const struct zfcpdd_dstat *zfcp_stat,
|
||||
const __u64 interval __attribute__ ((unused)))
|
||||
{
|
||||
if (!blk_stat)
|
||||
blk_stat = get_empty_blkiomon_stat();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Utility classes to print framsets
|
||||
*
|
||||
* Copyright IBM Corp. 2008, 2017
|
||||
* Copyright IBM Corp. 2008, 2021
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
@@ -128,7 +128,8 @@ private:
|
||||
const struct adapter_utilization *res);
|
||||
void print_queue_full(FILE *fp, const struct adapter_utilization *res);
|
||||
void print_failures(FILE *fp, const struct ioerr_cnt *cnt);
|
||||
void print_throughput(FILE *fp, const struct blkiomon_stat *stat);
|
||||
void print_throughput(FILE *fp, const struct blkiomon_stat *stat,
|
||||
const __u64 interval);
|
||||
void print_num_requests(FILE *fp, const struct blkiomon_stat *stat);
|
||||
};
|
||||
|
||||
@@ -147,7 +148,8 @@ protected:
|
||||
* Print the actual row, excluding the first column */
|
||||
virtual void print_data_row(FILE *fp,
|
||||
const struct blkiomon_stat *blk_stat,
|
||||
const struct zfcpdd_dstat *zfcp_stat) = 0;
|
||||
const struct zfcpdd_dstat *zfcp_stat,
|
||||
const __u64 interval) = 0;
|
||||
|
||||
void print_topline_prefix1(FILE *fp);
|
||||
void print_topline_prefix2(FILE *fp);
|
||||
@@ -185,8 +187,10 @@ public:
|
||||
private:
|
||||
virtual void print_data_row(FILE *fp,
|
||||
const struct blkiomon_stat *blk_stat,
|
||||
const struct zfcpdd_dstat *zfcp_stat);
|
||||
void print_throughput(FILE *fp, const struct blkiomon_stat *stat);
|
||||
const struct zfcpdd_dstat *zfcp_stat,
|
||||
const __u64 interval);
|
||||
void print_throughput(FILE *fp, const struct blkiomon_stat *stat,
|
||||
const __u64 interval);
|
||||
void print_request_stats(FILE *fp, const struct blkiomon_stat *stat);
|
||||
void print_io_subsystem_latency(FILE *fp, const struct blkiomon_stat *stat);
|
||||
void print_channel_latency(FILE *fp, const struct zfcpdd_dstat *stat);
|
||||
@@ -207,7 +211,8 @@ public:
|
||||
private:
|
||||
virtual void print_data_row(FILE *fp,
|
||||
const struct blkiomon_stat *blk_stat,
|
||||
const struct zfcpdd_dstat *zfcp_stat);
|
||||
const struct zfcpdd_dstat *zfcp_stat,
|
||||
const __u64 interval);
|
||||
void print_histogram_io_reqs(FILE *fp,
|
||||
const struct blkiomon_stat *stat);
|
||||
void print_histogram_io_subs_lat(FILE *fp,
|
||||
|
||||
@@ -130,6 +130,37 @@ int strncmp(const char *s1, const char *s2, unsigned long count)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the first occurrence of character in string.
|
||||
* STR: address of the string, which is different from NULL!
|
||||
*/
|
||||
char *strchr(const char *str, char c)
|
||||
{
|
||||
while (*str) {
|
||||
if (*str == c)
|
||||
return (char *)str;
|
||||
str++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Minimalistic hash function on strings.
|
||||
* It doesn't provide perfect quality of distribution.
|
||||
*
|
||||
* STR: null-terminated string
|
||||
* HASH_SIZE: number of buckets
|
||||
*/
|
||||
unsigned int strhash(unsigned char *str, unsigned int hash_size)
|
||||
{
|
||||
unsigned int sum = 0;
|
||||
|
||||
while (*str)
|
||||
sum += 5 * *(str++);
|
||||
|
||||
return sum % hash_size;
|
||||
}
|
||||
|
||||
static int skip_atoi(const char **c)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
@@ -54,6 +54,8 @@ char *strcat(char *, const char *);
|
||||
int strncmp(const char *, const char *, unsigned long);
|
||||
int strlen(const char *);
|
||||
char *strcpy(char *, const char *);
|
||||
char *strchr(const char *str, char c);
|
||||
unsigned int strhash(unsigned char *str, unsigned int hash_size);
|
||||
unsigned long get_zeroed_page(void);
|
||||
void free_page(unsigned long);
|
||||
void initialize(void);
|
||||
|
||||
@@ -143,12 +143,13 @@ int menu(void)
|
||||
int rc;
|
||||
|
||||
cmd_line_extra = (char *)COMMAND_LINE_EXTRA;
|
||||
memset(cmd_line_extra, 0, COMMAND_LINE_EXTRA_SIZE);
|
||||
|
||||
rc = sclp_setup(SCLP_INIT);
|
||||
if (rc)
|
||||
/* sclp setup failed boot default */
|
||||
goto boot;
|
||||
|
||||
memset(cmd_line_extra, 0, COMMAND_LINE_SIZE);
|
||||
rc = menu_param(&value);
|
||||
if (rc == 0) {
|
||||
/* got number from loadparm, boot it */
|
||||
|
||||
@@ -131,6 +131,205 @@ secure_boot_enabled()
|
||||
return rc;
|
||||
}
|
||||
|
||||
#define ZIPL_ENVBLK_SIGNATURE "# zIPL Environment Block\n"
|
||||
#define STR_HASH_SIZE (16)
|
||||
|
||||
struct env_hash_entry {
|
||||
unsigned int next;
|
||||
unsigned int name;
|
||||
};
|
||||
|
||||
/**
|
||||
* ITEMS: pointer to pre-allocated page, where the new item will be allocated
|
||||
* NAME: null-terminated name
|
||||
*/
|
||||
static void hash_table_add(struct env_hash_entry *items,
|
||||
struct env_hash_entry **buckets,
|
||||
unsigned int *new_idx,
|
||||
unsigned long name)
|
||||
{
|
||||
struct env_hash_entry *new;
|
||||
unsigned int hash;
|
||||
|
||||
new = &items[*new_idx];
|
||||
new->name = name;
|
||||
hash = strhash((unsigned char *)name, STR_HASH_SIZE);
|
||||
new->next = (unsigned long)buckets[hash];
|
||||
buckets[hash] = new;
|
||||
(*new_idx)++;
|
||||
}
|
||||
|
||||
struct env_hash_entry *hash_table_find(struct env_hash_entry **buckets,
|
||||
char *name)
|
||||
{
|
||||
struct env_hash_entry *item;
|
||||
|
||||
if (strlen(name) == 0)
|
||||
return NULL;
|
||||
item = buckets[strhash((unsigned char *)name, STR_HASH_SIZE)];
|
||||
while (item) {
|
||||
if (strlen((char *)(unsigned long)item->name) ==
|
||||
strlen(name) &&
|
||||
!strncmp((char *)(unsigned long)item->name,
|
||||
name, strlen(name)))
|
||||
return item;
|
||||
item = (struct env_hash_entry *)(unsigned long)item->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format of environment block:
|
||||
*
|
||||
* magic'\n'name1=value1'\n'...nameN=valueN'\n'zero-padding
|
||||
*/
|
||||
static void parse_envblk(struct env_hash_entry *items,
|
||||
struct env_hash_entry **buckets,
|
||||
unsigned int *nr)
|
||||
{
|
||||
char sgn[] = ZIPL_ENVBLK_SIGNATURE;
|
||||
unsigned int len = 0;
|
||||
unsigned int off = 0;
|
||||
char *name;
|
||||
char *value;
|
||||
|
||||
ebcdic_to_ascii((unsigned char *)sgn,
|
||||
(unsigned char *)sgn, sizeof(sgn) - 1);
|
||||
|
||||
if (strncmp((char *)_stage3_parms.envblk_addr, sgn, sizeof(sgn) - 1)) {
|
||||
printf("Bad envblk\n");
|
||||
return;
|
||||
}
|
||||
/* we rely that environment block is consistent */
|
||||
name = (char *)_stage3_parms.envblk_addr + sizeof(sgn) - 1;
|
||||
/*
|
||||
* calculate significant length of the environment block
|
||||
* (excluding trailing zeros)
|
||||
*/
|
||||
while (len < _stage3_parms.envblk_len) {
|
||||
if (name[len] == 0)
|
||||
break;
|
||||
len++;
|
||||
}
|
||||
while (off < len) {
|
||||
value = strchr(name, 0x3D /* = */) + 1;
|
||||
/* null-terminate the name */
|
||||
*(value - 1) = 0;
|
||||
hash_table_add(items, buckets, nr, (unsigned long)name);
|
||||
off += (value - name); /* offset of the value */
|
||||
|
||||
name = strchr(value, 0x0A /* /n */) + 1;
|
||||
/* null-terminate the value */
|
||||
*(name - 1) = 0;
|
||||
off += (name - value); /* offset of the next name (if any) */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all instances of the pattern ${NAME} in the command line, and replace
|
||||
* each one with corresponding VALUE as found in the hash table by NAME
|
||||
*
|
||||
* CMDL_LEN: length of the command line to be processed
|
||||
* BUCKETS: hash table of pairs (NAME, VALUE)
|
||||
*/
|
||||
void process_parm_line(struct env_hash_entry **buckets, unsigned int cmdl_len)
|
||||
{
|
||||
struct env_hash_entry *item;
|
||||
char empty_str = 0;
|
||||
char *cmdl_end;
|
||||
char *start;
|
||||
char *end;
|
||||
char *val;
|
||||
int len;
|
||||
|
||||
start = (char *)COMMAND_LINE;
|
||||
cmdl_end = start + cmdl_len;
|
||||
|
||||
while (start < cmdl_end) {
|
||||
start = strchr(start, 0x24 /* $ */);
|
||||
|
||||
if (start == NULL || start + 3 >= cmdl_end)
|
||||
/* no more instances */
|
||||
break;
|
||||
if (*(start + 1) != 0x7B /* { */) {
|
||||
/* skip "$" without braces */
|
||||
start += 1;
|
||||
continue;
|
||||
}
|
||||
end = strchr(start, 0x7D /* } */);
|
||||
if (end == NULL || end >= cmdl_end)
|
||||
/* no more instances */
|
||||
break;
|
||||
/* terminate the NAME and find it in the hash table */
|
||||
*end = 0;
|
||||
item = hash_table_find(buckets, start + 2);
|
||||
if (!item) {
|
||||
/*
|
||||
* Item to replace with not found.
|
||||
* The case of "${}" (empty NAME) also gets here!
|
||||
*
|
||||
* Assign the empty string to remove the instance
|
||||
* from the command line
|
||||
*/
|
||||
val = &empty_str;
|
||||
} else {
|
||||
val = (char *)(unsigned long)item->name +
|
||||
strlen((char *)(unsigned long)item->name) + 1;
|
||||
}
|
||||
/*
|
||||
* try to replace the instance by VALUE as found
|
||||
* in the hash table by NAME
|
||||
*/
|
||||
len = strlen(val);
|
||||
|
||||
if (cmdl_len + len - (end - start + 1) >= COMMAND_LINE_SIZE)
|
||||
/* VALUE doesn't fit */
|
||||
break;
|
||||
/*
|
||||
* make a room with the beginning at "$" by moving
|
||||
* the rest of parm line at the right of "}" to @dst,
|
||||
* which is (offset of "$" + size of the VALUE")
|
||||
*/
|
||||
memmove(start + len, end + 1, cmdl_end - (end + 1));
|
||||
/*
|
||||
* copy VALUE to the room
|
||||
*/
|
||||
memcpy(start, val, len);
|
||||
cmdl_end += (len - (end - start + 1));
|
||||
start += len;
|
||||
}
|
||||
if (cmdl_len > cmdl_end - (char *)COMMAND_LINE)
|
||||
memset(cmdl_end, 0,
|
||||
cmdl_len - (cmdl_end - (char *)COMMAND_LINE));
|
||||
}
|
||||
|
||||
/**
|
||||
* LEN: length of the command line to be processed
|
||||
*/
|
||||
static void handle_environment(unsigned int len)
|
||||
{
|
||||
struct env_hash_entry *buckets[STR_HASH_SIZE];
|
||||
struct env_hash_entry *items;
|
||||
unsigned int nr_items = 0;
|
||||
|
||||
if (_stage3_parms.envblk_addr == 0 ||
|
||||
_stage3_parms.envblk_addr == UNSPECIFIED_ADDRESS)
|
||||
return;
|
||||
|
||||
memset(buckets, 0, sizeof(buckets));
|
||||
items = (struct env_hash_entry *)get_zeroed_page();
|
||||
/*
|
||||
* scan in-memory environment block and populate hash table
|
||||
*/
|
||||
parse_envblk(items, buckets, &nr_items);
|
||||
/*
|
||||
* find environment variables in the command line and
|
||||
* replace them with their values as found in the hash table
|
||||
*/
|
||||
process_parm_line(buckets, len);
|
||||
free_page((unsigned long)items);
|
||||
}
|
||||
|
||||
void start(void)
|
||||
{
|
||||
unsigned int subchannel_id;
|
||||
@@ -171,6 +370,9 @@ void start(void)
|
||||
/* terminate \0 */
|
||||
cmdline[COMMAND_LINE_SIZE - 1] = 0;
|
||||
}
|
||||
/* determine length of original parm line */
|
||||
cmdline_len = MIN(strlen((const char *)cmdline),
|
||||
COMMAND_LINE_SIZE - 1);
|
||||
|
||||
/* convert extra parameter to ascii */
|
||||
if (!_stage3_parms.extra_parm || !*cextra)
|
||||
@@ -187,11 +389,6 @@ void start(void)
|
||||
cextra++;
|
||||
cextra_len--;
|
||||
}
|
||||
|
||||
/* determine length of original parm line */
|
||||
cmdline_len = MIN(strlen((const char *)cmdline),
|
||||
COMMAND_LINE_SIZE - 1);
|
||||
|
||||
/*
|
||||
* if extra parm string starts with '=' replace original string,
|
||||
* else append
|
||||
@@ -214,8 +411,9 @@ void start(void)
|
||||
/* terminate 0 */
|
||||
cmdline[cmdline_len + cextra_len] = 0;
|
||||
}
|
||||
|
||||
noextra:
|
||||
handle_environment(cmdline_len + cextra_len);
|
||||
|
||||
/* copy initrd start address and size intop new kernle space */
|
||||
*(unsigned long long *)INITRD_START = _stage3_parms.initrd_addr;
|
||||
*(unsigned long long *)INITRD_SIZE = _stage3_parms.initrd_len;
|
||||
|
||||
@@ -36,8 +36,10 @@ struct stage3_parms {
|
||||
unsigned long long flags; /* flags (e.g. STAGE3_FLAG_KDUMP) */
|
||||
unsigned long long image_len; /* length of kernel */
|
||||
unsigned long long image_addr; /* target address of kernel */
|
||||
unsigned long long envblk_addr; /* address of environment block */
|
||||
unsigned long long envblk_len; /* size of environment block */
|
||||
};
|
||||
STATIC_ASSERT(sizeof(struct stage3_parms) == 8 * 8)
|
||||
STATIC_ASSERT(sizeof(struct stage3_parms) == 8 * 10)
|
||||
|
||||
extern struct stage3_parms _stage3_parms;
|
||||
extern void kdump_stage3();
|
||||
|
||||
@@ -296,7 +296,8 @@ int boot_get_eckd_stage2(void** data, size_t* size, struct job_data* job);
|
||||
int boot_get_stage3_parms(void **buffer, size_t *bytecount, address_t parm_addr,
|
||||
address_t initrd_addr, size_t initrd_len,
|
||||
address_t entry, int extra_parm, uint64_t flags,
|
||||
address_t image_addr, size_t image_len);
|
||||
address_t image_addr, size_t image_len,
|
||||
address_t envblk_addr, size_t envblk_len);
|
||||
int boot_get_tape_ipl(void** data, size_t* size, address_t parm_addr,
|
||||
address_t initrd_addr, address_t image_addr);
|
||||
int boot_get_tape_dump(void** data, size_t* size, uint64_t mem);
|
||||
|
||||
@@ -17,10 +17,20 @@
|
||||
#include "disk.h"
|
||||
#include "job.h"
|
||||
#include "zipl.h"
|
||||
#include "stddef.h"
|
||||
|
||||
#define BOOTMAP_HEADER_VERSION 1
|
||||
|
||||
#define SIGNATURE_MAGIC "~Module signature appended~\n"
|
||||
#define PKCS7_FORMAT 0x01
|
||||
|
||||
struct bootmap_header {
|
||||
char header_text[48];
|
||||
u64 version;
|
||||
u64 envblk_offset;
|
||||
char reserved[448];
|
||||
};
|
||||
|
||||
struct signature_header {
|
||||
uint8_t format;
|
||||
uint8_t reserved[3];
|
||||
@@ -50,6 +60,9 @@ struct file_signature {
|
||||
|
||||
#define PKEY_ID_PKCS7 0x02
|
||||
|
||||
int bootmap_header_init(int fd);
|
||||
int bootmap_header_read(int fd, struct bootmap_header *bh);
|
||||
int bootmap_header_write(int fd, struct bootmap_header *bh);
|
||||
int bootmap_create(struct job_data* job, disk_blockptr_t* program_table,
|
||||
disk_blockptr_t *scsi_dump_sb_blockptr,
|
||||
disk_blockptr_t** stage2_list, blocknum_t* stage2_count,
|
||||
|
||||
@@ -90,6 +90,11 @@ struct disk_info {
|
||||
definition_t targetbase;
|
||||
};
|
||||
|
||||
struct file_range {
|
||||
off_t offset;
|
||||
size_t len;
|
||||
};
|
||||
|
||||
struct job_target_data;
|
||||
|
||||
int disk_get_info(const char* device, struct job_target_data* target,
|
||||
@@ -112,16 +117,23 @@ int disk_write_block_aligned(int fd, const void* data, size_t bytecount,
|
||||
blocknum_t disk_write_block_buffer(int fd, int fd_is_basedisk,
|
||||
const void* buffer, size_t bytecount,
|
||||
disk_blockptr_t** blocklist,
|
||||
struct disk_info* info);
|
||||
struct disk_info *info);
|
||||
blocknum_t disk_write_block_buffer_align(int fd, int fd_is_basedisk,
|
||||
const void *buffer, size_t bytecount,
|
||||
disk_blockptr_t **blocklist,
|
||||
struct disk_info *info, int align,
|
||||
off_t *offset);
|
||||
void disk_print_devt(dev_t d);
|
||||
void disk_print_info(struct disk_info* info);
|
||||
int disk_is_zero_block(disk_blockptr_t* block, struct disk_info* info);
|
||||
blocknum_t disk_compact_blocklist(disk_blockptr_t* list, blocknum_t count,
|
||||
struct disk_info* info);
|
||||
blocknum_t disk_get_blocklist_from_file(const char* filename,
|
||||
struct file_range *reg,
|
||||
disk_blockptr_t** blocklist,
|
||||
struct disk_info* pinfo);
|
||||
int disk_check_subchannel_set(int devno, dev_t device, char* dev_name);
|
||||
void disk_print_geo(struct disk_info *data);
|
||||
int fs_map(int fd, uint64_t offset, blocknum_t *mapped, int fs_block_size);
|
||||
|
||||
#endif /* not DISK_H */
|
||||
|
||||
34
zipl/include/envblk.h
Normal file
34
zipl/include/envblk.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* s390-tools/zipl/include/bootmap.h
|
||||
* Functions to handle environment block.
|
||||
*
|
||||
* Copyright IBM Corp. 2020
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*
|
||||
*/
|
||||
#include "boot/s390.h" /* for PAGE_SIZE */
|
||||
|
||||
#define ZIPL_ENVBLK_SIGNATURE "# zIPL Environment Block\n"
|
||||
#define ENVBLK_DEFAULT_IMPORT_SOURCE "/etc/ziplenv"
|
||||
/*
|
||||
* The following limit can be increased. It requires modifications
|
||||
* of the code, which is responsible for handling environment in
|
||||
* stage3, which will increase its memory footprint.
|
||||
*/
|
||||
#define ENVBLK_MAX_LINES (PAGE_SIZE / 8 /* sizeof(struct env_hash_entry */)
|
||||
|
||||
#define ENVBLK_MAX_IMPORT_SIZE(envblk_size) \
|
||||
(envblk_size - sizeof(ZIPL_ENVBLK_SIGNATURE) + 1)
|
||||
|
||||
int envblk_offset_get(int fd, off_t *off);
|
||||
int envblk_offset_set(int fd, off_t off);
|
||||
int envblk_size_get(int fd, int *size);
|
||||
int envblk_check_name(char *name, int len);
|
||||
int envblk_import(char *from, char *to, int size);
|
||||
char *envblk_next_line(char *s, const char *end);
|
||||
int envblk_scan(char *envblk, unsigned int envblk_size,
|
||||
void (*actor)(char *name));
|
||||
void envblk_print(char *envblk, unsigned int envblk_size);
|
||||
void envblk_create_blank(char *envblk, int envblk_len);
|
||||
@@ -46,9 +46,15 @@ struct job_ipl_data {
|
||||
address_t image_addr;
|
||||
address_t parm_addr;
|
||||
address_t ramdisk_addr;
|
||||
address_t envblk_addr;
|
||||
int is_kdump;
|
||||
};
|
||||
|
||||
struct job_envblk_data {
|
||||
int size;
|
||||
char *buf;
|
||||
};
|
||||
|
||||
struct job_segment_data {
|
||||
char* segment;
|
||||
address_t segment_addr;
|
||||
@@ -108,6 +114,7 @@ struct job_menu_data {
|
||||
struct job_data {
|
||||
enum job_id id;
|
||||
struct job_target_data target;
|
||||
struct job_envblk_data envblk;
|
||||
char* name;
|
||||
union {
|
||||
struct job_ipl_data ipl;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include "lib/zt_common.h"
|
||||
#include "lib/util_base.h"
|
||||
#include "boot/loaders_layout.h"
|
||||
|
||||
#define ZIPL_MAGIC "zIPL"
|
||||
@@ -35,7 +36,7 @@
|
||||
#define ZIPL_DEFAULT_CONF TOOLS_SYSCONFDIR "/zipl.conf"
|
||||
#define ZIPL_MINIMAL_CONF TOOLS_LIBDIR "/zipl.conf"
|
||||
#define ZIPL_DEFAULT_BLSDIR "/boot/loader/entries"
|
||||
#define ZIPL_STAGE3_PATH TOOLS_LIBDIR "/stage3.bin"
|
||||
#define ZIPL_STAGE3_PATH util_libdir_path("stage3.bin")
|
||||
#define ZIPL_SIPL_PATH "/sys/firmware/ipl/has_secure"
|
||||
|
||||
#define MENU_DEFAULT_PROMPT 0
|
||||
|
||||
@@ -9,10 +9,14 @@ install:
|
||||
sed -e 's@%SYSCONFDIR%@$(SYSCONFDIR)@' \
|
||||
-e 's@%TOOLS_LIBDIR%@$(TOOLS_LIBDIR)@' zipl.8.in \
|
||||
> $(DESTDIR)$(MANDIR)/man8/zipl.8
|
||||
sed -e 's@%SYSCONFDIR%@$(SYSCONFDIR)@' \
|
||||
-e 's@%TOOLS_LIBDIR%@$(TOOLS_LIBDIR)@' zipl-editenv.8.in \
|
||||
> $(DESTDIR)$(MANDIR)/man8/zipl-editenv.8
|
||||
sed -e 's@%SYSCONFDIR%@$(SYSCONFDIR)@' \
|
||||
-e 's@%TOOLS_LIBDIR%@$(TOOLS_LIBDIR)@' zipl.conf.5.in \
|
||||
> $(DESTDIR)$(MANDIR)/man5/zipl.conf.5
|
||||
chmod 644 $(DESTDIR)$(MANDIR)/man8/zipl.8 \
|
||||
$(DESTDIR)$(MANDIR)/man8/zipl-editenv.8 \
|
||||
$(DESTDIR)$(MANDIR)/man5/zipl.conf.5
|
||||
|
||||
clean:
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user