mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
Compare commits
86 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f1bd3bb66 | ||
|
|
0fbc4edd29 | ||
|
|
b8a9f0d1d3 | ||
|
|
d280e5b1fa | ||
|
|
e04acab0ed | ||
|
|
d868ce5ec7 | ||
|
|
dec58c349e | ||
|
|
d82f5e1f49 | ||
|
|
156450f359 | ||
|
|
c0392efa39 | ||
|
|
3c5644ccfd | ||
|
|
3fb356ebd2 | ||
|
|
fe68ec513d | ||
|
|
a86fb8b091 | ||
|
|
f32bff9688 | ||
|
|
7d355b0fec | ||
|
|
ab4445c261 | ||
|
|
e14363373b | ||
|
|
d9ca409978 | ||
|
|
13596f18da | ||
|
|
80b66da1d8 | ||
|
|
3eb9af9c97 | ||
|
|
f093d0bfd4 | ||
|
|
6a2f4fd376 | ||
|
|
e2f92e4079 | ||
|
|
c944f23d7e | ||
|
|
5872f8a21b | ||
|
|
a090a1ffe8 | ||
|
|
5e24f74fde | ||
|
|
340da73bb7 | ||
|
|
f642019bcc | ||
|
|
7cc542352e | ||
|
|
cf99ea019e | ||
|
|
15c22ec742 | ||
|
|
45ac847dc9 | ||
|
|
4a223c70f2 | ||
|
|
26d636f234 | ||
|
|
aade05b01d | ||
|
|
c3821f0821 | ||
|
|
ac0ac48f6f | ||
|
|
54519b4465 | ||
|
|
9f2e406525 | ||
|
|
edaad2a927 | ||
|
|
262a827ab4 | ||
|
|
4b33d80595 | ||
|
|
4c401162c0 | ||
|
|
168acec5ea | ||
|
|
aab339d3e3 | ||
|
|
1f459af568 | ||
|
|
46f09a0adc | ||
|
|
f65003a14e | ||
|
|
e092b4024a | ||
|
|
9d7bab18a4 | ||
|
|
8688d47e3d | ||
|
|
04bb72c0dc | ||
|
|
1c065082d2 | ||
|
|
38642e6905 | ||
|
|
ebdf888a2f | ||
|
|
9745e4678a | ||
|
|
33a17df9fc | ||
|
|
4ff7aeff39 | ||
|
|
edb75870b5 | ||
|
|
a3c746846d | ||
|
|
4044accf03 | ||
|
|
943e7e7198 | ||
|
|
4f00cb6346 | ||
|
|
9d55086720 | ||
|
|
eaa2ef6ba4 | ||
|
|
37c3752b31 | ||
|
|
8585efadbe | ||
|
|
13648dd6f4 | ||
|
|
427dff3450 | ||
|
|
08bc0a947a | ||
|
|
c3d583fe9c | ||
|
|
983a72dab9 | ||
|
|
811152c08a | ||
|
|
6a1b9cf10a | ||
|
|
599b141b8a | ||
|
|
b9e47e356b | ||
|
|
5e2a477bbf | ||
|
|
bba34cb975 | ||
|
|
a674011c0d | ||
|
|
c78b5cd2ba | ||
|
|
f3e374ac77 | ||
|
|
1e6a9dbd56 | ||
|
|
564a2601f6 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -46,6 +46,7 @@ libutil/util_prg_example
|
||||
libutil/util_rec_example
|
||||
libutil/util_scandir_example
|
||||
libzds/libzds.a
|
||||
libvmcp/vmcp_example
|
||||
mon_tools/mon_fsstatd
|
||||
mon_tools/mon_procd
|
||||
osasnmpd/osasnmpd
|
||||
@@ -86,4 +87,5 @@ zipl/boot/*.exec
|
||||
zipl/boot/data.h
|
||||
zipl/src/chreipl_helper.device-mapper
|
||||
zipl/src/zipl
|
||||
zipl/src/zipl_helper.device-mapper
|
||||
zkey/zkey
|
||||
|
||||
@@ -14,7 +14,6 @@ List of all individuals having contributed content to s390-tools
|
||||
- Christof Schmitt
|
||||
- Claudio Imbrenda
|
||||
- Clemens von Mann
|
||||
- cvs2git
|
||||
- Dan Horak
|
||||
- Despina Papadopoulou
|
||||
- Eberhard Pasch
|
||||
@@ -22,7 +21,6 @@ List of all individuals having contributed content to s390-tools
|
||||
- Erwin Vicari
|
||||
- Eugene Crosser
|
||||
- Eugene Dvurechenski
|
||||
- Eugene (jno) Dvurechenski
|
||||
- Farhan Ali
|
||||
- Fedor Loshakov
|
||||
- Felix Beck
|
||||
@@ -47,6 +45,7 @@ List of all individuals having contributed content to s390-tools
|
||||
- Jan Glauber
|
||||
- Jan Hoeppner
|
||||
- Jan Willeke
|
||||
- Javier Martinez Canillas
|
||||
- Jean-Baptiste Joret
|
||||
- Jens Remus
|
||||
- Jochen Roehrig
|
||||
@@ -62,7 +61,6 @@ List of all individuals having contributed content to s390-tools
|
||||
- Martin Schwidefsky
|
||||
- Maxim Shchetynin
|
||||
- Melissa Howland
|
||||
- Michael
|
||||
- Michael Ernst
|
||||
- Michael Holzheu
|
||||
- Michael Mueller
|
||||
@@ -77,11 +75,9 @@ List of all individuals having contributed content to s390-tools
|
||||
- Ralph Wuerthner
|
||||
- Rene Trumpp
|
||||
- Rolf Schaefer
|
||||
- root
|
||||
- Sa Liu
|
||||
- Sascha Silbe
|
||||
- Sebastian Ott
|
||||
- Seshagiri N Ippili
|
||||
- Seshagiri N. Ippili
|
||||
- Simon Sturm
|
||||
- Stefan Bader
|
||||
@@ -101,6 +97,7 @@ List of all individuals having contributed content to s390-tools
|
||||
- Thomas Weber
|
||||
- Ursula Braun
|
||||
- Utz Bacher
|
||||
- Vasily Gorbik
|
||||
- Viktor Mihajlovski
|
||||
- Volker Sameske
|
||||
- Wolfgang Taphorn
|
||||
|
||||
34
CHANGELOG.md
34
CHANGELOG.md
@@ -1,5 +1,39 @@
|
||||
Release history for s390-tools (MIT version)
|
||||
--------------------------------------------
|
||||
* __v2.5.0 (2018-06-08)__
|
||||
|
||||
For Linux kernel version: 4.17
|
||||
|
||||
Changes of existing tools:
|
||||
- zdev: Add support for reading firmware configuration files
|
||||
- zipl: Add BootLoaderSpec support
|
||||
- scripts: Add script to switch zipl config to a BootLoaderSpec setup
|
||||
|
||||
Bug Fixes:
|
||||
- lsluns: Print a message if no adapter or port exists
|
||||
|
||||
* __v2.4.0 (2018-05-07)__
|
||||
|
||||
For Linux kernel version: 4.16
|
||||
|
||||
Changes of existing tools:
|
||||
- dbginfo: Gather nvme related data
|
||||
- zipl: Rewrite helper script in C
|
||||
- libutil: Add function util_strstrip
|
||||
- libvmcp: Introduce libvmcp
|
||||
- zipl: Extend DASD stand-alone dumpers to drop zero pages
|
||||
- zgetdump: Add verbose option
|
||||
- zgetdump: Add 'Dump file size' field for zgetdump -i output
|
||||
- cpumf: Add IBM z14 ZR1 to the CPU Measurement Facility model list
|
||||
- zkey: Add build dependency to OpenSSL (libcrypto)
|
||||
- zkey: Add keystore implementation
|
||||
|
||||
|
||||
Bug Fixes:
|
||||
- hmcdrvfs: fix parsing of link count >= 1000
|
||||
- zgetdump: Avoid Segfault on processing dumps with memory limit
|
||||
- chreipl: correct fcp reipl sysfs write sequence
|
||||
- udev: Replace WAIT_FOR with TEST keyword
|
||||
|
||||
* __v2.3.0 (2018-01-30)__
|
||||
|
||||
|
||||
2
Makefile
2
Makefile
@@ -3,7 +3,7 @@ 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 libu2s libutil libzds libdasd libvmdump libccw
|
||||
LIB_DIRS = libvtoc libu2s libutil libzds libdasd libvmdump libccw libvmcp
|
||||
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 \
|
||||
|
||||
11
README.md
11
README.md
@@ -264,12 +264,14 @@ build options:
|
||||
| pfm | `HAVE_PFM` | cpacfstats |
|
||||
| net-snmp | `HAVE_SNMP` | osasnmpd |
|
||||
| glibc-static | `HAVE_LIBC_STATIC` | zfcpdump |
|
||||
| openssl | `HAVE_OPENSSL` | zkey |
|
||||
|
||||
This table lists additional build or install options:
|
||||
|
||||
| __COMPONENT__ | __OPTION__ | __TOOLS__ |
|
||||
|----------------|:----------------:|:-------------------------------:|
|
||||
| dracut | `HAVE_DRACUT` | zdev |
|
||||
| initramfs-tools| `HAVE_INITRAMFS` | zdev |
|
||||
|
||||
The s390-tools build process uses "pkg-config" if available and hard-coded
|
||||
compiler and linker options otherwise.
|
||||
@@ -366,3 +368,12 @@ the different tools are provided:
|
||||
For running znetconf these programs are required:
|
||||
- modprobe (kmod)
|
||||
- vmcp (s390-tools)
|
||||
|
||||
* zkey:
|
||||
For building the zkey tools you need openssl version 0.9.7 or newer installed
|
||||
(openssl-devel.rpm). Tip: you may skip the zkey build by adding
|
||||
`HAVE_OPENSSL=0` to the make invocation.
|
||||
A new group 'zkeyadm' needs to be created and all users intending to use the
|
||||
tool must be added to this group. The owner of the default key repository
|
||||
'/etc/zkey/repository' must be set to group 'zkeyadm' with write permission
|
||||
for this group.
|
||||
|
||||
@@ -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 = 3
|
||||
RELEASE = 5
|
||||
PATCHLEVEL = 0
|
||||
DISTRELEASE = build-$(shell date +%Y%m%d)
|
||||
S390_TOOLS_RELEASE = $(VERSION).$(RELEASE).$(PATCHLEVEL)-$(DISTRELEASE)
|
||||
@@ -338,6 +338,10 @@ $(rootdir)/libvmdump/libvmdump.a: $(rootdir)/libvmdump
|
||||
$(MAKE) -C $(rootdir)/libvmdump/ libvmdump.a
|
||||
.PHONY: $(rootdir)/libvmdump
|
||||
|
||||
$(rootdir)/libvmcp/libvmcp.a: $(rootdir)/libvmcp
|
||||
$(MAKE) -C $(rootdir)/libvmcp/ libvmcp.a
|
||||
.PHONY: $(rootdir)/libvmcp
|
||||
|
||||
$(rootdir)/zipl/boot/data.o:
|
||||
$(MAKE) -C $(rootdir)/zipl/boot/ data.o
|
||||
|
||||
|
||||
3
cpumf/bin/cpumf_helper.in
Normal file → Executable file
3
cpumf/bin/cpumf_helper.in
Normal file → Executable file
@@ -172,7 +172,7 @@ sub cpumf_parse_ctrdef($;$)
|
||||
|
||||
# Parse short description (optional)
|
||||
if ($line =~ m/^Short-Description:\s*(\S.*)?$/) {
|
||||
$h->{ctr}->{shortdesc} = $1 || "";
|
||||
$h->{$ctr}->{shortdesc} = $1 || "";
|
||||
|
||||
# Parse start of counter description
|
||||
} elsif ($line =~ m/^Description:\s*(\S.*)?$/) {
|
||||
@@ -211,6 +211,7 @@ my $system_z_hwtype_map = {
|
||||
2964 => 'IBM z13',
|
||||
2965 => 'IBM z13s',
|
||||
3906 => 'IBM z14',
|
||||
3907 => 'IBM z14 ZR1',
|
||||
};
|
||||
|
||||
sub get_hardware_type()
|
||||
|
||||
@@ -1,48 +1,60 @@
|
||||
Counter: 0 Name:CPU_CYCLES
|
||||
Short-Description:CPU Cycles
|
||||
Description:
|
||||
Cycle Count
|
||||
.
|
||||
Counter: 1 Name:INSTRUCTIONS
|
||||
Short-Description:Instructions
|
||||
Description:
|
||||
Instruction Count
|
||||
.
|
||||
Counter: 2 Name:L1I_DIR_WRITES
|
||||
Short-Description:L1I Directory Writes
|
||||
Description:
|
||||
Level-1 I-Cache Directory Write Count
|
||||
.
|
||||
Counter: 3 Name:L1I_PENALTY_CYCLES
|
||||
Short-Description:L1I Penalty Cycles
|
||||
Description:
|
||||
Level-1 I-Cache Penalty Cycle Count
|
||||
.
|
||||
Counter: 4 Name:L1D_DIR_WRITES
|
||||
Short-Description:L1D Directory Writes
|
||||
Description:
|
||||
Level-1 D-Cache Directory Write Count
|
||||
.
|
||||
Counter: 5 Name:L1D_PENALTY_CYCLES
|
||||
Short-Description:L1D Penalty Cycles
|
||||
Description:
|
||||
Level-1 D-Cache Penalty Cycle Count
|
||||
.
|
||||
Counter: 32 Name:PROBLEM_STATE_CPU_CYCLES
|
||||
Short-Description:Problem-State CPU Cycles
|
||||
Description:
|
||||
Problem-State Cycle Count
|
||||
.
|
||||
Counter: 33 Name:PROBLEM_STATE_INSTRUCTIONS
|
||||
Short-Description:Problem-State Instructions
|
||||
Description:
|
||||
Problem-State Instruction Count
|
||||
.
|
||||
Counter: 34 Name:PROBLEM_STATE_L1I_DIR_WRITES
|
||||
Short-Description:Problem-State L1I Directory Writes
|
||||
Description:
|
||||
Problem-State Level-1 I-Cache Directory Write Count
|
||||
.
|
||||
Counter: 35 Name:PROBLEM_STATE_L1I_PENALTY_CYCLES
|
||||
Short-Description:Problem-State L1I Penalty Cycles
|
||||
Description:
|
||||
Problem-State Level-1 I-Cache Penalty Cycle Count
|
||||
.
|
||||
Counter: 36 Name:PROBLEM_STATE_L1D_DIR_WRITES
|
||||
Short-Description:Problem-State L1D Directory Writes
|
||||
Description:
|
||||
Problem-State Level-1 D-Cache Directory Write Count
|
||||
.
|
||||
Counter: 37 Name:PROBLEM_STATE_L1D_PENALTY_CYCLES
|
||||
Short-Description:Problem-State L1D Penalty Cycles
|
||||
Description:
|
||||
Problem-State Level-1 D-Cache Penalty Cycle Count
|
||||
.
|
||||
|
||||
@@ -1,32 +1,40 @@
|
||||
Counter: 0 Name:CPU_CYCLES
|
||||
Short-Description:CPU Cycles
|
||||
Description:
|
||||
Cycle Count
|
||||
.
|
||||
Counter: 1 Name:INSTRUCTIONS
|
||||
Short-Description:Instructions
|
||||
Description:
|
||||
Instruction Count
|
||||
.
|
||||
Counter: 2 Name:L1I_DIR_WRITES
|
||||
Short-Description:L1I Directory Writes
|
||||
Description:
|
||||
Level-1 I-Cache Directory Write Count
|
||||
.
|
||||
Counter: 3 Name:L1I_PENALTY_CYCLES
|
||||
Short-Description:L1I Penalty Cycles
|
||||
Description:
|
||||
Level-1 I-Cache Penalty Cycle Count
|
||||
.
|
||||
Counter: 4 Name:L1D_DIR_WRITES
|
||||
Short-Description:L1D Directory Writes
|
||||
Description:
|
||||
Level-1 D-Cache Directory Write Count
|
||||
.
|
||||
Counter: 5 Name:L1D_PENALTY_CYCLES
|
||||
Short-Description:L1D Penalty Cycles
|
||||
Description:
|
||||
Level-1 D-Cache Penalty Cycle Count
|
||||
.
|
||||
Counter: 32 Name:PROBLEM_STATE_CPU_CYCLES
|
||||
Short-Description:Problem-State CPU Cycles
|
||||
Description:
|
||||
Problem-State Cycle Count
|
||||
.
|
||||
Counter: 33 Name:PROBLEM_STATE_INSTRUCTIONS
|
||||
Short-Description:Problem-State Instructions
|
||||
Description:
|
||||
Problem-State Instruction Count
|
||||
.
|
||||
|
||||
@@ -1,82 +1,98 @@
|
||||
Counter: 64 Name:PRNG_FUNCTIONS
|
||||
Short-Description:PRNG Functions
|
||||
Description:
|
||||
Total number of the PRNG functions issued by the CPU
|
||||
.
|
||||
Counter: 65 Name:PRNG_CYCLES
|
||||
Short-Description:PRNG Cycles
|
||||
Description:
|
||||
Total number of CPU cycles when the DEA/AES coprocessor is busy
|
||||
performing PRNG functions issued by the CPU
|
||||
.
|
||||
Counter: 66 Name:PRNG_BLOCKED_FUNCTIONS
|
||||
Short-Description:PRNG Blocked Functions
|
||||
Description:
|
||||
Total number of the PRNG functions that are issued by the CPU and are
|
||||
blocked because the DEA/AES coprocessor is busy performing a function
|
||||
issued by another CPU
|
||||
.
|
||||
Counter: 67 Name:PRNG_BLOCKED_CYCLES
|
||||
Short-Description:PRNG Blocked Cycles
|
||||
Description:
|
||||
Total number of CPU cycles blocked for the PRNG functions issued by
|
||||
the CPU because the DEA/AES coprocessor is busy performing a function
|
||||
issued by another CPU
|
||||
.
|
||||
Counter: 68 Name:SHA_FUNCTIONS
|
||||
Short-Description:SHA Functions
|
||||
Description:
|
||||
Total number of SHA functions issued by the CPU
|
||||
.
|
||||
Counter: 69 Name:SHA_CYCLES
|
||||
Short-Description:SHA Cycles
|
||||
Description:
|
||||
Total number of CPU cycles when the SHA coprocessor is busy performing
|
||||
the SHA functions issued by the CPU
|
||||
.
|
||||
Counter: 70 Name:SHA_BLOCKED_FUNCTIONS
|
||||
Short-Description:SHA Blocked Functions
|
||||
Description:
|
||||
Total number of the SHA functions that are issued by the CPU and are
|
||||
blocked because the SHA coprocessor is busy performing a function issued
|
||||
by another CPU
|
||||
.
|
||||
Counter: 71 Name:SHA_BLOCKED_CYCLES
|
||||
Short-Description:SHA Bloced Cycles
|
||||
Description:
|
||||
Total number of CPU cycles blocked for the SHA functions issued by the
|
||||
CPU because the SHA coprocessor is busy performing a function issued
|
||||
by another CPU
|
||||
.
|
||||
Counter: 72 Name:DEA_FUNCTIONS
|
||||
Short-Description:DEA Functions
|
||||
Description:
|
||||
Total number of the DEA functions issued by the CPU
|
||||
.
|
||||
Counter: 73 Name:DEA_CYCLES
|
||||
Short-Description:DEA Cycles
|
||||
Description:
|
||||
Total number of CPU cycles when the DEA/AES coprocessor is busy
|
||||
performing the DEA functions issued by the CPU
|
||||
.
|
||||
Counter: 74 Name:DEA_BLOCKED_FUNCTIONS
|
||||
Short-Description:DEA Blocked Functions
|
||||
Description:
|
||||
Total number of the DEA functions that are issued by the CPU and are
|
||||
blocked because the DEA/AES coprocessor is busy performing a function
|
||||
issued by another CPU
|
||||
.
|
||||
Counter: 75 Name:DEA_BLOCKED_CYCLES
|
||||
Short-Description:DEA Blocked Cycles
|
||||
Description:
|
||||
Total number of CPU cycles blocked for the DEA functions issued by the
|
||||
CPU because the DEA/AES coprocessor is busy performing a function issued
|
||||
by another CPU
|
||||
.
|
||||
Counter: 76 Name:AES_FUNCTIONS
|
||||
Short-Description:AES Functions
|
||||
Description:
|
||||
Total number of AES functions issued by the CPU
|
||||
.
|
||||
Counter: 77 Name:AES_CYCLES
|
||||
Short-Description:AES Cycles
|
||||
Description:
|
||||
Total number of CPU cycles when the DEA/AES coprocessor is busy
|
||||
performing the AES functions issued by the CPU
|
||||
.
|
||||
Counter: 78 Name:AES_BLOCKED_FUNCTIONS
|
||||
Short-Description:AES Blocked Functions
|
||||
Description:
|
||||
Total number of AES functions that are issued by the CPU and are blocked
|
||||
because the DEA/AES coprocessor is busy performing a function issued
|
||||
by another CPU
|
||||
.
|
||||
Counter: 79 Name:AES_BLOCKED_CYCLES
|
||||
Short-Description:AES Blocked Cycles
|
||||
Description:
|
||||
Total number of CPU cycles blocked for the AES functions issued by the
|
||||
CPU because the DEA/AES coprocessor is busy performing a function issued
|
||||
|
||||
@@ -1,96 +1,114 @@
|
||||
Counter: 128 Name:L1I_L2_SOURCED_WRITES
|
||||
Short-Description:L1I L2 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 I-Cache directory where the returned
|
||||
cache line was sourced from the Level-2 (L1.5) cache
|
||||
.
|
||||
Counter: 129 Name:L1D_L2_SOURCED_WRITES
|
||||
Short-Description:L1D L2 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-Cache directory where the installed
|
||||
cache line was sourced from the Level-2 (L1.5) cache
|
||||
.
|
||||
Counter: 130 Name:L1I_L3_LOCAL_WRITES
|
||||
Short-Description:L1I L3 Local Writes
|
||||
Description:
|
||||
A directory write to the Level-1 I-Cache directory where the installed
|
||||
cache line was sourced from the Level-3 cache that is on the same book
|
||||
as the Instruction cache (Local L2 cache)
|
||||
.
|
||||
Counter: 131 Name:L1D_L3_LOCAL_WRITES
|
||||
Short-Description:L1D L3 Local Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-Cache directory where the installtion
|
||||
cache line was source from the Level-3 cache that is on the same book
|
||||
as the Data cache (Local L2 cache)
|
||||
.
|
||||
Counter: 132 Name:L1I_L3_REMOTE_WRITES
|
||||
Short-Description:L1I L3 Remote Writes
|
||||
Description:
|
||||
A directory write to the Level-1 I-Cache directory where the installed
|
||||
cache line was sourced from a Level-3 cache that is not on the same
|
||||
book as the Instruction cache (Remote L2 cache)
|
||||
.
|
||||
Counter: 133 Name:L1D_L3_REMOTE_WRITES
|
||||
Short-Description:L1D L3 Remote Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-Cache directory where the installed
|
||||
cache line was sourced from a Level-3 cache that is not on the same
|
||||
book as the Data cache (Remote L2 cache)
|
||||
.
|
||||
Counter: 134 Name:L1D_LMEM_SOURCED_WRITES
|
||||
Short-Description:L1D Local Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-Cache directory where the installed
|
||||
cache line was sourced from memory that is attached to the same book
|
||||
as the Data cache (Local Memory)
|
||||
.
|
||||
Counter: 135 Name:L1I_LMEM_SOURCED_WRITES
|
||||
Short-Description:L1I Local Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 I-Cache where the installed cache
|
||||
line was sourced from memory that is attached to the s ame book as the
|
||||
Instruction cahe (local Memory)
|
||||
Instruction cache (Local Memory)
|
||||
.
|
||||
Counter: 136 Name:L1D_RO_EXCL_WRITES
|
||||
Short-Description:L1D Read-only Exclusive Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-Cache where the line was originally
|
||||
in a Read-Only state in the cache but has been updated to be in the
|
||||
Exclusive state that allows stores to the cache line
|
||||
.
|
||||
Counter: 137 Name:L1I_CACHELINE_INVALIDATES
|
||||
Short-Description:L1I Cacheline Invalidates
|
||||
Description:
|
||||
A cache line in the Level-1 I-Cache has been invalidated by a store on
|
||||
the same CPU as the Level-1 I-Cache
|
||||
.
|
||||
Counter: 138 Name:ITLB1_WRITES
|
||||
Short-Description:ITLB1 Writes
|
||||
Description:
|
||||
A translation entry has been written into the Level-1 Instruction
|
||||
Translation Lookaside Buffer
|
||||
.
|
||||
Counter: 139 Name:DTLB1_WRITES
|
||||
Short-Description:DTLB1 Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-1 Data Translation
|
||||
Lookaside Buffer
|
||||
.
|
||||
Counter: 140 Name:TLB2_PTE_WRITES
|
||||
Short-Description:TLB2 PTE Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-2 TLB Page Table
|
||||
Entry arrays
|
||||
.
|
||||
Counter: 141 Name:TLB2_CRSTE_WRITES
|
||||
Short-Description:TLB2 CRSTE Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-2 TLB Common Region
|
||||
Segment Table Entry arrays
|
||||
.
|
||||
Counter: 142 Name:TLB2_CRSTE_HPAGE_WRITES
|
||||
Short-Description:TLB2 CRSTE One-Megabyte Page Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-2 TLB Common Region
|
||||
Segment Table Entry arrays for a one-megabyte large page translation
|
||||
.
|
||||
Counter: 145 Name:ITLB1_MISSES
|
||||
Short-Description:ITLB1 Misses
|
||||
Description:
|
||||
Level-1 Instruction TLB miss in progress. Incremented by one for every
|
||||
cycle an ITLB1 miss is in progress
|
||||
.
|
||||
Counter: 146 Name:DTLB1_MISSES
|
||||
Short-Description:DTLB1 Misses
|
||||
Description:
|
||||
Level-1 Data TLB miss in progress. Incremented by one for every cycle
|
||||
an DTLB1 miss is in progress
|
||||
.
|
||||
Counter: 147 Name:L2C_STORES_SENT
|
||||
Short-Description:L2C Stores Sent
|
||||
Description:
|
||||
Incremented by one for every store sent to Level-2 (L1.5) cache
|
||||
.
|
||||
|
||||
@@ -16,288 +16,343 @@
|
||||
#
|
||||
# Extended Counter Set
|
||||
# ---------------------------------------------------------------------
|
||||
Counter:128 Name:L1D_WRITES_RO_EXCL
|
||||
Counter:128 Name:L1D_RO_EXCL_WRITES
|
||||
Short-Description:L1D Read-only Exclusive Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache where the line was
|
||||
originally in a Read-Only state in the cache but has been updated
|
||||
to be in the Exclusive state that allows stores to the cache line.
|
||||
.
|
||||
Counter:129 Name:DTLB1_WRITES
|
||||
Short-Description:DTLB1 Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-1 Data Translation
|
||||
Lookaside Buffer
|
||||
.
|
||||
Counter:130 Name:DTLB1_MISSES
|
||||
Short-Description:DTLB1 Misses
|
||||
Description:
|
||||
Level-1 Data TLB miss in progress. Incremented by one for every cycle
|
||||
a DTLB1 miss is in progress.
|
||||
.
|
||||
Counter:131 Name:DTLB1_HPAGE_WRITES
|
||||
Short-Description:DTLB1 One-Megabyte Page Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-1 Data Translation
|
||||
Lookaside Buffer for a one-megabyte page
|
||||
.
|
||||
Counter:132 Name:DTLB1_GPAGE_WRITES
|
||||
Short-Description:DTLB1 Two-Gigabyte Page Writes
|
||||
A translation entry has been written to the Level-1 Data Translation
|
||||
Lookaside Buffer for a two-gigabyte page.
|
||||
.
|
||||
Counter:133 Name:L1D_L2D_SOURCED_WRITES
|
||||
Short-Description:L1D L2D Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from the Level-2 Data cache
|
||||
.
|
||||
Counter:134 Name:ITLB1_WRITES
|
||||
Short-Description:ITLB1 Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-1 Instruction
|
||||
Translation Lookaside Buffer
|
||||
.
|
||||
Counter:135 Name:ITLB1_MISSES
|
||||
Short-Description:ITLB1 Misses
|
||||
Description:
|
||||
Level-1 Instruction TLB miss in progress. Incremented by one for every
|
||||
cycle an ITLB1 miss is in progress
|
||||
.
|
||||
Counter:136 Name:L1I_L2I_SOURCED_WRITES
|
||||
Short-Description:L1I L2I Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from the Level-2 Instruction cache
|
||||
.
|
||||
Counter:137 Name:TLB2_PTE_WRITES
|
||||
Short-Description:TLB2 PTE Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-2 TLB Page Table
|
||||
Entry arrays
|
||||
.
|
||||
Counter:138 Name:TLB2_CRSTE_HPAGE_WRITES
|
||||
Short-Description:TLB2 CRSTE One-Megabyte Page Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-2 TLB Combined Region
|
||||
Segment Table Entry arrays for a one-megabyte large page translation
|
||||
.
|
||||
Counter:139 Name:TLB2_CRSTE_WRITES
|
||||
Short-Description:TLB2 CRSTE Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-2 TLB Combined Region
|
||||
Segment Table Entry arrays
|
||||
.
|
||||
Counter:140 Name:TX_C_TEND
|
||||
Short-Description:Completed TEND instructions in constrained TX mode
|
||||
Description:
|
||||
A TEND instruction has completed in a constrained transactional-execution
|
||||
mode
|
||||
.
|
||||
Counter:141 Name:TX_NC_TEND
|
||||
Short-Description:Completed TEND instructions in non-constrained TX mode
|
||||
Description:
|
||||
A TEND instruction has completed in a non-constrained
|
||||
transactional-execution mode
|
||||
.
|
||||
Counter:143 Name:L1C_TLB1_MISSES
|
||||
Short-Description:L1C TLB1 Misses
|
||||
Description:
|
||||
Increments by one for any cycle where a Level-1 cache or Level-1 TLB miss
|
||||
is in progress.
|
||||
.
|
||||
Counter:144 Name:L1D_ONCHIP_L3_SOURCED_WRITES
|
||||
Short-Description:L1D On-Chip L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an On-Chip Level-3 cache without intervention
|
||||
.
|
||||
Counter:145 Name:L1D_ONCHIP_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1D On-Chip L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an On-Chip Level-3 cache with intervention
|
||||
.
|
||||
Counter:146 Name:L1D_ONNODE_L4_SOURCED_WRITES
|
||||
Short-Description:L1D On-Node L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an On-Node Level-4 cache
|
||||
.
|
||||
Counter:147 Name:L1D_ONNODE_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1D On-Node L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an On-Node Level-3 cache with intervention
|
||||
.
|
||||
Counter:148 Name:L1D_ONNODE_L3_SOURCED_WRITES
|
||||
Short-Description:L1D On-Node L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an On-Node Level-3 cache without intervention
|
||||
.
|
||||
Counter:149 Name:L1D_ONDRAWER_L4_SOURCED_WRITES
|
||||
Short-Description:L1D On-Drawer L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an On-Drawer Level-4 cache
|
||||
.
|
||||
Counter:150 Name:L1D_ONDRAWER_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1D On-Drawer L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an On-Drawer Level-3 cache with intervention
|
||||
.
|
||||
Counter:151 Name:L1D_ONDRAWER_L3_SOURCED_WRITES
|
||||
Short-Description:L1D On-Drawer L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an On-Drawer Level-3 cache without intervention
|
||||
.
|
||||
Counter:152 Name:L1D_OFFDRAWER_SCOL_L4_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Drawer Same-Column L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an Off-Drawer Same-Column Level-4 cache
|
||||
.
|
||||
Counter:153 Name:L1D_OFFDRAWER_SCOL_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1D Off-Drawer Same-Column L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an Off-Drawer Same-Column Level-3 cache with
|
||||
intervention
|
||||
.
|
||||
Counter:154 Name:L1D_OFFDRAWER_SCOL_L3_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Drawer Same-Column L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an Off-Drawer Same-Column Level-3 cache
|
||||
without intervention
|
||||
.
|
||||
Counter:155 Name:L1D_OFFDRAWER_FCOL_L4_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Drawer Far-Column L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an Off-Drawer Far-Column Level-4 cache
|
||||
.
|
||||
Counter:156 Name:L1D_OFFDRAWER_FCOL_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1D Off-Drawer Far-Column L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an Off-Drawer Far-Column Level-3 cache with
|
||||
intervention
|
||||
.
|
||||
Counter:157 Name:L1D_OFFDRAWER_FCOL_L3_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Drawer Far-Column L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an Off-Drawer Far-Column Level-3 cache
|
||||
without intervention
|
||||
.
|
||||
Counter:158 Name:L1D_ONNODE_MEM_SOURCED_WRITES
|
||||
Short-Description:L1D On-Node Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from On-Node memory
|
||||
.
|
||||
Counter:159 Name:L1D_ONDRAWER_MEM_SOURCED_WRITES
|
||||
Short-Description:L1D On-Drawer Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from On-Drawer memory
|
||||
.
|
||||
Counter:160 Name:L1D_OFFDRAWER_MEM_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Drawer Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from On-Drawer memory
|
||||
.
|
||||
Counter:161 Name:L1D_ONCHIP_MEM_SOURCED_WRITES
|
||||
Short-Description:L1D On-Chip Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from On-Chip memory
|
||||
.
|
||||
Counter:162 Name:L1I_ONCHIP_L3_SOURCED_WRITES
|
||||
Short-Description:L1I On-Chip L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an On-Chip Level-3 cache without
|
||||
intervention
|
||||
.
|
||||
Counter:163 Name:L1I_ONCHIP_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1I On-Chip L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an On Chip Level-3 cache with
|
||||
intervention
|
||||
.
|
||||
Counter:164 Name:L1I_ONNODE_L4_SOURCED_WRITES
|
||||
Short-Description:L1I On-Chip L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an On-Node Level-4 cache
|
||||
.
|
||||
Counter:165 Name:L1I_ONNODE_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1I On-Node L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from an On-Node Level-3 cache
|
||||
with intervention
|
||||
.
|
||||
Counter:166 Name:L1I_ONNODE_L3_SOURCED_WRITES
|
||||
Short-Description:L1I On-Node L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from an On-Node Level-3 cache
|
||||
without intervention
|
||||
.
|
||||
Counter:167 Name:L1I_ONDRAWER_L4_SOURCED_WRITES
|
||||
Short-Description:L1I On-Drawer L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from an On-Drawer Level-4 cache
|
||||
.
|
||||
Counter:168 Name:L1I_ONDRAWER_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1I On-Drawer L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from an On-Drawer Level-3 cache
|
||||
with intervention
|
||||
.
|
||||
Counter:169 Name:L1I_ONDRAWER_L3_SOURCED_WRITES
|
||||
Short-Description:L1I On-Drawer L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from an On-Drawer Level-3 cache
|
||||
without intervention
|
||||
.
|
||||
Counter:170 Name:L1I_OFFDRAWER_SCOL_L4_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Drawer Same-Column L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from an Off-Drawer Same-Column
|
||||
Level-4 cache
|
||||
.
|
||||
Counter:171 Name:L1I_OFFDRAWER_SCOL_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1I Off-Drawer Same-Column L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from an Off-Drawer Same-Column
|
||||
Level-3 cache with intervention
|
||||
.
|
||||
Counter:172 Name:L1I_OFFDRAWER_SCOL_L3_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Drawer Same-Column L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from an Off-Drawer Same-Column
|
||||
Level-3 cache without intervention
|
||||
.
|
||||
Counter:173 Name:L1I_OFFDRAWER_FCOL_L4_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Drawer Far-Column L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from an Off-Drawer Far-Column
|
||||
Level-4 cache
|
||||
.
|
||||
Counter:174 Name:L1I_OFFDRAWER_FCOL_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1I Off-Drawer Far-Column L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from an Off-Drawer Far-Column
|
||||
Level-3 cache with intervention
|
||||
.
|
||||
Counter:175 Name:L1I_OFFDRAWER_FCOL_L3_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Drawer Far-Column L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from an Off-Drawer Far-Column
|
||||
Level-3 cache without intervention
|
||||
.
|
||||
Counter:176 Name:L1I_ONNODE_MEM_SOURCED_WRITES
|
||||
Short-Description:L1I On-Node Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from On-Node memory
|
||||
.
|
||||
Counter:177 Name:L1I_ONDRAWER_MEM_SOURCED_WRITES
|
||||
Short-Description:L1I On-Drawer Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from On-Drawer memory
|
||||
.
|
||||
Counter:178 Name:L1I_OFFDRAWER_MEM_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Drawer Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from On-Drawer memory
|
||||
.
|
||||
Counter:179 Name:L1I_ONCHIP_MEM_SOURCED_WRITES
|
||||
Short-Description:L1I On-Chip Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from On-Chip memory
|
||||
.
|
||||
Counter:218 Name:TX_NC_TABORT
|
||||
Short-Description:Aborted transactions in non-constrained TX mode
|
||||
Description:
|
||||
A transaction abort has occurred in a non-constrained
|
||||
transactional-execution mode
|
||||
.
|
||||
Counter:219 Name:TX_C_TABORT_NO_SPECIAL
|
||||
Short-Description:Aborted transactions in constrained TX mode not using special completion logic
|
||||
Description:
|
||||
A transaction abort has occurred in a constrained transactional-execution
|
||||
mode and the CPU is not using any special logic to allow the transaction
|
||||
to complete
|
||||
.
|
||||
Counter:220 Name:TX_C_TABORT_SPECIAL
|
||||
Short-Description:Aborted transactions in constrained TX mode using special completion logic
|
||||
Description:
|
||||
A transaction abort has occurred in a constrained transactional-execution
|
||||
mode and the CPU is using special logic to allow the transaction to
|
||||
@@ -307,10 +362,12 @@ complete
|
||||
# MT-diagnostic counter set
|
||||
# ---------------------------------------------------------------------
|
||||
Counter:448 Name:MT_DIAG_CYCLES_ONE_THR_ACTIVE
|
||||
Short-Description:Cycle count with one thread active
|
||||
Description:
|
||||
Cycle count with one thread active
|
||||
.
|
||||
Counter:449 Name:MT_DIAG_CYCLES_TWO_THR_ACTIVE
|
||||
Short-Description:Cycle count with two threads active
|
||||
Description:
|
||||
Cycle count with two threads active
|
||||
.
|
||||
|
||||
@@ -19,272 +19,324 @@
|
||||
#
|
||||
# Extended Counter Set
|
||||
# ---------------------------------------------------------------------
|
||||
Counter:128 Name:L1D_WRITES_RO_EXCL
|
||||
Counter:128 Name:L1D_RO_EXCL_WRITES
|
||||
Short-Description:L1D Read-only Exclusive Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache where the line was
|
||||
originally in a Read-Only state in the cache but has been updated
|
||||
to be in the Exclusive state that allows stores to the cache line
|
||||
.
|
||||
Counter:129 Name:DTLB2_WRITES
|
||||
Short-Description:DTLB2 Writes
|
||||
Description:
|
||||
A translation has been written into The Translation Lookaside
|
||||
Buffer 2 (TLB2) and the request was made by the data cache
|
||||
.
|
||||
Counter:130 Name:DTLB2_MISSES
|
||||
Short-Description:DTLB2 Misses
|
||||
Description:
|
||||
A TLB2 miss is in progress for a request made by the data cache.
|
||||
Incremented by one for every TLB2 miss in progress for the Level-1
|
||||
Data cache on this cycle
|
||||
.
|
||||
Counter:131 Name:DTLB2_HPAGE_WRITES
|
||||
Short-Description:DTLB2 One-Megabyte Page Writes
|
||||
Description:
|
||||
A translation entry was written into the Combined Region and Segment
|
||||
Table Entry array in the Level-2 TLB for a one-megabyte page or a
|
||||
Last Host Translation was done
|
||||
.
|
||||
Counter:132 Name:DTLB2_GPAGE_WRITES
|
||||
Short-Description:DTLB2 Two-Gigabyte Page Writes
|
||||
Description:
|
||||
A translation entry for a two-gigabyte page was written into the
|
||||
Level-2 TLB
|
||||
.
|
||||
Counter:133 Name:L1D_L2D_SOURCED_WRITES
|
||||
Short-Description:L1D L2D Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the
|
||||
returned cache line was sourced from the Level-2 Data cache
|
||||
.
|
||||
Counter:134 Name:ITLB2_WRITES
|
||||
Short-Description:ITLB2 Writes
|
||||
Description:
|
||||
A translation entry has been written into the Translation Lookaside
|
||||
Buffer 2 (TLB2) and the request was made by the instruction cache
|
||||
.
|
||||
Counter:135 Name:ITLB2_MISSES
|
||||
Short-Description:ITLB2 Misses
|
||||
Description:
|
||||
A TLB2 miss is in progress for a request made by the instruction cache.
|
||||
Incremented by one for every TLB2 miss in progress for the Level-1
|
||||
Instruction cache in a cycle
|
||||
.
|
||||
Counter:136 Name:L1I_L2I_SOURCED_WRITES
|
||||
Short-Description:L1I L2I Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from the Level-2 Instruction cache
|
||||
.
|
||||
Counter:137 Name:TLB2_PTE_WRITES
|
||||
Short-Description:TLB2 PTE Writes
|
||||
Description:
|
||||
A translation entry was written into the Page Table Entry array in the
|
||||
Level-2 TLB
|
||||
.
|
||||
Counter:138 Name:TLB2_CRSTE_WRITES
|
||||
Short-Description:TLB2 CRSTE Writes
|
||||
Description:
|
||||
Translation entries were written into the Combined Region and Segment
|
||||
Table Entry array and the Page Table Entry array in the Level-2 TLB
|
||||
.
|
||||
Counter:139 Name:TLB2_ENGINES_BUSY
|
||||
Short-Description:TLB2 Engines Busy
|
||||
Description:
|
||||
The number of Level-2 TLB translation engines busy in a cycle
|
||||
.
|
||||
Counter:140 Name:TX_C_TEND
|
||||
Short-Description:Completed TEND instructions in constrained TX mode
|
||||
Description:
|
||||
A TEND instruction has completed in a constrained transactional-execution
|
||||
mode
|
||||
.
|
||||
Counter:141 Name:TX_NC_TEND
|
||||
Short-Description:Completed TEND instructions in non-constrained TX mode
|
||||
Description:
|
||||
A TEND instruction has completed in a non-constrained
|
||||
transactional-execution mode
|
||||
.
|
||||
Counter:143 Name:L1C_TLB2_MISSES
|
||||
Short-Description:L1C TLB2 Misses
|
||||
Description:
|
||||
Increments by one for any cycle where a level-1 cache or level-2 TLB miss
|
||||
is in progress
|
||||
.
|
||||
Counter:144 Name:L1D_ONCHIP_L3_SOURCED_WRITES
|
||||
Short-Description:L1D On-Chip L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an On-Chip Level-3 cache without intervention
|
||||
.
|
||||
Counter:145 Name:L1D_ONCHIP_MEMORY_SOURCED_WRITES
|
||||
Short-Description:L1D On-Chip Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from On-Chip memory
|
||||
.
|
||||
Counter:146 Name:L1D_ONCHIP_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1D On-Chip L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an On-Chip Level-3 cache with intervention
|
||||
.
|
||||
Counter:147 Name:L1D_ONCLUSTER_L3_SOURCED_WRITES
|
||||
Short-Description:L1D On-Cluster L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from On-Cluster Level-3 cache withountervention
|
||||
.
|
||||
Counter:148 Name:L1D_ONCLUSTER_MEMORY_SOURCED_WRITES
|
||||
Short-Description:L1D On-Cluster Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an On-Cluster memory
|
||||
.
|
||||
Counter:149 Name:L1D_ONCLUSTER_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1D On-Cluster L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an On-Cluster Level-3 cache with intervention
|
||||
.
|
||||
Counter:150 Name:L1D_OFFCLUSTER_L3_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Cluster L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an Off-Cluster Level-3 cache without
|
||||
intervention
|
||||
.
|
||||
Counter:151 Name:L1D_OFFCLUSTER_MEMORY_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Cluster Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from Off-Cluster memory
|
||||
.
|
||||
Counter:152 Name:L1D_OFFCLUSTER_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1D Off-Cluster L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an Off-Cluster Level-3 cache with intervention
|
||||
.
|
||||
Counter:153 Name:L1D_OFFDRAWER_L3_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Drawer L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an Off-Drawer Level-3 cache without
|
||||
intervention
|
||||
.
|
||||
Counter:154 Name:L1D_OFFDRAWER_MEMORY_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Drawer Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from Off-Drawer memory
|
||||
.
|
||||
Counter:155 Name:L1D_OFFDRAWER_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1D Off-Drawer L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an Off-Drawer Level-3 cache with intervention
|
||||
.
|
||||
Counter:156 Name:L1D_ONDRAWER_L4_SOURCED_WRITES
|
||||
Short-Description:L1D On-Drawer L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from On-Drawer Level-4 cache
|
||||
.
|
||||
Counter:157 Name:L1D_OFFDRAWER_L4_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Drawer L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from Off-Drawer Level-4 cache
|
||||
.
|
||||
Counter:158 Name:L1D_ONCHIP_L3_SOURCED_WRITES_RO
|
||||
Short-Description:L1D On-Chip L3 Sourced Writes read-only
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from On-Chip L3 but a read-only invalidate was
|
||||
done to remove other copies of the cache line
|
||||
.
|
||||
Counter:162 Name:L1I_ONCHIP_L3_SOURCED_WRITES
|
||||
Short-Description:L1I On-Chip L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache ine was sourced from an On-Chip Level-3 cache without
|
||||
intervention
|
||||
.
|
||||
Counter:163 Name:L1I_ONCHIP_MEMORY_SOURCED_WRITES
|
||||
Short-Description:L1I On-Chip Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache ine was sourced from On-Chip memory
|
||||
.
|
||||
Counter:164 Name:L1I_ONCHIP_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1I On-Chip L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache ine was sourced from an On-Chip Level-3 cache with
|
||||
intervention
|
||||
.
|
||||
Counter:165 Name:L1I_ONCLUSTER_L3_SOURCED_WRITES
|
||||
Short-Description:L1I On-Cluster L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an On-Cluster Level-3 cache without
|
||||
intervention
|
||||
.
|
||||
Counter:166 Name:L1I_ONCLUSTER_MEMORY_SOURCED_WRITES
|
||||
Short-Description:L1I On-Cluster Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an On-Cluster memory
|
||||
.
|
||||
Counter:167 Name:L1I_ONCLUSTER_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1I On-Cluster L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from On-Cluster Level-3 cache with
|
||||
intervention
|
||||
.
|
||||
Counter:168 Name:L1I_OFFCLUSTER_L3_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Cluster L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an Off-Cluster Level-3 cache without
|
||||
intervention
|
||||
.
|
||||
Counter:169 Name:L1I_OFFCLUSTER_MEMORY_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Cluster Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from Off-Cluster memory
|
||||
.
|
||||
Counter:170 Name:L1I_OFFCLUSTER_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1I Off-Cluster L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an Off-Cluster Level-3 cache with
|
||||
intervention
|
||||
.
|
||||
Counter:171 Name:L1I_OFFDRAWER_L3_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Drawer L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an Off-Drawer Level-3 cache without
|
||||
intervention
|
||||
.
|
||||
Counter:172 Name:L1I_OFFDRAWER_MEMORY_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Drawer Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from Off-Drawer memory
|
||||
.
|
||||
Counter:173 Name:L1I_OFFDRAWER_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1I Off-Drawer L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an Off-Drawer Level-3 cache with
|
||||
intervention
|
||||
.
|
||||
Counter:174 Name:L1I_ONDRAWER_L4_SOURCED_WRITES
|
||||
Short-Description:L1I On-Drawer L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from On-Drawer Level-4 cache
|
||||
.
|
||||
Counter:175 Name:L1I_OFFDRAWER_L4_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Drawer L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from Off-Drawer Level-4 cache
|
||||
.
|
||||
Counter:224 Name:BCD_DFP_EXECUTION_SLOTS
|
||||
Short-Description:BCD DFP Execution Slots
|
||||
Description:
|
||||
Count of floating point execution slots used for finished Binary Coded
|
||||
Decimal to Decimal Floating Point conversions. Instructions: CDZT,
|
||||
CXZT, CZDT, CZXT
|
||||
.
|
||||
Counter:225 Name:VX_BCD_EXECUTION_SLOTS
|
||||
Short-Description:VX BCD Execution Slots
|
||||
Description:
|
||||
Count of floating point execution slots used for finished vector arithmetic
|
||||
Binary Coded Decimal instructions. Instructions: VAP, VSP, VMPVMSP, VDP,
|
||||
VSDP, VRP, VLIP, VSRP, VPSOPVCP, VTP, VPKZ, VUPKZ, VCVB, VCVBG, VCVDVCVDG
|
||||
.
|
||||
Counter:226 Name:DECIMAL_INSTRUCTIONS
|
||||
Short-Description:Decimal Instructions
|
||||
Description:
|
||||
Decimal instructions dispatched. Instructions: CVB, CVD, AP, CP, DP, ED,
|
||||
EDMK, MP, SRP, SP, ZAP
|
||||
.
|
||||
Counter:232 Name:LAST_HOST_TRANSLATIONS
|
||||
Short-Description:Last host translation done
|
||||
Description:
|
||||
Last Host Translation done
|
||||
.
|
||||
Counter:243 Name:TX_NC_TABORT
|
||||
Short-Description:Aborted transactions in non-constrained TX mode
|
||||
Description:
|
||||
A transaction abort has occurred in a non-constrained
|
||||
transactional-execution mode
|
||||
.
|
||||
Counter:244 Name:TX_C_TABORT_NO_SPECIAL
|
||||
Short-Description:Aborted transactions in constrained TX mode not using special completion logic
|
||||
Description:
|
||||
A transaction abort has occurred in a constrained transactional-execution
|
||||
mode and the CPU is not using any special logic to allow the transaction
|
||||
to complete
|
||||
.
|
||||
Counter:245 Name:TX_C_TABORT_SPECIAL
|
||||
Short-Description:Aborted transactions in constrained TX mode using special completion logic
|
||||
Description:
|
||||
A transaction abort has occurred in a constrained transactional-execution
|
||||
mode and the CPU is using special logic to allow the transaction to
|
||||
@@ -294,10 +346,12 @@ complete
|
||||
# MT-diagnostic counter set
|
||||
# ---------------------------------------------------------------------
|
||||
Counter:448 Name:MT_DIAG_CYCLES_ONE_THR_ACTIVE
|
||||
Short-Description:Cycle count with one thread active
|
||||
Description:
|
||||
Cycle count with one thread active
|
||||
.
|
||||
Counter:449 Name:MT_DIAG_CYCLES_TWO_THR_ACTIVE
|
||||
Short-Description:Cycle count with two threads active
|
||||
Description:
|
||||
Cycle count with two threads active
|
||||
.
|
||||
|
||||
@@ -1,121 +1,145 @@
|
||||
Counter: 128 Name:L1D_L2_SOURCED_WRITES
|
||||
Short-Description:L1D L2 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-Cache directory where the returned
|
||||
cache line was sourced from the Level-2 cache
|
||||
.
|
||||
Counter: 129 Name:L1I_L2_SOURCED_WRITES
|
||||
Short-Description:L1I L2 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 I-Cache directory where the returned
|
||||
cache line was sourced from the Level-2 cache
|
||||
.
|
||||
Counter: 130 Name:DTLB1_MISSES
|
||||
Short-Description:DTLB1 Misses
|
||||
Description:
|
||||
Level-1 Data TLB miss in progress. Incremented by one for every cycle
|
||||
a DTLB1 miss is in progress.
|
||||
.
|
||||
Counter: 131 Name:ITLB1_MISSES
|
||||
Short-Description:ITLB1 Misses
|
||||
Description:
|
||||
Level-1 Instruction TLB miss in progress. Incremented by one for every
|
||||
cycle a ITLB1 miss is in progress.
|
||||
.
|
||||
Counter: 133 Name:L2C_STORES_SENT
|
||||
Short-Description:L2C Stores Sent
|
||||
Description:
|
||||
Incremented by one for every store sent to Level-2 cache
|
||||
.
|
||||
Counter: 134 Name:L1D_OFFBOOK_L3_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Book L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-Cache directory where the returned
|
||||
cache line was sourced from an Off Book Level-3 cache
|
||||
.
|
||||
Counter: 135 Name:L1D_ONBOOK_L4_SOURCED_WRITES
|
||||
Short-Description:L1D On-Book L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-Cache directory where the returned
|
||||
cache line was sourced from an On Book Level-4 cache
|
||||
.
|
||||
Counter: 136 Name:L1I_ONBOOK_L4_SOURCED_WRITES
|
||||
Short-Description:L1I On-Book L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 I-Cache directory where the returned
|
||||
cache line was sourced from an On Book Level-4 cache
|
||||
.
|
||||
Counter: 137 Name:L1D_RO_EXCL_WRITES
|
||||
Short-Description:L1D Read-only Exclusive Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-Cache where the line was originally
|
||||
in a Read-Only state in the cache but has been updated to be in the
|
||||
Exclusive state that allows stores to the cache line
|
||||
.
|
||||
Counter: 138 Name:L1D_OFFBOOK_L4_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Book L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-Cache directory where the returned
|
||||
cache line was sourced from an Off Book Level-4 cache
|
||||
.
|
||||
Counter: 139 Name:L1I_OFFBOOK_L4_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Book L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 I-Cache directory where the returned
|
||||
cache line was sourced from an Off Book Level-4 cache
|
||||
.
|
||||
Counter: 140 Name:DTLB1_HPAGE_WRITES
|
||||
Short-Description:DTLB1 One-Megabyte Page Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-1 Data Translation
|
||||
Lookaside Buffer for a one-megabyte page
|
||||
.
|
||||
Counter: 141 Name:L1D_LMEM_SOURCED_WRITES
|
||||
Short-Description:L1D Local Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-Cache where the installed cache line
|
||||
was sourced from memory that is attached to the same book as the Data
|
||||
cache (Local Memory)
|
||||
.
|
||||
Counter: 142 Name:L1I_LMEM_SOURCED_WRITES
|
||||
Short-Description:L1I Local Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 I-Cache where the installed cache
|
||||
line was sourced from memory that is attached to the same book as the
|
||||
Instruction cache (Local Memory)
|
||||
.
|
||||
Counter: 143 Name:L1I_OFFBOOK_L3_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Book L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 I-Cache directory where the returned
|
||||
cache line was sourced from an Off Book Level-3 cache
|
||||
.
|
||||
Counter: 144 Name:DTLB1_WRITES
|
||||
Short-Description:DTLB1 Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-1 Data Translation
|
||||
Lookaside Buffer
|
||||
.
|
||||
Counter: 145 Name:ITLB1_WRITES
|
||||
Short-Description:ITLB1 Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-1 Instruction
|
||||
Translation Lookaside Buffer
|
||||
.
|
||||
Counter: 146 Name:TLB2_PTE_WRITES
|
||||
Short-Description:TLB2 PTE Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-2 TLB Page Table
|
||||
Entry arrays
|
||||
.
|
||||
Counter: 147 Name:TLB2_CRSTE_HPAGE_WRITES
|
||||
Short-Description:TLB2 CRSTE One-Megabyte Page Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-2 TLB Common Region
|
||||
Segment Table Entry arrays for a one-megabyte large page translation
|
||||
.
|
||||
Counter: 148 Name:TLB2_CRSTE_WRITES
|
||||
Short-Description:TLB2 CRSTE Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-2 TLB Common Region
|
||||
Segment Table Entry arrays
|
||||
.
|
||||
Counter: 150 Name:L1D_ONCHIP_L3_SOURCED_WRITES
|
||||
Short-Description:L1D On-Chip L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-Cache directory where the returned
|
||||
cache line was sourced from an On Chip Level-3 cache
|
||||
.
|
||||
Counter: 152 Name:L1D_OFFCHIP_L3_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Chip L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-Cache directory where the returned
|
||||
cache line was sourced from an Off Chip/On Book Level-3 cache
|
||||
.
|
||||
Counter: 153 Name:L1I_ONCHIP_L3_SOURCED_WRITES
|
||||
Short-Description:L1I On-Chip L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 I-Cache directory where the returned
|
||||
cache line was sourced from an On Chip Level-3 cache
|
||||
.
|
||||
Counter: 155 Name:L1I_OFFCHIP_L3_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Chip L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 I-Cache directory where the returned
|
||||
cache line was sourced from an Off Chip/On Book Level-3 cache
|
||||
|
||||
@@ -1,98 +1,117 @@
|
||||
Counter: 128 Name:DTLB1_MISSES
|
||||
Short-Description:DTLB1 Misses
|
||||
Description:
|
||||
Level-1 Data TLB miss in progress. Incremented by one for every cycle
|
||||
a DTLB1 miss is in progress.
|
||||
.
|
||||
Counter:129 Name:ITLB1_MISSES
|
||||
Short-Description:ITLB1 Misses
|
||||
Description:
|
||||
Level-1 Instruction TLB miss in progress. Incremented by one for every
|
||||
cycle a ITLB1 miss is in progress.
|
||||
.
|
||||
Counter:130 Name:L1D_L2I_SOURCED_WRITES
|
||||
Short-Description:L1D L2I Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from the Level-2 Instruction cache
|
||||
.
|
||||
Counter:131 Name:L1I_L2I_SOURCED_WRITES
|
||||
Short-Description:L1I L2I Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from the Level-2 Instruction cache
|
||||
.
|
||||
Counter:132 Name:L1D_L2D_SOURCED_WRITES
|
||||
Short-Description:L1D L2D Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from the Level-2 Data cache
|
||||
.
|
||||
Counter:133 Name:DTLB1_WRITES
|
||||
Short-Description:DTLB1 Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-1 Data Translation
|
||||
Lookaside Buffer
|
||||
.
|
||||
Counter:135 Name:L1D_LMEM_SOURCED_WRITES
|
||||
Short-Description:L1D Local Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache where the installed cache line
|
||||
was sourced from memory that is attached to the same book as the Data
|
||||
cache (Local Memory)
|
||||
.
|
||||
Counter:137 Name:L1I_LMEM_SOURCED_WRITES
|
||||
Short-Description:L1I Local Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache where the installed cache
|
||||
line was sourced from memory that is attached to the same book as the
|
||||
Instruction cache (Local Memory)
|
||||
.
|
||||
Counter:138 Name:L1D_RO_EXCL_WRITES
|
||||
Short-Description:L1D Read-only Exclusive Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-Cache where the line was originally
|
||||
in a Read-Only state in the cache but has been updated to be in the
|
||||
Exclusive state that allows stores to the cache line
|
||||
.
|
||||
Counter:139 Name:DTLB1_HPAGE_WRITES
|
||||
Short-Description:DTLB1 One-Megabyte Page Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-1 Data Translation
|
||||
Lookaside Buffer for a one-megabyte page
|
||||
.
|
||||
Counter:140 Name:ITLB1_WRITES
|
||||
Short-Description:ITLB1 Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-1 Instruction
|
||||
Translation Lookaside Buffer
|
||||
.
|
||||
Counter:141 Name:TLB2_PTE_WRITES
|
||||
Short-Description:TLB2 PTE Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-2 TLB Page Table
|
||||
Entry arrays
|
||||
.
|
||||
Counter:142 Name:TLB2_CRSTE_HPAGE_WRITES
|
||||
Short-Description:TLB2 CRSTE One-Megabyte Page Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-2 TLB Common Region
|
||||
Segment Table Entry arrays for a one-megabyte large page translation
|
||||
.
|
||||
Counter:143 Name:TLB2_CRSTE_WRITES
|
||||
Short-Description:TLB2 CRSTE Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-2 TLB Common Region
|
||||
Segment Table Entry arrays
|
||||
.
|
||||
Counter:144 Name:L1D_ONCHIP_L3_SOURCED_WRITES
|
||||
Short-Description:L1D On-Chip L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an On Chip Level-3 cache without intervention
|
||||
.
|
||||
Counter:145 Name:L1D_OFFCHIP_L3_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Chip L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an Off Chip/On Book Level-3 cache without
|
||||
intervention
|
||||
.
|
||||
Counter:146 Name:L1D_OFFBOOK_L3_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Book L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an Off Book Level-3 cache without intervention
|
||||
.
|
||||
Counter:147 Name:L1D_ONBOOK_L4_SOURCED_WRITES
|
||||
Short-Description:L1D On-Book L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an On Book Level-4 cache
|
||||
.
|
||||
Counter:148 Name:L1D_OFFBOOK_L4_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Book L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an Off Book Level-4 cache
|
||||
@@ -104,16 +123,19 @@ cache line was sourced from an Off Book Level-4 cache
|
||||
# C .. constrained
|
||||
#
|
||||
Counter:149 Name:TX_NC_TEND
|
||||
Short-Description:Completed TEND instructions in non-constrained TX mode
|
||||
Description:
|
||||
A TEND instruction has completed in a nonconstrained
|
||||
transactional-execution mode
|
||||
.
|
||||
Counter:150 Name:L1D_ONCHIP_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1D On-Chip L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from a On Chip Level-3 cache with intervention
|
||||
.
|
||||
Counter:151 Name:L1D_OFFCHIP_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1D Off-Chip L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an Off Chip/On Book Level-3 cache with
|
||||
@@ -121,73 +143,86 @@ intervention
|
||||
.
|
||||
# XXX Remove SOURCED from L1D_OFFBOOK_L3_SOURCED_WRITES...
|
||||
Counter:152 Name:L1D_OFFBOOK_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1D Off-Book L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an Off Book Level-3 cache with intervention
|
||||
.
|
||||
Counter:153 Name:L1I_ONCHIP_L3_SOURCED_WRITES
|
||||
Short-Description:L1I On-Chip L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an On Chip Level-3 cache without
|
||||
intervention
|
||||
.
|
||||
Counter:154 Name:L1I_OFFCHIP_L3_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Chip L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an Off Chip/On Book Level-3 cache
|
||||
without intervention
|
||||
.
|
||||
Counter:155 Name:L1I_OFFBOOK_L3_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Book L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an Off Book Level-3 cache without
|
||||
intervention
|
||||
.
|
||||
Counter:156 Name:L1I_ONBOOK_L4_SOURCED_WRITES
|
||||
Short-Description:L1I On-Book L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an On Book Level-4 cache
|
||||
.
|
||||
Counter:157 Name:L1I_OFFBOOK_L4_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Book L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an Off Book Level-4 cache
|
||||
.
|
||||
Counter:158 Name:TX_C_TEND
|
||||
Short-Description:Completed TEND instructions in constrained TX mode
|
||||
Description:
|
||||
A TEND instruction has completed in a constrained transactional-execution
|
||||
mode
|
||||
.
|
||||
Counter:159 Name:L1I_ONCHIP_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1I On-Chip L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an On Chip Level-3 cache with
|
||||
intervention
|
||||
.
|
||||
Counter:160 Name:L1I_OFFCHIP_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1I Off-Chip L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an Off Chip/On Book Level-3 cache
|
||||
with intervention
|
||||
.
|
||||
Counter:161 Name:L1I_OFFBOOK_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1I Off-Book L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an Off Book Level-3 cache with
|
||||
intervention
|
||||
.
|
||||
Counter:177 Name:TX_NC_TABORT
|
||||
Short-Description:Aborted transactions in non-constrained TX mode
|
||||
Description:
|
||||
A transaction abort has occurred in a nonconstrained
|
||||
transactional-execution mode
|
||||
.
|
||||
Counter:178 Name:TX_C_TABORT_NO_SPECIAL
|
||||
Short-Description:Aborted transactions in constrained TX mode not using special completion logic
|
||||
Description:
|
||||
A transaction abort has occurred in a constrained transactional-execution
|
||||
mode and the CPU is not using any special logic to allow the transaction
|
||||
to complete
|
||||
.
|
||||
Counter:179 Name:TX_C_TABORT_SPECIAL
|
||||
Short-Description:Aborted transactions in constrained TX mode using special completion logic
|
||||
Description:
|
||||
A transaction abort has occurred in a constrained transactional-execution
|
||||
mode and the CPU is using special logic to allow the transaction to
|
||||
|
||||
@@ -26,4 +26,5 @@
|
||||
2964 => 'cpum-cf-extended-z13.ctr',
|
||||
2965 => 'cpum-cf-extended-z13.ctr',
|
||||
3906 => 'cpum-cf-extended-z14.ctr',
|
||||
3907 => 'cpum-cf-extended-z14.ctr',
|
||||
};
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
#
|
||||
# Basic-sampling mode
|
||||
Counter: 0xB0000 Name:SF_CYCLES_BASIC
|
||||
Short-Description:Sample CPU Cycles Using Basic-sampling Mode
|
||||
Description:
|
||||
Sample CPU cycles using basic-sampling mode
|
||||
.
|
||||
# Diagnostic-sampling mode (includes basic-sampling)
|
||||
Counter: 0xBD000 Name:SF_CYCLES_BASIC_DIAG
|
||||
Short-Description:Sample CPU Cycle Using Diagnostic-sampling Mode (not for ordinary use)
|
||||
Description:
|
||||
Sample CPU cycle using diagnostic-sampling mode (not for ordinary use)
|
||||
.
|
||||
|
||||
@@ -7,7 +7,7 @@ SUBSYSTEM!="block", GOTO="ra_end"
|
||||
|
||||
ACTION!="add", GOTO="ra_change"
|
||||
# on device add set initial readahead to 512 (instead of in kernel 128)
|
||||
KERNEL=="sd*[!0-9]", WAIT_FOR="queue/read_ahead_kb", ATTR{queue/read_ahead_kb}="512"
|
||||
KERNEL=="sd*[!0-9]", TEST=="queue/read_ahead_kb", ATTR{queue/read_ahead_kb}="512"
|
||||
|
||||
LABEL="ra_change"
|
||||
|
||||
|
||||
@@ -821,10 +821,13 @@ static char *hmcdrv_parse_line(char *line, char *namebuf,
|
||||
if ((*line != '\0') && (*line != '\n')) {
|
||||
field = hmcdrv_parse_ntoken(field, line, &attr);
|
||||
|
||||
while ((*line != '\0') &&
|
||||
(*line != '\n') &&
|
||||
!isspace(*line))
|
||||
while ((*line != '\0') && (*line != '\n')) {
|
||||
if (isspace(*line))
|
||||
break;
|
||||
if (field == 1 && isdigit(*line))
|
||||
break;
|
||||
++line; /* search end of field */
|
||||
}
|
||||
}
|
||||
} /* while */
|
||||
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Allocate memory or panic in case of failure
|
||||
*
|
||||
@@ -125,4 +129,10 @@ int __util_vsprintf(const char *func, const char *file, int line,
|
||||
char *util_strcat_realloc(char *str1, const char *str2);
|
||||
void util_str_toupper(char *str);
|
||||
|
||||
char *util_strstrip(char *s);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /** LIB_UTIL_LIBC_H @} */
|
||||
|
||||
52
include/lib/vmcp.h
Normal file
52
include/lib/vmcp.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* vmcp - z/VM CP command library
|
||||
*
|
||||
* Copyright IBM Corp. 2005, 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 LIB_VMCP_H
|
||||
#define LIB_VMCP_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define VMCP_DEVICE_NODE "/dev/vmcp" /* VMCP device name */
|
||||
#define VMCP_DEFAULT_BUFSZ 0x4000 /* VMCP default buffer size */
|
||||
|
||||
/*
|
||||
* Error codes returned by vmcp() function. This enables the caller
|
||||
* to emit a detailed error message on the type of failure.
|
||||
*/
|
||||
#define VMCP_SUCCESS 0 /* VMCP operation completed successfully */
|
||||
#define VMCP_ERR_OPEN (-1) /* Error Open of VMCP device */
|
||||
#define VMCP_ERR_SETBUF (-2) /* Error VMCP_SETBUF ioctl */
|
||||
#define VMCP_ERR_READ (-3) /* Error VMCP read system call */
|
||||
#define VMCP_ERR_GETCODE (-4) /* Error VMCP_GETCODE ioctl */
|
||||
#define VMCP_ERR_GETSIZE (-5) /* Error VMCP_GETSIZE ioctl */
|
||||
#define VMCP_ERR_TOOSMALL (-6) /* Error VMCP buffer too small for
|
||||
* response
|
||||
*/
|
||||
#define VMCP_ERR_WRITE (-7) /* Error VMCP write system call */
|
||||
|
||||
struct vmcp_parm {
|
||||
const char *cpcmd;
|
||||
unsigned int buffer_size;
|
||||
bool do_upper;
|
||||
int cprc;
|
||||
char *response;
|
||||
unsigned int response_size;
|
||||
};
|
||||
|
||||
int vmcp(struct vmcp_parm *cp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -445,7 +445,7 @@ static void set_target_type_auto(const char *arg)
|
||||
{
|
||||
char busid[10];
|
||||
|
||||
if (access(arg, R_OK) == 0) {
|
||||
if (access(arg, F_OK) == 0) {
|
||||
set_target_type(TT_NODE, 1);
|
||||
return;
|
||||
}
|
||||
@@ -539,12 +539,19 @@ static void parse_chreipl_options(int argc, char *argv[])
|
||||
parse_pos_args(&argv[optind], argc - optind);
|
||||
}
|
||||
|
||||
static void verify_write_access(const char *path, const char *attr)
|
||||
static void check_exists(const char *path, const char *attr)
|
||||
{
|
||||
char fpath[PATH_MAX];
|
||||
|
||||
snprintf(fpath, sizeof(fpath), "/sys/firmware/%s", path);
|
||||
if (access(fpath, W_OK) != 0)
|
||||
if (access(fpath, F_OK) != 0)
|
||||
ERR_EXIT("System does not allow to set %s", attr);
|
||||
}
|
||||
|
||||
static void write_str_optional(char *string, char *file, int exit_on_fail,
|
||||
const char *attr)
|
||||
{
|
||||
if (write_str_errno(string, file) && exit_on_fail)
|
||||
ERR_EXIT("System does not allow to set %s", attr);
|
||||
}
|
||||
|
||||
@@ -585,22 +592,18 @@ static void chreipl_ccw(void)
|
||||
ERR_EXIT("Could not find DASD CCW device \"%s\"", l.busid);
|
||||
}
|
||||
|
||||
if (l.bootparms_set && strlen(l.bootparms) > BOOTPARMS_CCW_MAX) {
|
||||
ERR_EXIT("Maximum boot parameter length exceeded (%zu/%u)",
|
||||
strlen(l.bootparms), BOOTPARMS_CCW_MAX);
|
||||
}
|
||||
|
||||
/*
|
||||
* On old systems that use CCW reipl loadparm cannot be set
|
||||
*/
|
||||
if (l.loadparm_set)
|
||||
verify_write_access("reipl/ccw/loadparm", "loadparm");
|
||||
if (l.bootparms_set) {
|
||||
verify_write_access("reipl/ccw/parm", "boot parameters");
|
||||
if (strlen(l.bootparms) > BOOTPARMS_CCW_MAX)
|
||||
ERR_EXIT("Maximum boot parameter length exceeded "
|
||||
"(%zu/%u)", strlen(l.bootparms),
|
||||
BOOTPARMS_CCW_MAX);
|
||||
}
|
||||
if (access("/sys/firmware/reipl/ccw/parm", W_OK) == 0)
|
||||
write_str(l.bootparms, "reipl/ccw/parm");
|
||||
if (access("/sys/firmware/reipl/ccw/loadparm", W_OK) == 0)
|
||||
write_str(l.loadparm, "reipl/ccw/loadparm");
|
||||
write_str_optional(l.loadparm, "reipl/ccw/loadparm", l.loadparm_set,
|
||||
"loadparm");
|
||||
write_str_optional(l.bootparms, "reipl/ccw/parm", l.bootparms_set,
|
||||
"boot parameters");
|
||||
write_str(l.busid, "reipl/ccw/device");
|
||||
write_str("ccw", "reipl/reipl_type");
|
||||
|
||||
@@ -616,27 +619,21 @@ static void chreipl_fcp(void)
|
||||
ERR_EXIT("Device is on cio_ignore list, try \"cio_ignore -r %s\"?", l.busid);
|
||||
ERR_EXIT("Could not find FCP device \"%s\"", l.busid);
|
||||
}
|
||||
verify_write_access("reipl/fcp/device", "\"fcp\" re-IPL target");
|
||||
check_exists("reipl/fcp/device", "\"fcp\" re-IPL target");
|
||||
if (l.bootparms_set && strlen(l.bootparms) > BOOTPARMS_FCP_MAX) {
|
||||
ERR_EXIT("Maximum boot parameter length exceeded (%zu/%u)",
|
||||
strlen(l.bootparms), BOOTPARMS_FCP_MAX);
|
||||
}
|
||||
/*
|
||||
* On old systems the FCP reipl loadparm cannot be set
|
||||
*/
|
||||
if (l.loadparm_set)
|
||||
verify_write_access("reipl/fcp/loadparm", "loadparm");
|
||||
if (l.bootparms_set) {
|
||||
verify_write_access("reipl/fcp/scp_data", "boot parameters");
|
||||
if (strlen(l.bootparms) > BOOTPARMS_FCP_MAX)
|
||||
ERR_EXIT("Maximum boot parameter length exceeded "
|
||||
"(%zu/%u)", strlen(l.bootparms),
|
||||
BOOTPARMS_FCP_MAX);
|
||||
}
|
||||
if (access("/sys/firmware/reipl/fcp/scp_data", W_OK) == 0)
|
||||
write_str(l.bootparms, "reipl/fcp/scp_data");
|
||||
if (access("/sys/firmware/reipl/fcp/loadparm", W_OK) == 0)
|
||||
write_str(l.loadparm, "reipl/fcp/loadparm");
|
||||
write_str_optional(l.loadparm, "reipl/fcp/loadparm", l.loadparm_set,
|
||||
"loadparm");
|
||||
write_str_optional(l.bootparms, "reipl/fcp/scp_data", l.bootparms_set,
|
||||
"boot parameters");
|
||||
write_str(l.busid, "reipl/fcp/device");
|
||||
write_str(l.wwpn, "reipl/fcp/wwpn");
|
||||
write_str(l.lun, "reipl/fcp/lun");
|
||||
write_str("fcp", "reipl/reipl_type");
|
||||
/*
|
||||
* set the boot record logical block address. Master boot
|
||||
* record. It is always 0 for Linux
|
||||
@@ -645,6 +642,7 @@ static void chreipl_fcp(void)
|
||||
if (!l.bootprog_set)
|
||||
sprintf(l.bootprog, "0");
|
||||
write_str(l.bootprog, "reipl/fcp/bootprog");
|
||||
write_str("fcp", "reipl/reipl_type");
|
||||
|
||||
print_fcp(0, 0);
|
||||
}
|
||||
@@ -652,17 +650,14 @@ static void chreipl_fcp(void)
|
||||
static void chreipl_nss(void)
|
||||
{
|
||||
check_nss_opts();
|
||||
verify_write_access("reipl/nss/name", "\"nss\" re-IPL target");
|
||||
if (l.bootparms_set) {
|
||||
verify_write_access("reipl/nss/parm", "boot parameters");
|
||||
if (strlen(l.bootparms) > BOOTPARMS_NSS_MAX)
|
||||
ERR_EXIT("Maximum boot parameter length exceeded "
|
||||
"(%zu/%u)", strlen(l.bootparms),
|
||||
BOOTPARMS_NSS_MAX);
|
||||
check_exists("reipl/nss/name", "\"nss\" re-IPL target");
|
||||
if (l.bootparms_set && strlen(l.bootparms) > BOOTPARMS_NSS_MAX) {
|
||||
ERR_EXIT("Maximum boot parameter length exceeded (%zu/%u)",
|
||||
strlen(l.bootparms), BOOTPARMS_NSS_MAX);
|
||||
}
|
||||
write_str_optional(l.bootparms, "reipl/nss/parm", l.bootparms_set,
|
||||
"boot parameters");
|
||||
write_str(l.nss_name, "reipl/nss/name");
|
||||
if (access("/sys/firmware/reipl/nss/parm", W_OK) == 0)
|
||||
write_str(l.bootparms, "reipl/nss/parm");
|
||||
write_str("nss", "reipl/reipl_type");
|
||||
print_nss(0);
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ int write_str_errno(char *string, char *file)
|
||||
snprintf(path, sizeof(path), "/sys/firmware/%s", file);
|
||||
fh = open(path, O_WRONLY);
|
||||
if (fh < 0)
|
||||
ERR_EXIT_ERRNO("Could not open \"%s\"", file);
|
||||
return errno;
|
||||
if (write(fh, value, strlen(value)) < 0)
|
||||
return errno;
|
||||
close(fh);
|
||||
|
||||
@@ -198,3 +198,33 @@ int __util_vsprintf(const char *func, const char *file, int line,
|
||||
rc != -1, "Could not format string\n");
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip leading and trailing spaces from string
|
||||
*
|
||||
* Remove string \a s leading and trailing spaces
|
||||
*
|
||||
* @param[in,out] s String to manipulate
|
||||
*
|
||||
* @returns Pointer to first non-space character in string \a s
|
||||
*/
|
||||
char *util_strstrip(char *s)
|
||||
{
|
||||
size_t size;
|
||||
char *end;
|
||||
|
||||
size = strlen(s);
|
||||
|
||||
if (!size)
|
||||
return s;
|
||||
|
||||
end = s + size - 1;
|
||||
while (end >= s && isspace(*end))
|
||||
end--;
|
||||
*(end + 1) = '\0';
|
||||
|
||||
while (*s && isspace(*s))
|
||||
s++;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -10,10 +10,13 @@
|
||||
//! [code]
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lib/util_libc.h"
|
||||
#include "lib/util_panic.h"
|
||||
|
||||
#define EXAMPLE_WORD " /sys/devices/system/cpu "
|
||||
|
||||
/*
|
||||
* Demonstrate that out of memory is automatically handled via panic()
|
||||
*/
|
||||
@@ -22,6 +25,12 @@ int main(void)
|
||||
unsigned long ulong_max = (unsigned long)-1;
|
||||
void *ptr;
|
||||
char *zeroes, *str;
|
||||
char buffer[sizeof(EXAMPLE_WORD)];
|
||||
|
||||
strcat(buffer, EXAMPLE_WORD);
|
||||
fprintf(stderr, "Try to remove leading and trailing spaces from "
|
||||
"\"%s\"\nresult = \"%s\"\n", EXAMPLE_WORD,
|
||||
util_strstrip(buffer));
|
||||
|
||||
/* Use util_strcat_realloc() for string concatenation */
|
||||
fprintf(stderr, "Try to concatenate \"Hello\", \", \" and \"world!\": ");
|
||||
|
||||
18
libvmcp/Makefile
Normal file
18
libvmcp/Makefile
Normal file
@@ -0,0 +1,18 @@
|
||||
include ../common.mak
|
||||
|
||||
lib = libvmcp.a
|
||||
|
||||
examples = vmcp_example
|
||||
|
||||
all: $(lib) $(examples)
|
||||
|
||||
objects = vmcp.o
|
||||
|
||||
$(lib): $(objects)
|
||||
|
||||
install: all
|
||||
|
||||
vmcp_example: vmcp_example.o $(lib) $(rootdir)/libutil/libutil.a
|
||||
|
||||
clean:
|
||||
rm -f *.o $(lib) $(examples)
|
||||
134
libvmcp/vmcp.c
Normal file
134
libvmcp/vmcp.c
Normal file
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* vmcp - z/VM CP function library
|
||||
*
|
||||
* Copyright IBM Corp. 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "lib/util_libc.h"
|
||||
#include "lib/vmcp.h"
|
||||
|
||||
#define VMCP_DEVICE_NODE "/dev/vmcp"
|
||||
#define VMCP_GETSIZE _IOR(0x10, 3, int)
|
||||
#define VMCP_SETBUF _IOW(0x10, 2, int)
|
||||
#define VMCP_GETCODE _IOR(0x10, 1, int)
|
||||
|
||||
/*
|
||||
* Read at most COUNT bytes from FD into memory at location BUF.
|
||||
* Return number of bytes read on success, -1 on error.
|
||||
*/
|
||||
static ssize_t read_buffer(int fd, char *buf, ssize_t count)
|
||||
{
|
||||
ssize_t ret, done;
|
||||
|
||||
for (done = 0; done < (ssize_t)count; done += ret) {
|
||||
ret = read(fd, &buf[done], count - done);
|
||||
if (ret == -1 && errno == EINTR)
|
||||
continue;
|
||||
if (ret == -1)
|
||||
return -1;
|
||||
if (ret == 0)
|
||||
break;
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit a command to z/VM CP and return the response, the size in bytes
|
||||
* of the response and CP command response code.
|
||||
*
|
||||
* The member response contains the response from CP. It is a pointer
|
||||
* to a malloc'ed buffer which must be freed by the caller when the return
|
||||
* code is zero or VMCP_ERR_TOOSMALL.
|
||||
*
|
||||
* @param[in,out] cmd Pointer to struct vmcp_parm.
|
||||
* @param[in] cpcmd Pointer to CP command string.
|
||||
* @param[in] do_upper If true convert cpcmd string to upper case.
|
||||
* @param[out] cprc Return code of the CP command.
|
||||
* @param[out] response Return buffer, has been allocated via malloc()
|
||||
* must be freed by caller, see below.
|
||||
* @param[out] response_size Size of the response in bytes, can be larger
|
||||
* than buffer_size.
|
||||
*
|
||||
* @returns Zero on success or a negative error number on failure.
|
||||
* @retval VMCP_SUCCESS Success valid members: cprc, response,
|
||||
* response_size
|
||||
* @retval VMCP_ERR_OPEN Error opening VMCP device, valid members: none
|
||||
* @retval VMCP_ERR_SETBUF Error setting buffer, valid members: none
|
||||
* @retval VMCP_ERR_GETCODE Error getting cp exit code, valid members: none
|
||||
* @retval VMCP_ERR_WRITE Error write CP command, valid members: none
|
||||
* @retval VMCP_ERR_GETSIZE Error reading response size,
|
||||
* valid members: cprc
|
||||
* @retval VMCP_ERR_READ Error reading resp
|
||||
* @retval VMCP_ERR_TOOSMALL Error response buffer too small, response
|
||||
* truncated, valid members: cprc, response,
|
||||
* response_size
|
||||
*/
|
||||
int vmcp(struct vmcp_parm *cmd)
|
||||
{
|
||||
int rc = VMCP_SUCCESS, fd, len;
|
||||
char *cpcmd;
|
||||
|
||||
cmd->response = NULL;
|
||||
cmd->response_size = 0;
|
||||
cmd->cprc = 0;
|
||||
|
||||
fd = open(VMCP_DEVICE_NODE, O_RDWR);
|
||||
if (fd == -1)
|
||||
return VMCP_ERR_OPEN;
|
||||
|
||||
cpcmd = util_strdup(cmd->cpcmd); /* Exits on failure */
|
||||
if (cmd->do_upper)
|
||||
util_str_toupper(cpcmd);
|
||||
|
||||
if (ioctl(fd, VMCP_SETBUF, &cmd->buffer_size) == -1) {
|
||||
rc = VMCP_ERR_SETBUF;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (write(fd, cpcmd, strlen(cpcmd)) == -1) {
|
||||
rc = VMCP_ERR_WRITE;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (ioctl(fd, VMCP_GETCODE, &cmd->cprc) == -1) {
|
||||
rc = VMCP_ERR_GETCODE;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (ioctl(fd, VMCP_GETSIZE, &cmd->response_size) == -1) {
|
||||
rc = VMCP_ERR_GETSIZE;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (cmd->response_size <= cmd->buffer_size) {
|
||||
len = cmd->response_size;
|
||||
} else {
|
||||
len = cmd->buffer_size;
|
||||
rc = VMCP_ERR_TOOSMALL;
|
||||
}
|
||||
|
||||
/* Exits on failure */
|
||||
cmd->response = (char *)util_zalloc(len + 1);
|
||||
|
||||
if (read_buffer(fd, cmd->response, len) == -1) {
|
||||
rc = VMCP_ERR_READ;
|
||||
free(cmd->response);
|
||||
cmd->response = NULL;
|
||||
}
|
||||
|
||||
fail:
|
||||
close(fd);
|
||||
free(cpcmd);
|
||||
return rc;
|
||||
}
|
||||
65
libvmcp/vmcp_example.c
Normal file
65
libvmcp/vmcp_example.c
Normal file
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* vmcp_example - Example program for vmcp.c
|
||||
*
|
||||
* Copyright 2018 IBM Corp.
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
//! [code]
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <err.h>
|
||||
|
||||
#include "lib/vmcp.h"
|
||||
|
||||
/*
|
||||
* Demonstrate vmcp() function usage
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
struct vmcp_parm cp;
|
||||
int rc;
|
||||
|
||||
cp.cpcmd = "q osa";
|
||||
cp.buffer_size = VMCP_DEFAULT_BUFSZ;
|
||||
cp.do_upper = true;
|
||||
|
||||
rc = vmcp(&cp);
|
||||
|
||||
switch (rc) {
|
||||
case VMCP_SUCCESS:
|
||||
printf("%s\n", cp.response);
|
||||
free(cp.response);
|
||||
break;
|
||||
case VMCP_ERR_OPEN:
|
||||
errx(EXIT_FAILURE, "Could not open device %s", VMCP_DEVICE_NODE);
|
||||
break;
|
||||
case VMCP_ERR_SETBUF:
|
||||
errx(EXIT_FAILURE, "Could not set buffer size");
|
||||
break;
|
||||
case VMCP_ERR_GETCODE:
|
||||
errx(EXIT_FAILURE, "Could not query return code");
|
||||
break;
|
||||
case VMCP_ERR_GETSIZE:
|
||||
errx(EXIT_FAILURE, "Could not query response size");
|
||||
break;
|
||||
case VMCP_ERR_WRITE:
|
||||
errx(EXIT_FAILURE, "Could not issue CP command");
|
||||
break;
|
||||
case VMCP_ERR_READ:
|
||||
errx(EXIT_FAILURE, "Could not read CP response");
|
||||
break;
|
||||
case VMCP_ERR_TOOSMALL:
|
||||
free(cp.response);
|
||||
printf("Response truncated (requires %u bytes)\n",
|
||||
cp.response_size);
|
||||
errx(EXIT_FAILURE, "Response buffer (%u bytes) too small",
|
||||
cp.buffer_size);
|
||||
break;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//! [code]
|
||||
@@ -1,7 +1,7 @@
|
||||
include ../common.mak
|
||||
|
||||
SCRIPTS = dbginfo.sh zfcpdbf scsi_logging_level
|
||||
MAN_PAGES = dbginfo.sh.1 zfcpdbf.1
|
||||
SCRIPTS = dbginfo.sh zfcpdbf zipl-switch-to-blscfg scsi_logging_level
|
||||
MAN_PAGES = dbginfo.sh.1 zfcpdbf.1 zipl-switch-to-blscfg.1
|
||||
|
||||
all:
|
||||
|
||||
|
||||
@@ -182,11 +182,14 @@ readonly OUTPUT_FILE_XML="${WORKPATH}domain_xml"
|
||||
# File that includes the docker inspect output
|
||||
readonly OUTPUT_FILE_DOCKER="${WORKPATH}docker_inspect.out"
|
||||
|
||||
# File that includes nvme related information
|
||||
readonly OUTPUT_FILE_NVME="${WORKPATH}nvme.out"
|
||||
|
||||
# Mount point of the debug file system
|
||||
readonly MOUNT_POINT_DEBUGFS="/sys/kernel/debug"
|
||||
|
||||
# The amount of steps running the whole collections
|
||||
readonly COLLECTION_COUNT=11
|
||||
readonly COLLECTION_COUNT=12
|
||||
|
||||
# The kernel version (e.g. '2' from 2.6.32 or '3' from 3.2.1)
|
||||
readonly KERNEL_VERSION=$(uname -r 2>/dev/null | cut -d'.' -f1)
|
||||
@@ -471,6 +474,8 @@ VM_CMDS="q userid\
|
||||
:q privclass\
|
||||
:q cplevel\
|
||||
:q cpservice\
|
||||
:q cpprot user\
|
||||
:q specex\
|
||||
:q ssi\
|
||||
:q cpus\
|
||||
:q srm\
|
||||
@@ -826,6 +831,25 @@ collect_docker() {
|
||||
pr_log_stdout " "
|
||||
}
|
||||
|
||||
########################################
|
||||
collect_nvme() {
|
||||
local NVME
|
||||
|
||||
pr_syslog_stdout "11 of ${COLLECTION_COUNT}: Collecting nvme output"
|
||||
call_run_command "nvme list" "${OUTPUT_FILE_NVME}"
|
||||
|
||||
for NVME in /dev/nvme[0-9]*; do
|
||||
if [ -c $NVME ]; then
|
||||
call_run_command "smartctl -x $NVME" "${OUTPUT_FILE_NVME}"
|
||||
call_run_command "nvme fw-log $NVME" "${OUTPUT_FILE_NVME}"
|
||||
call_run_command "nvme smart-log $NVME" "${OUTPUT_FILE_NVME}"
|
||||
call_run_command "nvme error-log $NVME" "${OUTPUT_FILE_NVME}"
|
||||
fi
|
||||
done
|
||||
|
||||
pr_log_stdout " "
|
||||
}
|
||||
|
||||
########################################
|
||||
post_processing() {
|
||||
local file_mtime
|
||||
@@ -833,7 +857,7 @@ post_processing() {
|
||||
local tmp_file
|
||||
local file_name
|
||||
|
||||
pr_syslog_stdout "11 of ${COLLECTION_COUNT}: Postprocessing"
|
||||
pr_syslog_stdout "${COLLECTION_COUNT} of ${COLLECTION_COUNT}: Postprocessing"
|
||||
|
||||
find "${WORKPATH}etc/libvirt/qemu/" -maxdepth 1 -name "*.xml" 2>/dev/null | while IFS= read -r file_name; do
|
||||
file_mtime_epoche=$(stat --format=%Y "${file_name}")
|
||||
@@ -1118,6 +1142,8 @@ collect_domain_xml
|
||||
|
||||
collect_docker
|
||||
|
||||
collect_nvme
|
||||
|
||||
post_processing
|
||||
|
||||
create_package
|
||||
|
||||
213
scripts/zipl-switch-to-blscfg
Executable file
213
scripts/zipl-switch-to-blscfg
Executable file
@@ -0,0 +1,213 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# zipl-switch-to-blscfg - Switch zipl to use BootLoaderSpec configuration
|
||||
#
|
||||
# Copyright 2018 Red Hat, Inc.
|
||||
#
|
||||
# s390-tools is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the MIT license. See LICENSE for details.
|
||||
#
|
||||
|
||||
readonly SCRIPTNAME="${0##*/}"
|
||||
|
||||
declare -A zipl_to_bls
|
||||
zipl_to_bls["image"]="linux"
|
||||
zipl_to_bls["ramdisk"]="initrd"
|
||||
zipl_to_bls["parameters"]="options"
|
||||
|
||||
print_error() {
|
||||
echo "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
function on_exit() {
|
||||
if ! rm -rf $TMP; then
|
||||
echo "Delete temporary files failed!" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
if ! TMP="$(mktemp -d)"; then
|
||||
print_error "Creating a temporary dir for config files failed!"
|
||||
fi
|
||||
|
||||
trap 'on_exit' EXIT
|
||||
|
||||
print_version() {
|
||||
cat <<EOF
|
||||
${SCRIPTNAME}: version %S390_TOOLS_VERSION%
|
||||
Copyright Red Hat, Inc. 2018
|
||||
EOF
|
||||
}
|
||||
|
||||
print_usage()
|
||||
{
|
||||
print_version
|
||||
|
||||
cat <<EOF
|
||||
|
||||
Usage: ${SCRIPTNAME} [OPTIONS]
|
||||
|
||||
Switches the zipl boot-loader configuration to use BootLoaderSpec files.
|
||||
|
||||
Options:
|
||||
|
||||
-h, --help print this help and exit
|
||||
-v, --version print version information and exit
|
||||
--backup-suffix=SUFFIX suffix used for backup files, defaults to .bak
|
||||
--bls-directory=DIR path to generate BLS files, defaults to /boot/loader/entries
|
||||
--config-file=FILE path to zipl configuration file, defaults to /etc/zipl.conf
|
||||
--ignore-default ignore the default option from the zipl configuration file
|
||||
--use-version-name use the section kernel version as the BLS file name
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
OPTS="$(getopt -o hv --long help,version,backup-suffix:,bls-directory:,config-file:,\
|
||||
ignore-default,use-version-name -n \'$SCRIPTNAME\' -- "$@")"
|
||||
eval set -- "$OPTS"
|
||||
|
||||
BACKUP_SUFFIX=.bak
|
||||
BLS_DIR="/boot/loader/entries"
|
||||
CMDLINE_LINUX_DEBUG=" systemd.log_level=debug systemd.log_target=kmsg"
|
||||
LINUX_DEBUG_VERSION_POSTFIX="_with_debugging"
|
||||
LINUX_DEBUG_TITLE_POSTFIX=" with debugging"
|
||||
CONFIG="/etc/zipl.conf"
|
||||
|
||||
while [ ${#} -gt 0 ]; do
|
||||
case "$1" in
|
||||
--help|-h)
|
||||
print_usage
|
||||
exit 0
|
||||
;;
|
||||
--version|-v)
|
||||
print_version
|
||||
exit 0
|
||||
;;
|
||||
--backup-suffix)
|
||||
BACKUP_SUFFIX=${2}
|
||||
shift
|
||||
;;
|
||||
--bls-directory)
|
||||
BLS_DIR=${2}
|
||||
shift
|
||||
;;
|
||||
--config-file)
|
||||
CONFIG=${2}
|
||||
shift
|
||||
;;
|
||||
--ignore-default)
|
||||
ignore_default=true
|
||||
;;
|
||||
--use-version-name)
|
||||
version_name=true
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo >&2
|
||||
echo "${SCRIPTNAME}: invalid option \"${1}\"" >&2
|
||||
echo "Try '${SCRIPTNAME} --help' for more information" >&2
|
||||
echo >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
TMP_CONFIG="${TMP}/${CONFIG##*/}"
|
||||
|
||||
[[ -d "$BLS_DIR" ]] || mkdir -m 0700 -p "$BLS_DIR"
|
||||
|
||||
if [ -f /etc/machine-id ]; then
|
||||
read MACHINE_ID < /etc/machine-id
|
||||
MACHINE_ID=${MACHINE_ID}-
|
||||
fi
|
||||
|
||||
count=0
|
||||
OUTPUT=""
|
||||
TARGET=""
|
||||
while IFS='= ' read key val; do
|
||||
# for BLS the default kernel is always the latest one
|
||||
if [[ $key == \#* ]] || [[ $key == "default" && $ignore_default == true ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# remove spaces
|
||||
key="$(echo $key | sed -e 's/^[ \t"]*//;s/[ \t"]*$//')"
|
||||
|
||||
if [[ $key = \[*] ]]; then
|
||||
if [[ $key == "[defaultboot]" ]]; then
|
||||
OUTPUT=${TMP_CONFIG}
|
||||
echo $key >> ${OUTPUT}
|
||||
else
|
||||
key="${key%\]}"
|
||||
key="${key#\[}"
|
||||
section=$key
|
||||
OUTPUT=${BLS_DIR}/${MACHINE_ID}${section}.conf
|
||||
if [ -f "${OUTPUT}" ]; then
|
||||
print_error "BLS file ${OUTPUT} already exists"
|
||||
fi
|
||||
fi
|
||||
elif [[ $val ]]; then
|
||||
val="$(echo $val | sed -e 's/^[ \t"]*//;s/[ \t"]*$//')"
|
||||
if [[ $key == "target" ]]; then
|
||||
if [ -z ${TARGET} ]; then
|
||||
echo $key=$val >> ${TMP_CONFIG}
|
||||
TARGET=$val
|
||||
else if [ "${TARGET}" != "${val}" ]; then
|
||||
print_error "BLS is only supported if all sections have the same target"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if [ -n "${zipl_to_bls[$key]}" ]; then
|
||||
if [[ $key = "image" && $version_name == true ]]; then
|
||||
if [[ $val = *"vmlinuz-"* ]]; then
|
||||
version="${val##*/vmlinuz-}"
|
||||
else
|
||||
version="${val##*/}"
|
||||
fi
|
||||
echo "version $version" >> ${OUTPUT}
|
||||
if [[ $version = *"rescue"* ]]; then
|
||||
FILENAME=${BLS_DIR}/${MACHINE_ID}0-rescue.conf
|
||||
else
|
||||
FILENAME=${BLS_DIR}/${MACHINE_ID}${version}.conf
|
||||
fi
|
||||
|
||||
if [[ ${OUTPUT} != ${FILENAME} ]]; then
|
||||
if [ -f "${FILENAME}" ]; then
|
||||
print_error "BLS file ${FILENAME} already exists"
|
||||
fi
|
||||
mv ${OUTPUT} ${FILENAME}
|
||||
if [ ! $? -eq 0 ]; then
|
||||
print_error "Creating BLS file ${FILENAME} failed"
|
||||
fi
|
||||
OUTPUT=${FILENAME}
|
||||
fi
|
||||
elif [[ $key = "image" ]]; then
|
||||
echo "version $section" >> ${OUTPUT}
|
||||
fi
|
||||
|
||||
echo "${zipl_to_bls[$key]} ${val}" >> ${OUTPUT}
|
||||
else
|
||||
echo $key=$val >> ${TMP_CONFIG}
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done < "${CONFIG}"
|
||||
|
||||
if [ -f "${CONFIG}${BACKUP_SUFFIX}" ]; then
|
||||
print_error "Backup file ${CONFIG}${BACKUP_SUFFIX} already exists"
|
||||
fi
|
||||
|
||||
cp -af "${CONFIG}" "${CONFIG}${BACKUP_SUFFIX}"
|
||||
mv "${TMP_CONFIG}" "${CONFIG}"
|
||||
|
||||
zipl > /dev/null
|
||||
if [ ! $? -eq 0 ]; then
|
||||
mv "${CONFIG}${BACKUP_SUFFIX}" "${CONFIG}"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
45
scripts/zipl-switch-to-blscfg.1
Normal file
45
scripts/zipl-switch-to-blscfg.1
Normal file
@@ -0,0 +1,45 @@
|
||||
.TH ZIPL-SWITCH-TO-BLSCFG 1 "April 2018" "s390-tools"
|
||||
|
||||
.SH NAME
|
||||
zipl-switch-to-blscfg \- Switch zipl to use BootLoaderSpec configuration
|
||||
|
||||
.SH SYNOPSIS
|
||||
.br
|
||||
\fBzipl-switch-to-blscfg\fP [OPTIONS]
|
||||
.br
|
||||
\fBzipl-switch-to-blscfg\fP {\-h|\-v}
|
||||
|
||||
.SH DESCRIPTION
|
||||
This script switches the zipl boot-loader configuration to use BootLoaderSpec files
|
||||
to define IPL sections. For each Linux kernel defined in the zipl.conf config file,
|
||||
a BLS fragment is generated in the BLS directory specified. Also, the zipl.conf is
|
||||
modified it only contains global configurations, all IPL sections comes from BLS.
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-h\fP, \fB\-\-help\fP
|
||||
Print this help and exit
|
||||
|
||||
.TP
|
||||
\fB\-v\fP, \fB\-\-version\fP
|
||||
Print version information and exit
|
||||
|
||||
.TP
|
||||
\fB\-\-backup-suffix <SUFFIX>\fP
|
||||
The suffix used for backup files, defaults to .bak.
|
||||
|
||||
.TP
|
||||
\fB\-\-bls-directory <DIRECTORY>\fP
|
||||
The DIRECTORY where the BLS fragments will be generated. The directory is created if it doesn't exists, by default /boot/loader/entries is used.
|
||||
|
||||
.TP
|
||||
\fB\-\-config-file <FILE>\fP
|
||||
The FILE used for zipl configuration file, defaults to /etc/zipl.conf.
|
||||
|
||||
.TP
|
||||
\fB\-\-ignore-default\fP
|
||||
Ignore the default option from the zipl configuration file
|
||||
|
||||
.TP
|
||||
\fB\-\-use-version-name\fP
|
||||
Use the section kernel version as the BLS file name
|
||||
@@ -2,7 +2,9 @@ include ../common.mak
|
||||
|
||||
all: vmcp
|
||||
|
||||
vmcp: vmcp.o
|
||||
libs = $(rootdir)/libvmcp/libvmcp.a $(rootdir)/libutil/libutil.a
|
||||
|
||||
vmcp: vmcp.o $(libs)
|
||||
|
||||
install: all
|
||||
$(INSTALL) -d -m 755 $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR)/man8
|
||||
|
||||
171
vmcp/vmcp.c
171
vmcp/vmcp.c
@@ -4,7 +4,7 @@
|
||||
* Tool for accessing the control program of z/VM using the
|
||||
* kernel module vmcp
|
||||
* return codes:
|
||||
* 0: everything was fine (VMCP_OK)
|
||||
* 0: everything was fine (EXIT_SUCCESS)
|
||||
* 1: CP returned a nn zero response code (VMCP_CP)
|
||||
* 2: the response buffer was not large enough (VMCP_BUF)
|
||||
* 3: an internal Linux error occurred (VMCP_LIN)
|
||||
@@ -28,33 +28,58 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "vmcp.h"
|
||||
#include "lib/zt_common.h"
|
||||
#include "lib/vmcp.h"
|
||||
#include "lib/util_opt.h"
|
||||
#include "lib/util_prg.h"
|
||||
|
||||
#define MAXBUFFER 1048576
|
||||
#define MINBUFFER 4096
|
||||
#define MAXCMDLEN 240
|
||||
|
||||
#define VMCP_OK 0
|
||||
#define VMCP_CP 1
|
||||
#define VMCP_BUF 2
|
||||
#define VMCP_LIN 3
|
||||
#define VMCP_OPT 4
|
||||
|
||||
static int keep_case = 0;
|
||||
static int buffersize = 8192;
|
||||
static int buffersize = VMCP_DEFAULT_BUFSZ;
|
||||
static char command[MAXCMDLEN + 1];
|
||||
|
||||
static void print_help(const char *name)
|
||||
{
|
||||
printf("%s: z/VM CP command interface.\n%s", name, help_text);
|
||||
}
|
||||
static struct util_opt opt_vec[] = {
|
||||
UTIL_OPT_SECTION("OPTIONS"),
|
||||
{
|
||||
.option = { "keepcase", no_argument, NULL, 'k' },
|
||||
.desc = "Do not convert CP-command string to uppercase",
|
||||
},
|
||||
{
|
||||
.option = { "buffer", required_argument, NULL, 'b' },
|
||||
.argument = "SIZE",
|
||||
.desc = "Specify buffer size in bytes, kilobytes (k) "
|
||||
"or megabytes (M). SIZE range from 4096 to 1048576 "
|
||||
"bytes"
|
||||
},
|
||||
UTIL_OPT_HELP,
|
||||
UTIL_OPT_VERSION,
|
||||
UTIL_OPT_END
|
||||
};
|
||||
|
||||
static void print_version(const char *name)
|
||||
{
|
||||
printf("%s: z/VM CP command interface version %s\n"
|
||||
"Copyright IBM Corp. 2005, 2017\n",
|
||||
name, RELEASE_STRING);
|
||||
}
|
||||
|
||||
static void uppercase(char *string)
|
||||
{
|
||||
while (*string != '\0') {
|
||||
*string = toupper(*string);
|
||||
string++;
|
||||
static const struct util_prg prg = {
|
||||
.desc = "z/VM CP command interface",
|
||||
.args = "CP-command",
|
||||
.copyright_vec = {
|
||||
{
|
||||
.owner = "IBM Corp.",
|
||||
.pub_first = 2005,
|
||||
.pub_last = 2018,
|
||||
},
|
||||
UTIL_PRG_COPYRIGHT_END
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/* Parse STRING for buffer size in bytes, allowing size modifier suffix 'k' and
|
||||
* 'm'. Return buffer size in bytes on success, -1 on error. */
|
||||
@@ -95,17 +120,18 @@ static int parse_args(int argc, char **argv)
|
||||
int index;
|
||||
|
||||
do {
|
||||
opt = getopt_long(argc, argv, opt_string, options, NULL);
|
||||
opt = util_opt_getopt_long(argc, argv);
|
||||
switch (opt) {
|
||||
case -1:
|
||||
/* Reached end of parameter list. */
|
||||
break;
|
||||
case 'h':
|
||||
print_help(argv[0]);
|
||||
exit(VMCP_OK);
|
||||
util_prg_print_help();
|
||||
util_opt_print_help();
|
||||
exit(EXIT_SUCCESS);
|
||||
case 'v':
|
||||
print_version(argv[0]);
|
||||
exit(VMCP_OK);
|
||||
util_prg_print_version();
|
||||
exit(EXIT_SUCCESS);
|
||||
case 'k':
|
||||
keep_case = 1;
|
||||
break;
|
||||
@@ -137,7 +163,8 @@ static int parse_args(int argc, char **argv)
|
||||
strcat(command, argv[index]);
|
||||
}
|
||||
if (strlen(command) == 0) {
|
||||
print_help(argv[0]);
|
||||
util_prg_print_help();
|
||||
util_opt_print_help();
|
||||
return VMCP_OPT;
|
||||
}
|
||||
return VMCP_OK;
|
||||
@@ -148,25 +175,6 @@ static inline void linux_error(const char *message)
|
||||
fprintf(stderr, "Error: %s: %s\n", message, strerror(errno));
|
||||
}
|
||||
|
||||
/* Read at most COUNT bytes from FD into memory at location BUF. Return
|
||||
* number of bytes read on success, -1 on error. */
|
||||
static ssize_t read_buffer(int fd, char *buf, size_t count)
|
||||
{
|
||||
ssize_t ret;
|
||||
ssize_t done;
|
||||
|
||||
for (done = 0; done < (ssize_t) count; done += ret) {
|
||||
ret = read(fd, &buf[done], count - done);
|
||||
if (ret == -1 && errno == EINTR)
|
||||
continue;
|
||||
if (ret == -1)
|
||||
return -1;
|
||||
if (ret == 0)
|
||||
break;
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
/* Write COUNT bytes to FD from memory at location BUF. Return number of bytes
|
||||
* written on success, -1 otherwise. */
|
||||
static ssize_t write_buffer(int fd, const char *buf, size_t count)
|
||||
@@ -188,77 +196,54 @@ static ssize_t write_buffer(int fd, const char *buf, size_t count)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct vmcp_parm cp;
|
||||
int ret;
|
||||
int fd;
|
||||
int response_code;
|
||||
int response_size;
|
||||
char *buffer;
|
||||
|
||||
util_prg_init(&prg);
|
||||
util_opt_init(opt_vec, NULL);
|
||||
|
||||
ret = parse_args(argc, argv);
|
||||
if (ret != VMCP_OK)
|
||||
return ret;
|
||||
|
||||
if (!keep_case)
|
||||
uppercase(command);
|
||||
cp.buffer_size = buffersize;
|
||||
cp.cpcmd = command;
|
||||
cp.do_upper = !keep_case;
|
||||
|
||||
buffer = malloc(buffersize);
|
||||
if (!buffer) {
|
||||
linux_error("Could not allocate return buffer");
|
||||
ret = vmcp(&cp);
|
||||
|
||||
switch (ret) {
|
||||
case VMCP_ERR_OPEN:
|
||||
linux_error("Could not open device " VMCP_DEVICE_NODE);
|
||||
return VMCP_LIN;
|
||||
}
|
||||
fd = open(DEVICE_NODE, O_RDWR);
|
||||
if (fd == -1) {
|
||||
linux_error("Could not open device " DEVICE_NODE);
|
||||
free(buffer);
|
||||
return VMCP_LIN;
|
||||
}
|
||||
if (ioctl(fd, VMCP_SETBUF, &buffersize) == -1) {
|
||||
case VMCP_ERR_SETBUF:
|
||||
linux_error("Could not set buffer size");
|
||||
free(buffer);
|
||||
close(fd);
|
||||
return VMCP_LIN;
|
||||
}
|
||||
if (write(fd, command, strlen(command)) == -1) {
|
||||
case VMCP_ERR_WRITE:
|
||||
linux_error("Could not issue CP command");
|
||||
free(buffer);
|
||||
close(fd);
|
||||
return VMCP_LIN;
|
||||
}
|
||||
if (ioctl(fd, VMCP_GETCODE, &response_code) == -1) {
|
||||
case VMCP_ERR_GETCODE:
|
||||
linux_error("Could not query return code");
|
||||
free(buffer);
|
||||
close(fd);
|
||||
return VMCP_LIN;
|
||||
}
|
||||
if (ioctl(fd, VMCP_GETSIZE, &response_size) == -1) {
|
||||
case VMCP_ERR_GETSIZE:
|
||||
linux_error("Could not query response size");
|
||||
free(buffer);
|
||||
close(fd);
|
||||
return VMCP_LIN;
|
||||
}
|
||||
ret = read_buffer(fd, buffer, buffersize);
|
||||
if (ret == -1) {
|
||||
case VMCP_ERR_READ:
|
||||
linux_error("Could not read CP response");
|
||||
free(buffer);
|
||||
close(fd);
|
||||
return VMCP_LIN;
|
||||
}
|
||||
write_buffer(STDOUT_FILENO, buffer, ret);
|
||||
if (response_size > buffersize) {
|
||||
write_buffer(STDOUT_FILENO, cp.response,
|
||||
MIN(cp.response_size, cp.buffer_size));
|
||||
free(cp.response);
|
||||
if (ret == VMCP_ERR_TOOSMALL) {
|
||||
fprintf(stderr, "Error: output (%d bytes) was truncated, try "
|
||||
"--buffer to increase size\n", response_size);
|
||||
free(buffer);
|
||||
close(fd);
|
||||
"--buffer to increase size\n", cp.response_size);
|
||||
return VMCP_BUF;
|
||||
}
|
||||
if (response_code > 0) {
|
||||
if (cp.cprc > 0) {
|
||||
fprintf(stderr, "Error: non-zero CP response for command '%s': "
|
||||
"#%d\n", command, response_code);
|
||||
free(buffer);
|
||||
close(fd);
|
||||
"#%d\n", command, cp.cprc);
|
||||
return VMCP_CP;
|
||||
}
|
||||
free(buffer);
|
||||
close(fd);
|
||||
return VMCP_OK;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
59
vmcp/vmcp.h
59
vmcp/vmcp.h
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* vmcp - Send commands to the z/VM control program
|
||||
*
|
||||
* Definitions used by vmcp
|
||||
*
|
||||
* Copyright IBM Corp. 2005, 2017
|
||||
*
|
||||
* 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 __vmcp_h__
|
||||
#define __vmcp_h__
|
||||
|
||||
#include <getopt.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "lib/zt_common.h"
|
||||
|
||||
#define DEVICE_NODE "/dev/vmcp"
|
||||
|
||||
#define VMCP_GETCODE _IOR(0x10, 1, int)
|
||||
#define VMCP_SETBUF _IOW(0x10, 2, int)
|
||||
#define VMCP_GETSIZE _IOR(0x10, 3, int)
|
||||
|
||||
#define MAXBUFFER 1048576
|
||||
#define MINBUFFER 4096
|
||||
#define MAXCMDLEN 240
|
||||
|
||||
#define VMCP_OK 0
|
||||
#define VMCP_CP 1
|
||||
#define VMCP_BUF 2
|
||||
#define VMCP_LIN 3
|
||||
#define VMCP_OPT 4
|
||||
|
||||
static struct option options[] = {
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{"version", no_argument, NULL, 'v'},
|
||||
{"keepcase", no_argument, NULL, 'k'},
|
||||
{"buffer", required_argument, NULL, 'b'},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
static const char opt_string[] = "+hvkb:";
|
||||
|
||||
static const char help_text[] =
|
||||
"Usage:\n"
|
||||
"vmcp [-k] [-b <size>] command\n"
|
||||
"vmcp [-h|-v]\n\n"
|
||||
"Options:\n"
|
||||
"-h or --help :Print usage information, then exit\n"
|
||||
"-v or --version :Print version information, then exit\n"
|
||||
"-k or --keepcase :Using this option, vmcp does not convert the command\n"
|
||||
" to uppercase. The default is to translate the command\n"
|
||||
" string.\n"
|
||||
"-b <size> or :defines the buffer size for the response\n"
|
||||
"--buffer=<size> valid values are from 4096 to 1048576 bytes\n"
|
||||
" the k and M suffixes are also supported\n";
|
||||
#endif
|
||||
@@ -5,7 +5,9 @@ LDLIBS += -lz
|
||||
|
||||
all: vmur
|
||||
|
||||
libs = $(rootdir)/libvmdump/libvmdump.a
|
||||
libs = $(rootdir)/libvmdump/libvmdump.a \
|
||||
$(rootdir)/libvmcp/libvmcp.a $(rootdir)/libutil/libutil.a
|
||||
|
||||
objects = vmur.o
|
||||
|
||||
vmur: $(objects) $(libs)
|
||||
|
||||
131
vmur/vmur.cpp
131
vmur/vmur.cpp
@@ -31,9 +31,13 @@
|
||||
|
||||
#include "lib/vmdump.h"
|
||||
#include "lib/zt_common.h"
|
||||
#include "lib/util_libc.h"
|
||||
#include "lib/vmcp.h"
|
||||
|
||||
#include "vmur.h"
|
||||
|
||||
#define CP_PREFIX_LEN 11
|
||||
|
||||
/* Program name */
|
||||
static char *prog_name;
|
||||
|
||||
@@ -243,24 +247,6 @@ fail:
|
||||
ERR_EXIT("Could not initialize signal handler (errno = %i)\n", errno);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read at most COUNT bytes from FD into memory at location BUF.
|
||||
* Return number of bytes read on success, -1 on error.
|
||||
*/
|
||||
static ssize_t read_buf(int fd, char *buf, ssize_t count)
|
||||
{
|
||||
ssize_t rc, len;
|
||||
|
||||
for (len = 0; len < count; len += rc) {
|
||||
rc = read(fd, &buf[len], count - len);
|
||||
if (rc == -1)
|
||||
return -1;
|
||||
if (rc == 0)
|
||||
break;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
/*
|
||||
* Strip leading CP header from error message
|
||||
*/
|
||||
@@ -293,64 +279,63 @@ static void cperr_exit(char *cpcmd, int cprc, char *buf)
|
||||
|
||||
static void _cpcmd(char *cpcmd, char **resp, int *rc, int retry, int upper)
|
||||
{
|
||||
int fd, len, cprc, bufsize = VMCP_BUFSIZE;
|
||||
char *buf;
|
||||
struct vmcp_parm cp;
|
||||
char cmd[MAXCMDLEN];
|
||||
int ret;
|
||||
|
||||
strcpy(cmd, cpcmd);
|
||||
if (upper)
|
||||
to_upper(cmd);
|
||||
cp.cpcmd = cmd;
|
||||
cp.do_upper = upper;
|
||||
cp.buffer_size = VMCP_DEFAULT_BUFSZ;
|
||||
|
||||
fd = open(VMCP_DEVICE_NODE, O_RDWR);
|
||||
if (fd == -1)
|
||||
retry:
|
||||
ret = vmcp(&cp);
|
||||
|
||||
switch (ret) {
|
||||
case VMCP_ERR_OPEN:
|
||||
ERR_EXIT("Could not issue CP command: \"%s\"\n"
|
||||
"Ensure that vmcp kernel module is loaded!\n", cmd);
|
||||
|
||||
do {
|
||||
if (ioctl(fd, VMCP_SETBUF, &bufsize) == -1)
|
||||
goto fail;
|
||||
|
||||
if (write(fd, cmd, strlen(cmd)) == -1)
|
||||
goto fail;
|
||||
|
||||
if (ioctl(fd, VMCP_GETCODE, &cprc) == -1)
|
||||
goto fail;
|
||||
|
||||
if (ioctl(fd, VMCP_GETSIZE, &len) == -1)
|
||||
goto fail;
|
||||
|
||||
if (len <= bufsize)
|
||||
break;
|
||||
else if (retry)
|
||||
bufsize = len;
|
||||
else
|
||||
ERR_EXIT("Not enough buffer space (%i/%i) for CP "
|
||||
"command '%s'.\nSorry, please issue command "
|
||||
"on your 3270 console!\n", len, bufsize, cmd);
|
||||
} while (1);
|
||||
|
||||
buf = (char *) malloc(len + 1);
|
||||
if (!buf)
|
||||
ERR_EXIT("Out of memory for CP command '%s'\n", cmd);
|
||||
|
||||
memset(buf, 0, len + 1);
|
||||
if (read_buf(fd, buf, len) == -1)
|
||||
case VMCP_ERR_SETBUF:
|
||||
goto fail;
|
||||
|
||||
case VMCP_ERR_WRITE:
|
||||
goto fail;
|
||||
|
||||
case VMCP_ERR_GETCODE:
|
||||
goto fail;
|
||||
|
||||
case VMCP_ERR_GETSIZE:
|
||||
goto fail;
|
||||
|
||||
case VMCP_ERR_READ:
|
||||
goto fail;
|
||||
|
||||
case VMCP_ERR_TOOSMALL:
|
||||
if (retry) {
|
||||
cp.buffer_size = cp.response_size;
|
||||
free(cp.response);
|
||||
goto retry;
|
||||
}
|
||||
ERR_EXIT("Not enough buffer space (%u/%u) for CP "
|
||||
"command '%s'.\nSorry, please issue command "
|
||||
" on your 3270 console!\n", cp.response_size,
|
||||
cp.buffer_size, cmd);
|
||||
}
|
||||
|
||||
if (rc == NULL) {
|
||||
if (cprc != 0) {
|
||||
if (cp.cprc != 0) {
|
||||
/* caller wants us to handle the error */
|
||||
cperr_exit(cmd, cprc, buf);
|
||||
cperr_exit(cmd, cp.cprc, cp.response);
|
||||
}
|
||||
} else {
|
||||
*rc = cprc;
|
||||
*rc = cp.cprc;
|
||||
}
|
||||
|
||||
if (resp)
|
||||
*resp = buf;
|
||||
*resp = cp.response;
|
||||
else
|
||||
free(buf);
|
||||
close(fd);
|
||||
free(cp.response);
|
||||
return;
|
||||
|
||||
fail:
|
||||
@@ -1369,30 +1354,6 @@ static void close_reader(struct vmur *info, const char *hold)
|
||||
cpcmd(cmd, NULL, NULL, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* strip leading and trailing blanks
|
||||
*/
|
||||
static char *strstrip(char *s)
|
||||
{
|
||||
size_t size;
|
||||
char *end;
|
||||
|
||||
size = strlen(s);
|
||||
|
||||
if (!size)
|
||||
return s;
|
||||
|
||||
end = s + size - 1;
|
||||
while (end >= s && isspace(*end))
|
||||
end--;
|
||||
*(end + 1) = '\0';
|
||||
|
||||
while (*s && isspace(*s))
|
||||
s++;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check whether reader can handle class of reader spool file
|
||||
*/
|
||||
@@ -1431,9 +1392,9 @@ static int get_filename_from_reader(struct vmur *info)
|
||||
sprintf(cmd, "QUERY RDR * %s ALL SHORTDATE", info->spoolid);
|
||||
cpcmd(cmd, &buf, NULL, 0);
|
||||
memcpy(name, &buf[130], 8);
|
||||
strstrip(name);
|
||||
util_strstrip(name);
|
||||
memcpy(type, &buf[140], 8);
|
||||
strstrip(type);
|
||||
util_strstrip(type);
|
||||
free(buf);
|
||||
if (strlen(name) == 0) {
|
||||
ERR("Please specify name to receive "
|
||||
|
||||
@@ -31,14 +31,6 @@ do { \
|
||||
ERR_EXIT(str " can only be specified once.\n"); \
|
||||
} while (0)
|
||||
|
||||
#define VMCP_DEVICE_NODE "/dev/vmcp"
|
||||
#define VMCP_BUFSIZE 0x4000
|
||||
#define VMCP_GETSIZE _IOR(0x10, 3, int)
|
||||
#define VMCP_SETBUF _IOW(0x10, 2, int)
|
||||
#define VMCP_GETCODE _IOR(0x10, 1, int)
|
||||
|
||||
#define CP_PREFIX_LEN 11
|
||||
|
||||
#define VMRDR_DEVICE_NODE "/dev/vmrdr-0.0.000c"
|
||||
#define VMPUN_DEVICE_NODE "/dev/vmpun-0.0.000d"
|
||||
#define VMPRT_DEVICE_NODE "/dev/vmprt-0.0.000e"
|
||||
|
||||
@@ -649,14 +649,12 @@ static void print_defunct_devices(struct util_rec *rec, char *path)
|
||||
snprintf(buf, sizeof(buf), "%s", device);
|
||||
}
|
||||
if (cmd.opt_devrange && cmd.rng_count > 0 &&
|
||||
!id_in_ranges_list(device)) {
|
||||
util_scandir_free(de_vec, count);
|
||||
!id_in_ranges_list(device))
|
||||
continue;
|
||||
}
|
||||
if (fill_device_info(rec, path, device) != 0) {
|
||||
util_scandir_free(de_vec, count);
|
||||
|
||||
if (fill_device_info(rec, path, device) != 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cmd.opt_uppercase)
|
||||
util_str_toupper(buf);
|
||||
util_rec_set(rec, "device", "%s", buf);
|
||||
@@ -719,7 +717,7 @@ static void print_subchannels_of_type(enum sch_type type_requested,
|
||||
if (!cmd.opt_devrange && cmd.rng_count > 0)
|
||||
return;
|
||||
path = util_path_sysfs("devices");
|
||||
count = util_scandir(&de_vec, alphasort, path, "css.*/");
|
||||
count = util_scandir(&de_vec, alphasort, path, "css.*");
|
||||
free(path);
|
||||
for (i = 0; i < count; i++) {
|
||||
path = util_path_sysfs("devices/%s/defunct", de_vec[i]->d_name);
|
||||
|
||||
@@ -235,8 +235,15 @@ sub get_env_list
|
||||
my @res ;
|
||||
my %res_hash;
|
||||
|
||||
if (!</sys/bus/ccw/drivers/zfcp/*.*.*/>) {
|
||||
print "$PROGRAM_NAME: No adapter exists\n";
|
||||
return;
|
||||
}
|
||||
@res = </sys/bus/ccw/drivers/zfcp/*.*.*/0x*>;
|
||||
return () if (!@res);
|
||||
if (!@res) {
|
||||
print "$PROGRAM_NAME: No port on any adapter exists\n";
|
||||
return;
|
||||
}
|
||||
foreach my $entry (@res) {
|
||||
my $a = ${[split('/', $entry)]}[-2];
|
||||
my $p = ${[split('/', $entry)]}[-1];
|
||||
|
||||
@@ -2,7 +2,7 @@ include ../../common.mak
|
||||
|
||||
all: lsqeth
|
||||
|
||||
libs = $(rootdir)/libutil/libutil.a
|
||||
libs = $(rootdir)/libvmcp/libvmcp.a $(rootdir)/libutil/libutil.a
|
||||
|
||||
lsqeth: lsqeth.o misc.o $(libs)
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "lib/util_rec.h"
|
||||
#include "lib/util_scandir.h"
|
||||
#include "lib/zt_common.h"
|
||||
#include "lib/vmcp.h"
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
@@ -44,15 +45,6 @@
|
||||
#define MAX_ID_LENGTH 10
|
||||
#define PAGE_SIZE 4096
|
||||
|
||||
/*
|
||||
* Constants for CP call (taken from vmcp.h)
|
||||
*/
|
||||
#define VMCP_DEVICE_NODE "/dev/vmcp"
|
||||
#define VMCP_GETCODE _IOR(0x10, 1, int)
|
||||
#define VMCP_SETBUF _IOW(0x10, 2, int)
|
||||
#define VMCP_GETSIZE _IOR(0x10, 3, int)
|
||||
#define CP_BUF_SIZE 8192
|
||||
|
||||
/*
|
||||
* Private data
|
||||
*/
|
||||
@@ -197,32 +189,38 @@ static void ethtool_checksumming(char *buf, const char *if_name)
|
||||
*/
|
||||
static void exec_cp(char **argz, size_t *argz_len, const char *fmt, ...)
|
||||
{
|
||||
int fd, response_code, response_size, rc;
|
||||
static const int buf_size = CP_BUF_SIZE;
|
||||
char *buf, *command;
|
||||
struct vmcp_parm cp;
|
||||
char *command;
|
||||
va_list ap;
|
||||
int rc;
|
||||
|
||||
fd = open(VMCP_DEVICE_NODE, O_RDWR);
|
||||
if (fd == -1)
|
||||
errx(EXIT_FAILURE, "Could not open device %s", VMCP_DEVICE_NODE);
|
||||
if (ioctl(fd, VMCP_SETBUF, &buf_size) == -1)
|
||||
errx(EXIT_FAILURE, "Could not set buffer size");
|
||||
UTIL_VASPRINTF(&command, fmt, ap);
|
||||
if (write(fd, command, strlen(command)) == -1)
|
||||
errx(EXIT_FAILURE, "Could not issue CP command");
|
||||
cp.cpcmd = command;
|
||||
cp.do_upper = false;
|
||||
cp.buffer_size = VMCP_DEFAULT_BUFSZ;
|
||||
rc = vmcp(&cp);
|
||||
free(command);
|
||||
if (ioctl(fd, VMCP_GETCODE, &response_code) == -1)
|
||||
|
||||
switch (rc) {
|
||||
case VMCP_ERR_OPEN:
|
||||
errx(EXIT_FAILURE, "Could not open device %s", VMCP_DEVICE_NODE);
|
||||
case VMCP_ERR_SETBUF:
|
||||
errx(EXIT_FAILURE, "Could not set buffer size");
|
||||
case VMCP_ERR_GETCODE:
|
||||
errx(EXIT_FAILURE, "Could not query return code");
|
||||
if (ioctl(fd, VMCP_GETSIZE, &response_size) == -1)
|
||||
case VMCP_ERR_GETSIZE:
|
||||
errx(EXIT_FAILURE, "Could not query response size");
|
||||
buf = util_malloc(buf_size);
|
||||
rc = misc_read_buf(fd, buf, buf_size);
|
||||
if (rc == -1)
|
||||
case VMCP_ERR_WRITE:
|
||||
errx(EXIT_FAILURE, "Could not issue CP command");
|
||||
case VMCP_ERR_READ:
|
||||
errx(EXIT_FAILURE, "Could not read CP response");
|
||||
rc = argz_create_sep(buf, '\n', argz, argz_len);
|
||||
case VMCP_ERR_TOOSMALL:
|
||||
break; /* Truncated CP response treated as good */
|
||||
}
|
||||
rc = argz_create_sep(cp.response, '\n', argz, argz_len);
|
||||
if (rc)
|
||||
errx(EXIT_FAILURE, "Memory allocation error for CP response processing");
|
||||
free(buf);
|
||||
free(cp.response);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -57,6 +57,7 @@ Set all available cryptographic device(s) online or offline.
|
||||
.B <device id>
|
||||
Specifies a cryptographic device which will be set either online or offline.
|
||||
The device can either be a card device or a queue device.
|
||||
A queue device can only get switched online when the providing card is online.
|
||||
|
||||
Please note that the card device and queue device representation are both
|
||||
in hexadecimal notation.
|
||||
@@ -95,7 +96,7 @@ Print version information and exit.
|
||||
.B chzcrypt -e 0 1 12
|
||||
Will set the cryptographic card devices 0, 1 and 12 online.
|
||||
.TP
|
||||
.B chzcrypt -e 01.0038
|
||||
.B chzcrypt -e 10.0038
|
||||
Will set the cryptographic device '10.0038' respectively card id 16
|
||||
(0x10) with domain 56 (0x38) online.
|
||||
.TP
|
||||
|
||||
@@ -8,6 +8,7 @@ install: all
|
||||
$(MAKE) -C src install
|
||||
$(MAKE) -C man install
|
||||
$(MAKE) -C dracut install
|
||||
$(MAKE) -C initramfs install
|
||||
|
||||
clean:
|
||||
$(MAKE) -C src clean
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
# 95zdev/module_setup.sh
|
||||
# This module installs configuration files (udev rules and modprobe.conf
|
||||
# files) required to enable the root device on s390. It will only work when
|
||||
# the root device was configured using the chzdev tool.
|
||||
# the root device was configured using the chzdev tool. In addition,
|
||||
# a hook is installed to parse rd.zdev= kernel parameters.
|
||||
#
|
||||
|
||||
check() {
|
||||
@@ -29,30 +30,27 @@ depends() {
|
||||
}
|
||||
|
||||
installkernel() {
|
||||
local _modules=$(lszdev --by-path / --columns MODULES --no-headings 2>/dev/null)
|
||||
|
||||
[ -z "$_modules" ] && return 0
|
||||
[ ! -z "$_modules" ] && instmods $_modules
|
||||
# Add modules for all device types supported by chzdev (required for
|
||||
# auto-configuration)
|
||||
instmods lcs qeth qeth_l2 qeth_l3 dasd_mod dasd_eckd_mod dasd_fba_mod \
|
||||
dasd_diag_mod zfcp
|
||||
}
|
||||
|
||||
install() {
|
||||
local _tempfile
|
||||
|
||||
# Exit early if root device type is unknown
|
||||
if ! lszdev --by-path / >/dev/null 2>&1 ; then
|
||||
return 0
|
||||
fi
|
||||
# Ensure that required tools are available
|
||||
inst_multiple chzdev lszdev vmcp
|
||||
|
||||
# Hook to parse zdev kernel parameter
|
||||
inst_hook cmdline 95 "$moddir/parse-zdev.sh"
|
||||
|
||||
# Obtain early + root device configuration
|
||||
_tempfile=$(mktemp --tmpdir dracut-zdev.XXXXXX)
|
||||
|
||||
if chzdev --export - --persistent --by-path / >/dev/null 2>&1 ; then
|
||||
# Use persistent configuration
|
||||
chzdev --export "$_tempfile" --persistent --by-path / --quiet --type
|
||||
else
|
||||
# Use active configuration
|
||||
chzdev --export "$_tempfile" --active --by-path / --quiet --type
|
||||
sed -i -e 's/active/persistent/g' "$_tempfile"
|
||||
fi
|
||||
chzdev --export "$_tempfile" --persistent --by-path / --quiet \
|
||||
--type 2>/dev/null
|
||||
chzdev --export - --persistent --by-attrib "zdev:early=1" --quiet \
|
||||
--type 2>/dev/null >> "$_tempfile"
|
||||
|
||||
# Apply via --import to prevent other devices from being configured
|
||||
chzdev --import "$_tempfile" --persistent --base "/etc=$initdir/etc" \
|
||||
|
||||
38
zdev/dracut/95zdev/parse-zdev.sh
Normal file
38
zdev/dracut/95zdev/parse-zdev.sh
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright IBM Corp. 2017
|
||||
#
|
||||
# s390-tools is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the MIT license. See LICENSE for details.
|
||||
#
|
||||
# 95zdev/parse-zdev.sh
|
||||
# Parse the kernel command line for rd.zdev kernel parameters. These
|
||||
# parameters are evaluated and used to configure z Systems specific devices.
|
||||
#
|
||||
# Format:
|
||||
# rd.zdev=no-auto
|
||||
#
|
||||
# where
|
||||
#
|
||||
# no-auto: Indicates that firmware-provided I/O configuration data
|
||||
# should not be applied.
|
||||
#
|
||||
|
||||
zdev_fw_file="/sys/firmware/sclp_sd/config/data"
|
||||
zdev_base_args="--force --yes --no-root-update --no-settle --auto-conf --quiet"
|
||||
|
||||
if [ -e "$zdev_fw_file" ] ; then
|
||||
zdev_auto=1
|
||||
else
|
||||
zdev_auto=0
|
||||
fi
|
||||
|
||||
for zdev_arg in $(getargs rd.zdev); do
|
||||
if [ "$zdev_arg" = "no-auto" ] ; then
|
||||
zdev_auto=0
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $zdev_auto -eq 1 ] ; then
|
||||
chzdev --import "$zdev_fw_file" $zdev_base_args
|
||||
fi
|
||||
@@ -11,11 +11,14 @@ ZDEVDIR := 95zdev
|
||||
# performs the following functions when dracut is run:
|
||||
#
|
||||
# - copy the persistent root device configuration to the initial ram disk
|
||||
# - install a boot-time hook to apply firmware-provided configuration data
|
||||
# to the system
|
||||
#
|
||||
ifeq ($(HAVE_DRACUT),1)
|
||||
install:
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(MODDIR)
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(MODDIR)/$(ZDEVDIR)
|
||||
$(INSTALL) -m 755 $(ZDEVDIR)/module-setup.sh \
|
||||
$(ZDEVDIR)/parse-zdev.sh \
|
||||
$(DESTDIR)$(MODDIR)/$(ZDEVDIR)/
|
||||
endif
|
||||
|
||||
@@ -189,6 +189,7 @@ struct value_map {
|
||||
* in the persistent configuration
|
||||
* @nounload: (Device type attributes only) This attribute can be set while
|
||||
* the corresponding kernel module remains loaded.
|
||||
* @internal: This attribute only affects internal handling
|
||||
* @order: A number indicating the order in which to apply attribute
|
||||
* @order_cmp: A function determining if a setting for this attribute should
|
||||
* be applied before (-1) or after (1) another setting, or
|
||||
@@ -216,6 +217,7 @@ struct attrib {
|
||||
unsigned int activerem :1;
|
||||
unsigned int defunset :1;
|
||||
unsigned int nounload :1;
|
||||
unsigned int internal :1;
|
||||
|
||||
/* Optional */
|
||||
int order;
|
||||
|
||||
@@ -11,7 +11,10 @@
|
||||
#define DASD_H
|
||||
|
||||
struct devtype;
|
||||
struct subtype;
|
||||
|
||||
extern struct devtype dasd_devtype;
|
||||
extern struct subtype dasd_subtype_eckd;
|
||||
extern struct subtype dasd_subtype_fba;
|
||||
|
||||
#endif /* DASD_H */
|
||||
|
||||
@@ -45,6 +45,7 @@ struct device_state {
|
||||
* @node: Node for adding this device to a list
|
||||
* @active: Device state in the active configuration
|
||||
* @persistent: Device state in the persistent configuration
|
||||
* @autoconf: Auto-configured device state
|
||||
* @errors: A strlist of error and warning messages issued for the device
|
||||
* @processed: Device has been processed
|
||||
*/
|
||||
@@ -59,6 +60,7 @@ struct device {
|
||||
|
||||
struct device_state active;
|
||||
struct device_state persistent;
|
||||
struct device_state autoconf;
|
||||
|
||||
unsigned int processed:1;
|
||||
};
|
||||
@@ -94,5 +96,9 @@ void device_list_add(struct device_list *, struct device *);
|
||||
struct device *device_list_find(struct device_list *, const char *,
|
||||
struct device *);
|
||||
void device_list_print(struct device_list *, int);
|
||||
struct setting_list *device_get_setting_list(struct device *dev,
|
||||
config_t config);
|
||||
|
||||
config_t device_get_config(struct device *dev);
|
||||
|
||||
#endif /* DEVICE_H */
|
||||
|
||||
@@ -31,6 +31,7 @@ struct export_object {
|
||||
} ptr;
|
||||
};
|
||||
|
||||
struct export_object *object_new(export_t type, void *ptr);
|
||||
exit_code_t export_write_device(FILE *, struct device *, config_t, int *);
|
||||
exit_code_t export_write_devtype(FILE *, struct devtype *, config_t, int *);
|
||||
exit_code_t export_read(FILE *, const char *, struct util_list *);
|
||||
|
||||
25
zdev/include/firmware.h
Normal file
25
zdev/include/firmware.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2017
|
||||
*
|
||||
* 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 FIRMWARE_H
|
||||
#define FIRMWARE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "exit_code.h"
|
||||
#include "misc.h"
|
||||
|
||||
struct util_list;
|
||||
|
||||
bool firmware_detect(FILE *fd);
|
||||
exit_code_t firmware_read(FILE *fd, const char *filename, long skip,
|
||||
config_t config, struct util_list *objects);
|
||||
|
||||
#endif /* FIRMWARE_H */
|
||||
25
zdev/include/internal.h
Normal file
25
zdev/include/internal.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2017
|
||||
*
|
||||
* 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 INTERNAL_H
|
||||
#define INTERNAL_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "attrib.h"
|
||||
|
||||
#define INTERNAL_ATTR_PREFIX "zdev:"
|
||||
#define INTERNAL_ATTR_EARLY INTERNAL_ATTR_PREFIX "early"
|
||||
|
||||
extern struct attrib internal_attr_early;
|
||||
|
||||
const char *internal_get_name(const char *name);
|
||||
bool internal_by_name(const char *name);
|
||||
|
||||
#endif /* INTERNAL_H */
|
||||
@@ -19,9 +19,14 @@
|
||||
#include "exit_code.h"
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#define SCOPE_ACTIVE(x) (((x) == config_active) || ((x) == config_all))
|
||||
#define SCOPE_PERSISTENT(x) (((x) == config_persistent) || \
|
||||
((x) == config_all))
|
||||
#define SCOPE_ACTIVE(x) ((x) & config_active ? 1 : 0)
|
||||
#define SCOPE_PERSISTENT(x) ((x) & config_persistent ? 1 : 0)
|
||||
#define SCOPE_AUTOCONF(x) ((x) & config_autoconf ? 1 : 0)
|
||||
#define SCOPE_ALL(x) ((x) == (config_active | config_persistent |\
|
||||
config_autoconf))
|
||||
#define SCOPE_SINGLE(x) ((x) == config_active || \
|
||||
(x) == config_persistent || \
|
||||
(x) == config_autoconf)
|
||||
|
||||
#define DELAY_INDENT 4
|
||||
|
||||
@@ -34,12 +39,15 @@
|
||||
|
||||
#define EVEN(x) (((x) & 1) == 0)
|
||||
|
||||
/* Enumeration of configuration sets. */
|
||||
typedef enum {
|
||||
config_active,
|
||||
config_persistent,
|
||||
config_all,
|
||||
} config_t;
|
||||
/* Enumeration of configuration sets. Multiple configuration sets can be
|
||||
* combined using bit-wise or. */
|
||||
enum {
|
||||
config_active = 1,
|
||||
config_persistent = 2,
|
||||
config_autoconf = 4,
|
||||
config_all = 7,
|
||||
};
|
||||
typedef int config_t;
|
||||
|
||||
typedef enum {
|
||||
err_ignore,
|
||||
@@ -159,6 +167,7 @@ bool misc_read_dir(const char *, struct util_list *,
|
||||
bool (*)(const char *, void *), void *);
|
||||
bool file_is_devnode(const char *);
|
||||
exit_code_t remove_file(const char *);
|
||||
exit_code_t misc_read_fd(FILE *fd, void **buffer, size_t *size_ptr);
|
||||
char *misc_read_text_file(const char *, int, err_t);
|
||||
char *misc_read_cmd_output(const char *, int, err_t);
|
||||
char *config_read_cmd_output(const char *, int, err_t);
|
||||
@@ -166,7 +175,7 @@ exit_code_t misc_write_text_file(const char *, const char *, err_t);
|
||||
exit_code_t misc_write_text_file_retry(const char *, const char *, err_t);
|
||||
exit_code_t misc_mktemp(char **, int *);
|
||||
char *misc_readlink(const char *path);
|
||||
config_t get_config(int, int);
|
||||
config_t get_config(int act, int pers, int ac);
|
||||
bool is_zvm(void);
|
||||
bool is_terminal(void);
|
||||
const char *config_to_str(config_t);
|
||||
@@ -174,6 +183,7 @@ bool str_to_config(const char *, config_t *);
|
||||
char *quote_str(const char *, int);
|
||||
char *unquote_str(const char *);
|
||||
char *shrink_str(const char *);
|
||||
char *misc_strrstr(const char *haystack, const char *needle);
|
||||
|
||||
struct util_list *strlist_new(void);
|
||||
void strlist_free(struct util_list *);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#define PATH_CCW_BUS "/sys/bus/ccw"
|
||||
#define PATH_CCWGROUP_BUS "/sys/bus/ccwgroup"
|
||||
#define PATH_UDEV_RULES "/etc/udev/rules.d"
|
||||
#define PATH_UDEV_RULES_VOLATILE "/run/udev/rules.d"
|
||||
#define PATH_PROC "/proc"
|
||||
|
||||
#define PATH_UDEVADM "udevadm"
|
||||
@@ -55,8 +56,8 @@ char *path_get_ccw_device(const char *, const char *);
|
||||
char *path_get_ccw_devices(const char *);
|
||||
char *path_get_ccwgroup_device(const char *, const char *);
|
||||
char *path_get_ccwgroup_devices(const char *);
|
||||
char *path_get_udev_rule(const char *, const char *);
|
||||
char *path_get_udev_rules(void);
|
||||
char *path_get_udev_rule(const char *type, const char *id, bool vol);
|
||||
char *path_get_udev_rules(bool vol);
|
||||
char *path_get_proc(const char *);
|
||||
char *path_get_sys_bus_dev(const char *, const char *);
|
||||
char *path_get_sys_bus_drv(const char *, const char *);
|
||||
|
||||
@@ -17,9 +17,11 @@
|
||||
#define QETH_NUM_DEVS 3
|
||||
|
||||
struct devtype;
|
||||
struct subtype;
|
||||
struct namespace;
|
||||
|
||||
extern struct devtype qeth_devtype;
|
||||
extern struct subtype qeth_subtype_qeth;
|
||||
extern struct namespace qeth_namespace;
|
||||
|
||||
#endif /* QETH_H */
|
||||
|
||||
@@ -94,7 +94,8 @@ void setting_list_map_values(struct setting_list *);
|
||||
void setting_list_mark_default_derived(struct setting_list *);
|
||||
int setting_list_count_set(struct setting_list *);
|
||||
void setting_list_remove_derived(struct setting_list *);
|
||||
char *setting_get_changes(struct setting_list *, struct setting_list *);
|
||||
char *setting_get_changes(struct setting_list *act, struct setting_list *pers,
|
||||
struct setting_list *ac);
|
||||
bool setting_match_value(struct setting *, const char *);
|
||||
|
||||
#endif /* SETTING_H */
|
||||
|
||||
@@ -67,17 +67,22 @@ typedef exit_code_t (*subtype_cb_t)(struct subtype *st, const char *id,
|
||||
*
|
||||
* @exists_active: Check if device exists in active configuration
|
||||
* @exists_persistent: Check if device exists in persistent configuration
|
||||
* @exists_autoconf: Check if device exists in autoconf configuration
|
||||
*
|
||||
* @add_active_ids: Add IDs of all devices existing in active configuration to
|
||||
* specified strlist
|
||||
* @add_persistent_ids: Add IDs of all devices existing in persistent
|
||||
* configuration to specified strlist
|
||||
* @add_autoconf_ids: Add IDs of all devices existing in autoconf
|
||||
* configuration to specified strlist
|
||||
*
|
||||
* @read_active: Read device configuration from active configuration
|
||||
* @read_persistent: Read device configuration from persistent configuration
|
||||
* @read_autoconf: Read device configuration from autoconf configuration
|
||||
*
|
||||
* @configure_active: Apply configuration to active configuration
|
||||
* @configure_persistent: Apply configuration to persistent configuration
|
||||
* @configure_autoconf: Apply configuration to autoconf configuration
|
||||
*
|
||||
* @check_pre_write: Optional: Determine if the given configuration is valid
|
||||
* for the specified device. If not, emit warning messages
|
||||
@@ -150,24 +155,33 @@ struct subtype {
|
||||
|
||||
bool (*exists_active)(struct subtype *, const char *);
|
||||
bool (*exists_persistent)(struct subtype *, const char *);
|
||||
bool (*exists_autoconf)(struct subtype *, const char *);
|
||||
|
||||
void (*add_active_ids)(struct subtype *, struct util_list *);
|
||||
void (*add_persistent_ids)(struct subtype *,
|
||||
struct util_list *);
|
||||
void (*add_autoconf_ids)(struct subtype *,
|
||||
struct util_list *);
|
||||
|
||||
exit_code_t (*read_active)(struct subtype *, struct device *,
|
||||
read_scope_t);
|
||||
exit_code_t (*read_persistent)(struct subtype *, struct device *,
|
||||
read_scope_t);
|
||||
exit_code_t (*read_autoconf)(struct subtype *, struct device *,
|
||||
read_scope_t);
|
||||
|
||||
exit_code_t (*configure_active)(struct subtype *, struct device *);
|
||||
exit_code_t (*configure_persistent)(struct subtype *,
|
||||
struct device *);
|
||||
exit_code_t (*configure_autoconf)(struct subtype *,
|
||||
struct device *);
|
||||
|
||||
exit_code_t (*deconfigure_active)(struct subtype *,
|
||||
struct device *);
|
||||
exit_code_t (*deconfigure_persistent)(struct subtype *,
|
||||
struct device *);
|
||||
exit_code_t (*deconfigure_autoconf)(struct subtype *,
|
||||
struct device *);
|
||||
|
||||
exit_code_t (*check_pre_configure)(struct subtype *,
|
||||
struct device *, int, config_t);
|
||||
@@ -217,23 +231,31 @@ void subtype_exit(struct subtype *);
|
||||
|
||||
bool subtype_device_exists_active(struct subtype *, const char *);
|
||||
bool subtype_device_exists_persistent(struct subtype *, const char *);
|
||||
bool subtype_device_exists_autoconf(struct subtype *st, const char *id);
|
||||
|
||||
void subtype_add_active_ids(struct subtype *, struct util_list *);
|
||||
void subtype_add_persistent_ids(struct subtype *, struct util_list *);
|
||||
void subtype_add_autoconf_ids(struct subtype *st, struct util_list *ids);
|
||||
|
||||
exit_code_t subtype_device_read_active(struct subtype *, struct device *,
|
||||
read_scope_t);
|
||||
exit_code_t subtype_device_read_persistent(struct subtype *, struct device *,
|
||||
read_scope_t);
|
||||
exit_code_t subtype_device_read_autoconf(struct subtype *st, struct device *dev,
|
||||
read_scope_t scope);
|
||||
|
||||
exit_code_t subtype_device_configure_active(struct subtype *, struct device *);
|
||||
exit_code_t subtype_device_configure_persistent(struct subtype *,
|
||||
struct device *);
|
||||
exit_code_t subtype_device_configure_autoconf(struct subtype *st,
|
||||
struct device *dev);
|
||||
|
||||
exit_code_t subtype_device_deconfigure_active(struct subtype *,
|
||||
struct device *);
|
||||
exit_code_t subtype_device_deconfigure_persistent(struct subtype *st,
|
||||
struct device *);
|
||||
exit_code_t subtype_device_deconfigure_autoconf(struct subtype *st,
|
||||
struct device *dev);
|
||||
|
||||
exit_code_t subtype_check_pre_configure(struct subtype *, struct device *, int,
|
||||
config_t);
|
||||
|
||||
@@ -13,7 +13,11 @@
|
||||
#include "lib/util_list.h"
|
||||
#include "exit_code.h"
|
||||
|
||||
struct attrib;
|
||||
struct setting_list;
|
||||
|
||||
extern int udev_need_settle;
|
||||
extern int udev_no_settle;
|
||||
|
||||
/* Single key-operator-value entry in a udev rule line.*/
|
||||
struct udev_entry_node {
|
||||
@@ -39,9 +43,14 @@ exit_code_t udev_read_file(const char *, struct udev_file **);
|
||||
void udev_free_file(struct udev_file *);
|
||||
void udev_file_print(struct udev_file *);
|
||||
|
||||
void udev_get_device_ids(const char *, struct util_list *);
|
||||
exit_code_t udev_remove_rule(const char *, const char *);
|
||||
void udev_get_device_ids(const char *type, struct util_list *list,
|
||||
bool autoconf);
|
||||
exit_code_t udev_remove_rule(const char *type, const char *id, bool autoconf);
|
||||
|
||||
void udev_settle(void);
|
||||
|
||||
void udev_add_internal_from_entry(struct setting_list *list,
|
||||
struct udev_entry_node *entry,
|
||||
struct attrib **attribs);
|
||||
|
||||
#endif /* UDEV_H */
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
|
||||
struct device;
|
||||
|
||||
bool udev_ccw_exists(const char *, const char *);
|
||||
exit_code_t udev_ccw_read_device(struct device *);
|
||||
exit_code_t udev_ccw_write_device(struct device *);
|
||||
exit_code_t udev_ccw_write_cio_ignore(const char *);
|
||||
bool udev_ccw_exists(const char *type, const char *id, bool autoconf);
|
||||
exit_code_t udev_ccw_read_device(struct device *dev, bool autoconf);
|
||||
exit_code_t udev_ccw_write_device(struct device *dev, bool autoconf);
|
||||
exit_code_t udev_ccw_write_cio_ignore(const char *id_list, bool autoconf);
|
||||
|
||||
#endif /* UDEV_CCW_H */
|
||||
|
||||
@@ -16,10 +16,12 @@
|
||||
struct device;
|
||||
struct util_list;
|
||||
|
||||
bool udev_ccwgroup_exists(const char *, const char *);
|
||||
exit_code_t udev_ccwgroup_read_device(struct device *);
|
||||
exit_code_t udev_ccwgroup_write_device(struct device *);
|
||||
void udev_ccwgroup_add_device_ids(const char *, struct util_list *);
|
||||
exit_code_t udev_ccwgroup_remove_rule(const char *, const char *);
|
||||
bool udev_ccwgroup_exists(const char *type, const char *id, bool autoconf);
|
||||
exit_code_t udev_ccwgroup_read_device(struct device *dev, bool autoconf);
|
||||
exit_code_t udev_ccwgroup_write_device(struct device *dev, bool autoconf);
|
||||
void udev_ccwgroup_add_device_ids(const char *type, struct util_list *list,
|
||||
bool autoconf);
|
||||
exit_code_t udev_ccwgroup_remove_rule(const char *type, const char *id,
|
||||
bool autoconf);
|
||||
|
||||
#endif /* UDEV_CCWGROUP_H */
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
|
||||
struct device;
|
||||
|
||||
void udev_zfcp_lun_add_device_ids(struct util_list *);
|
||||
bool udev_zfcp_lun_exists(const char *);
|
||||
exit_code_t udev_zfcp_lun_read_device(struct device *);
|
||||
exit_code_t udev_zfcp_lun_write_device(struct device *);
|
||||
exit_code_t udev_zfcp_lun_remove_rule(const char *);
|
||||
void udev_zfcp_lun_add_device_ids(struct util_list *list, bool autoconf);
|
||||
bool udev_zfcp_lun_exists(const char *id, bool autoconf);
|
||||
exit_code_t udev_zfcp_lun_read_device(struct device *dev, bool autoconf);
|
||||
exit_code_t udev_zfcp_lun_write_device(struct device *dev, bool autoconf);
|
||||
exit_code_t udev_zfcp_lun_remove_rule(const char *id, bool autoconf);
|
||||
|
||||
#endif /* UDEV_ZFCP_LUN_H */
|
||||
|
||||
22
zdev/initramfs/Makefile
Normal file
22
zdev/initramfs/Makefile
Normal file
@@ -0,0 +1,22 @@
|
||||
# Common definitions
|
||||
include ../../common.mak
|
||||
|
||||
INITRAMFSDIR := /usr/share/initramfs-tools
|
||||
HOOKDIR := $(INITRAMFSDIR)/hooks
|
||||
INITTOP := $(INITRAMFSDIR)/scripts/init-top
|
||||
|
||||
# HAVE_INITRAMFS
|
||||
#
|
||||
# This install time parameter determines whether the zdev initramfs support is
|
||||
# installed (HAVE_INITRAMFS=1) or not (default). When installed, the module
|
||||
# performs the following functions when mkinitramfs is run:
|
||||
#
|
||||
# - install a boot-time hook to apply firmware-provided configuration data
|
||||
# to the system
|
||||
#
|
||||
ifeq ($(HAVE_INITRAMFS),1)
|
||||
install:
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)/$(HOOKDIR) $(DESTDIR)/$(INITTOP)
|
||||
$(INSTALL) -m 755 hooks/zdev $(DESTDIR)/$(HOOKDIR)
|
||||
$(INSTALL) -m 755 scripts/init-top/zdev $(DESTDIR)/$(INITTOP)
|
||||
endif
|
||||
56
zdev/initramfs/hooks/zdev
Normal file
56
zdev/initramfs/hooks/zdev
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright IBM Corp. 2016, 2017
|
||||
#
|
||||
# s390-tools is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the MIT license. See LICENSE for details.
|
||||
#
|
||||
# hooks/zdev
|
||||
# This hook script adds files required to apply firmware-provided I/O
|
||||
# configuration data during boot.
|
||||
#
|
||||
|
||||
# Needs to run after udev or resulting udev rules could be overwritten
|
||||
PREREQ="udev"
|
||||
|
||||
prereqs()
|
||||
{
|
||||
echo "$PREREQ"
|
||||
}
|
||||
|
||||
case $1 in
|
||||
prereqs)
|
||||
prereqs
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
. /usr/share/initramfs-tools/hook-functions
|
||||
|
||||
# Add modules for all device types supported by chzdev (required for
|
||||
# auto-configuration)
|
||||
zdev_modules="lcs qeth qeth_l2 qeth_l3 dasd_mod dasd_eckd_mod dasd_fba_mod dasd_diag_mod zfcp"
|
||||
|
||||
for x in $zdev_modules ; do
|
||||
manual_add_modules ${x}
|
||||
done
|
||||
|
||||
copy_exec /sbin/chzdev
|
||||
copy_exec /sbin/lszdev
|
||||
copy_exec /sbin/vmcp
|
||||
|
||||
_tempfile=$(mktemp --tmpdir initramfs-zdev.XXXXXX)
|
||||
|
||||
# Obtain early + root device configuration
|
||||
chzdev --export "$_tempfile" --persistent --by-path / \
|
||||
--by-attrib "zdev:early=1" --quiet --type 2>/dev/null
|
||||
|
||||
# Apply via --import to prevent other devices from being configured.
|
||||
# Rename the resulting cio-ignore rule to ensure that it does not override
|
||||
# the one copied by the initramfs udev hook to /lib/udev.
|
||||
chzdev --import "$_tempfile" --persistent \
|
||||
--base "/etc/udev/rules.d/41-cio-ignore.rules=$DESTDIR/etc/udev/rules.d/41-cio-ignore-root.rules" \
|
||||
--base "/etc=$DESTDIR/etc" --yes --quiet --no-root-update --force \
|
||||
>/dev/null
|
||||
|
||||
rm -f "$_tempfile"
|
||||
67
zdev/initramfs/scripts/init-top/zdev
Normal file
67
zdev/initramfs/scripts/init-top/zdev
Normal file
@@ -0,0 +1,67 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright IBM Corp. 2017
|
||||
#
|
||||
# s390-tools is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the MIT license. See LICENSE for details.
|
||||
#
|
||||
# scripts/init-top/zdev
|
||||
# Parse the kernel command line for rd.zdev kernel parameters. These
|
||||
# parameters are evaluated and used to configure z Systems specific devices.
|
||||
#
|
||||
# Format:
|
||||
# rd.zdev=no-auto
|
||||
#
|
||||
# where
|
||||
#
|
||||
# no-auto: Indicates that firmware-provided I/O configuration data
|
||||
# should not be applied.
|
||||
#
|
||||
|
||||
PREREQ="udev"
|
||||
|
||||
prereqs()
|
||||
{
|
||||
echo "$PREREQ"
|
||||
}
|
||||
|
||||
case $1 in
|
||||
prereqs)
|
||||
prereqs
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
. /scripts/functions
|
||||
|
||||
zdev_fw_file="/sys/firmware/sclp_sd/config/data"
|
||||
zdev_base_args="--force --yes --no-root-update --no-settle --auto-conf --quiet"
|
||||
|
||||
if [ -e "$zdev_fw_file" ] ; then
|
||||
zdev_auto=1
|
||||
else
|
||||
zdev_auto=0
|
||||
fi
|
||||
|
||||
for x in $(cat /proc/cmdline); do
|
||||
case ${x} in
|
||||
rd.zdev=*)
|
||||
zdev_arg=${x#*=}
|
||||
if [ "$zdev_arg" = "no-auto" ] ; then
|
||||
zdev_auto=0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ $zdev_auto -eq 1 ] ; then
|
||||
log_begin_msg "Starting firmware auto-configuration"
|
||||
chzdev --import "$zdev_fw_file" $zdev_base_args
|
||||
log_end_msg
|
||||
|
||||
# Repeat cold-plug after creating udev rules
|
||||
udevadm control --reload
|
||||
udevadm trigger --type=subsystems --action=add
|
||||
udevadm trigger --action=add
|
||||
udevadm settle || true
|
||||
fi
|
||||
@@ -334,6 +334,35 @@ a specific attribute.
|
||||
.PP
|
||||
.
|
||||
.
|
||||
.SS "Special settings"
|
||||
The following special settings affect how devices are handled by chzdev:
|
||||
.PP
|
||||
.
|
||||
.BR zdev:early =0|1
|
||||
.RS 4
|
||||
Control in which stage of the boot process a device is activated:
|
||||
.TP 4
|
||||
.B 0
|
||||
Device is activated normally during boot (default).
|
||||
.PP
|
||||
.TP 4
|
||||
.B 1
|
||||
Device is activated early in the boot process, by the initial RAM-disk.
|
||||
.PP
|
||||
Specify a value of 1 for this attribute in any of the following situations:
|
||||
.TP 4
|
||||
\(bu
|
||||
To ensure that your settings override auto-configuration settings.
|
||||
.PP
|
||||
.TP 4
|
||||
\(bu
|
||||
To ensure that a device required to access the root file system is correctly
|
||||
enabled during boot. An example would be a networking device, or a device that
|
||||
is intended to extend a logical volume that provides the root file system.
|
||||
.PP
|
||||
.RE
|
||||
.
|
||||
.
|
||||
.SH ACTIONS
|
||||
You can use one of the action options listed below to specify the
|
||||
.B main tool action
|
||||
@@ -409,17 +438,27 @@ default value.
|
||||
.PP
|
||||
.
|
||||
.OD import "" "FILENAME" "|-"
|
||||
Import configuration data from a text file.
|
||||
Import configuration data from a text or machine-provided file.
|
||||
|
||||
Reads configuration data from FILENAME and applies it. If a single hyphen ("-")
|
||||
is specified as FILENAME data is read from the standard input stream. The
|
||||
input format of the data read must be the same format as produced by the
|
||||
chzdev \-\-export action.
|
||||
input format must be either in the format as produced by the chzdev \-\-export
|
||||
action, or in the format of a machine-provided I/O configuration data file.
|
||||
|
||||
.B Machine-provided data:
|
||||
Some machine models provide I/O configuration data which is made available
|
||||
by the Linux kernel via a sysfs interface. While this data is intended for
|
||||
automatic consumption during the boot phase, you can also apply it manually
|
||||
using the \-\-import action like in the following example
|
||||
|
||||
.B Example:
|
||||
.CL chzdev --import /sys/firmware/sclp_sd/config/data
|
||||
|
||||
.B Note:
|
||||
By default all configuration data that is read is also applied. To reduce the
|
||||
scope of imported configuration data, you can select specific devices, a device
|
||||
type, or define whether only data for the active or persistent configuration
|
||||
should be imported.
|
||||
type, or define whether only data for the active, persistent or
|
||||
auto-configuration should be imported.
|
||||
.PP
|
||||
.
|
||||
.OD list-attributes "l" ""
|
||||
@@ -462,6 +501,18 @@ on reboot, or when a device becomes unavailable, or when a device driver is
|
||||
unloaded.
|
||||
.PP
|
||||
.
|
||||
.OD auto-conf "" ""
|
||||
Apply changes to the auto-configuration only.
|
||||
|
||||
This option is used internally to apply machine-provided I/O configuration data
|
||||
to a Linux system.
|
||||
|
||||
.B Note:
|
||||
There is typically no need for users to specify this option directly.
|
||||
In particular, user-initiated changes to this configuration will be lost
|
||||
the next time that machine-provided data is obtained (i.e. during boot).
|
||||
.PP
|
||||
.
|
||||
.OD base "" "PATH" | "KEY" = "VALUE"
|
||||
Change file system paths used to access files.
|
||||
|
||||
@@ -518,6 +569,15 @@ device configuration persistent. Typically such steps include rebuilding the
|
||||
initial RAM disk, or modifying the kernel command line.
|
||||
.PP
|
||||
.
|
||||
.OD no-settle "" ""
|
||||
Do not wait for udev processing to complete.
|
||||
|
||||
Skips all calls to the udevadm tool that are intended to wait for udev to
|
||||
finish processing before continuing. There is typically no need to use this
|
||||
option unless chzdev is run in an environment where udev is not fully
|
||||
functional (such as in the early phase of an initial RAM disk).
|
||||
.PP
|
||||
.
|
||||
.OD persistent "p" ""
|
||||
Apply changes to persistent configuration only.
|
||||
|
||||
|
||||
@@ -69,12 +69,13 @@ With no further options specified, the output format defaults to list format.
|
||||
.
|
||||
.
|
||||
.SS "Configurations"
|
||||
There are two sources for configuration information: the active configuration
|
||||
of the currently running system, and the persistent configuration stored in
|
||||
configuration files.
|
||||
There are three sources for configuration information: the active configuration
|
||||
of the currently running system, the persistent configuration stored in
|
||||
configuration files, and the auto-configuration that is provided by some
|
||||
machine types to automatically enable I/O devices.
|
||||
.PP
|
||||
By default lszdev displays information from both the active and the persistent
|
||||
configuration.
|
||||
configuration, and, if available, from the auto-configuration.
|
||||
.PP
|
||||
.
|
||||
.
|
||||
@@ -319,6 +320,19 @@ Restricts output to information obtained from the active configuration, that
|
||||
is information from the running system.
|
||||
.PP
|
||||
.
|
||||
.OD auto-conf "" ""
|
||||
List information from the auto-configuration only.
|
||||
|
||||
Restricts output to information obtained from the auto-configuration.
|
||||
The auto-configuration is the collection of configuration data obtained
|
||||
automatically on some machine models during boot.
|
||||
|
||||
.B Note:
|
||||
This data is refreshed during each boot. Also configuration directives in
|
||||
the auto-configuration only take effect if there is no directive for the
|
||||
same device in the persistent configuration.
|
||||
.PP
|
||||
.
|
||||
.OD base "" "PATH" | "KEY" = "VALUE"
|
||||
Change file system paths used to access files.
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ ALL_CPPFLAGS += -I ../include -std=gnu99 -Wno-unused-parameter \
|
||||
chzdev_objects += attrib.o chzdev.o device.o devnode.o devtype.o exit_code.o \
|
||||
export.o hash.o inuse.o misc.o namespace.o opts.o path.o \
|
||||
root.o select.o setting.o subtype.o table.o table_attribs.o \
|
||||
table_types.o net.o
|
||||
table_types.o net.o firmware.o internal.o
|
||||
|
||||
# Devtype Helpers
|
||||
chzdev_objects += blkinfo.o ccw.o ccwgroup.o findmnt.o modprobe.o module.o \
|
||||
@@ -38,7 +38,7 @@ chzdev_objects += generic_ccw.o
|
||||
lszdev_objects += attrib.o lszdev.o device.o devnode.o devtype.o exit_code.o \
|
||||
export.o hash.o inuse.o misc.o namespace.o opts.o path.o \
|
||||
root.o select.o setting.o subtype.o table.o table_types.o \
|
||||
net.o
|
||||
net.o internal.o
|
||||
|
||||
# Devtype Helpers
|
||||
lszdev_objects += blkinfo.o ccw.o ccwgroup.o findmnt.o modprobe.o module.o \
|
||||
|
||||
100
zdev/src/ccw.c
100
zdev/src/ccw.c
@@ -73,6 +73,7 @@ struct attrib ccw_attr_cmb_enable = {
|
||||
" 1: Data collection is enabled (rewrite 1 to reset data)\n",
|
||||
.rewrite = 1,
|
||||
.defval = "0",
|
||||
.order_cmp = ccw_offline_only_order_cmp,
|
||||
.accept = ACCEPT_ARRAY(ACCEPT_RANGE(0, 1)),
|
||||
};
|
||||
|
||||
@@ -892,12 +893,13 @@ static exit_code_t collect_group_cb(struct subtype *st, const char *id,
|
||||
}
|
||||
|
||||
/* Set bits for all persistently configured CCW devices. */
|
||||
static char ***id_bitmap_collect(void)
|
||||
static char ***id_bitmap_collect(bool autoconf)
|
||||
{
|
||||
char ***id_bitmap;
|
||||
int i, j;
|
||||
struct devtype *dt;
|
||||
struct subtype *st;
|
||||
config_t config = autoconf ? config_autoconf : config_persistent;
|
||||
|
||||
id_bitmap = id_bitmap_new();
|
||||
|
||||
@@ -906,14 +908,14 @@ static char ***id_bitmap_collect(void)
|
||||
for (j = 0; (st = dt->subtypes[j]); j++) {
|
||||
/* Collect CCW device IDs. */
|
||||
if (st->namespace == &ccw_namespace) {
|
||||
subtype_for_each_id(st, config_persistent,
|
||||
subtype_for_each_id(st, config,
|
||||
collect_cb, id_bitmap);
|
||||
}
|
||||
/* Collect CCWGROUP device IDs. Since there may be
|
||||
* multiple namespaces, we need to make use of this
|
||||
* hack. */
|
||||
if (ccwgroup_compatible_namespace(st->namespace)) {
|
||||
subtype_for_each_id(st, config_persistent,
|
||||
subtype_for_each_id(st, config,
|
||||
collect_group_cb,
|
||||
id_bitmap);
|
||||
}
|
||||
@@ -952,7 +954,7 @@ static void range_add(struct util_list *list, struct ccw_devid *from,
|
||||
free(f_str);
|
||||
}
|
||||
|
||||
static struct util_list *cio_ignore_get_ranges(void)
|
||||
static struct util_list *cio_ignore_get_ranges(bool autoconf)
|
||||
{
|
||||
char ***id_bitmap;
|
||||
unsigned int cssid, ssid, devno;
|
||||
@@ -962,7 +964,7 @@ static struct util_list *cio_ignore_get_ranges(void)
|
||||
|
||||
ranges = strlist_new();
|
||||
|
||||
id_bitmap = id_bitmap_collect();
|
||||
id_bitmap = id_bitmap_collect(autoconf);
|
||||
for (cssid = 0; cssid < CSSID_MAX; cssid++) {
|
||||
if (!id_bitmap[cssid])
|
||||
continue;
|
||||
@@ -1003,24 +1005,34 @@ static struct util_list *cio_ignore_get_ranges(void)
|
||||
}
|
||||
|
||||
/* Persistently configure cio_ignore. */
|
||||
exit_code_t ccw_blacklist_persist(void)
|
||||
static exit_code_t _ccw_blacklist_persist(bool autoconf)
|
||||
{
|
||||
struct util_list *ranges;
|
||||
char *id_list;
|
||||
exit_code_t rc;
|
||||
|
||||
/* Get string to write to /proc/cio_ignore. */
|
||||
ranges = cio_ignore_get_ranges();
|
||||
ranges = cio_ignore_get_ranges(autoconf);
|
||||
id_list = strlist_flatten(ranges, ",");
|
||||
strlist_free(ranges);
|
||||
|
||||
/* Write udev rule to automatically write cio_ignore. */
|
||||
rc = udev_ccw_write_cio_ignore(id_list);
|
||||
rc = udev_ccw_write_cio_ignore(id_list, autoconf);
|
||||
free(id_list);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
exit_code_t ccw_blacklist_persist(void)
|
||||
{
|
||||
exit_code_t rc1, rc2;
|
||||
|
||||
rc1 = _ccw_blacklist_persist(false);
|
||||
rc2 = _ccw_blacklist_persist(true);
|
||||
|
||||
return rc1 ? rc1 : rc2;
|
||||
}
|
||||
|
||||
/*
|
||||
* CCW device ID namespace.
|
||||
*/
|
||||
@@ -1368,7 +1380,13 @@ static bool ccw_st_exists_active(struct subtype *st, const char *id)
|
||||
/* Check if a configuration exists for a CCW device with the specified @id. */
|
||||
static bool ccw_st_exists_persistent(struct subtype *st, const char *id)
|
||||
{
|
||||
return udev_ccw_exists(st->name, id);
|
||||
return udev_ccw_exists(st->name, id, false);
|
||||
}
|
||||
|
||||
/* Check if a configuration exists for a CCW device with the specified @id. */
|
||||
static bool ccw_st_exists_autoconf(struct subtype *st, const char *id)
|
||||
{
|
||||
return udev_ccw_exists(st->name, id, true);
|
||||
}
|
||||
|
||||
static bool get_ids_cb(const char *file, void *data)
|
||||
@@ -1404,7 +1422,14 @@ static void ccw_st_add_active_ids(struct subtype *st, struct util_list *ids)
|
||||
* to strlist @ids. */
|
||||
static void ccw_st_add_persistent_ids(struct subtype *st, struct util_list *ids)
|
||||
{
|
||||
udev_get_device_ids(st->name, ids);
|
||||
udev_get_device_ids(st->name, ids, false);
|
||||
}
|
||||
|
||||
/* Add the IDs of all CCW devices for which a autoconf configuration exists
|
||||
* to strlist @ids. */
|
||||
static void ccw_st_add_autoconf_ids(struct subtype *st, struct util_list *ids)
|
||||
{
|
||||
udev_get_device_ids(st->name, ids, true);
|
||||
}
|
||||
|
||||
/* Read the configuration of the CCW device with the specified @id from the
|
||||
@@ -1440,7 +1465,16 @@ static exit_code_t ccw_st_read_persistent(struct subtype *st,
|
||||
struct device *dev,
|
||||
read_scope_t scope)
|
||||
{
|
||||
return udev_ccw_read_device(dev);
|
||||
return udev_ccw_read_device(dev, false);
|
||||
}
|
||||
|
||||
/* Read the configuration of the CCW device with the specified @id from the
|
||||
* autoconf configuration and add the resulting data to @dev. */
|
||||
static exit_code_t ccw_st_read_autoconf(struct subtype *st,
|
||||
struct device *dev,
|
||||
read_scope_t scope)
|
||||
{
|
||||
return udev_ccw_read_device(dev, true);
|
||||
}
|
||||
|
||||
static int get_online(struct setting_list *list)
|
||||
@@ -1505,7 +1539,14 @@ static exit_code_t ccw_st_configure_active(struct subtype *st,
|
||||
static exit_code_t ccw_st_configure_persistent(struct subtype *st,
|
||||
struct device *dev)
|
||||
{
|
||||
return udev_ccw_write_device(dev);
|
||||
return udev_ccw_write_device(dev, false);
|
||||
}
|
||||
|
||||
/* Create a autoconf configuration for the specified device @dev. */
|
||||
static exit_code_t ccw_st_configure_autoconf(struct subtype *st,
|
||||
struct device *dev)
|
||||
{
|
||||
return udev_ccw_write_device(dev, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -1552,7 +1593,22 @@ static exit_code_t ccw_st_deconfigure_active(struct subtype *st,
|
||||
static exit_code_t ccw_st_deconfigure_persistent(struct subtype *st,
|
||||
struct device *dev)
|
||||
{
|
||||
return udev_remove_rule(st->name, dev->id);
|
||||
return udev_remove_rule(st->name, dev->id, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* ccw_st_deconfigure_autoconf - Deconfigure device in autoconf
|
||||
* configuration set
|
||||
* @st: Subtype of target device
|
||||
* @dev: Target device
|
||||
*
|
||||
* Deconfigure device @dev in the autoconf configuration set. Return %EXIT_OK
|
||||
* on success, an error code otherwise.
|
||||
*/
|
||||
static exit_code_t ccw_st_deconfigure_autoconf(struct subtype *st,
|
||||
struct device *dev)
|
||||
{
|
||||
return udev_remove_rule(st->name, dev->id, true);
|
||||
}
|
||||
|
||||
/* Perform basic sanity checks. */
|
||||
@@ -1589,6 +1645,8 @@ static void ccw_st_online_set(struct subtype *st, struct device *dev,
|
||||
setting_list_apply(dev->active.settings, a, name, value);
|
||||
if (SCOPE_PERSISTENT(config))
|
||||
setting_list_apply(dev->persistent.settings, a, name, value);
|
||||
if (SCOPE_AUTOCONF(config))
|
||||
setting_list_apply(dev->autoconf.settings, a, name, value);
|
||||
}
|
||||
|
||||
/* Determine the online state of the specified CCW device (0=offline, 1=online,
|
||||
@@ -1596,14 +1654,16 @@ static void ccw_st_online_set(struct subtype *st, struct device *dev,
|
||||
static int ccw_st_online_get(struct subtype *st, struct device *dev,
|
||||
config_t config)
|
||||
{
|
||||
int act_online = 1, pers_online = 1;
|
||||
int act_online = 1, pers_online = 1, auto_online = 1;
|
||||
|
||||
if (SCOPE_ACTIVE(config))
|
||||
act_online = get_online(dev->active.settings);
|
||||
if (SCOPE_PERSISTENT(config))
|
||||
pers_online = get_online(dev->persistent.settings);
|
||||
if (SCOPE_AUTOCONF(config))
|
||||
auto_online = get_online(dev->autoconf.settings);
|
||||
|
||||
return MIN(act_online, pers_online);
|
||||
return MIN(MIN(act_online, pers_online), auto_online);
|
||||
}
|
||||
|
||||
/* Determine if the online state of the specified CCW device was specified */
|
||||
@@ -1622,6 +1682,11 @@ static bool ccw_st_online_specified(struct subtype *st, struct device *dev,
|
||||
if (s && s->specified)
|
||||
return true;
|
||||
}
|
||||
if (SCOPE_AUTOCONF(config) && dev->autoconf.settings) {
|
||||
s = setting_list_find(dev->autoconf.settings, "online");
|
||||
if (s && s->specified)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -1769,18 +1834,23 @@ struct subtype ccw_subtype = {
|
||||
|
||||
.exists_active = &ccw_st_exists_active,
|
||||
.exists_persistent = &ccw_st_exists_persistent,
|
||||
.exists_autoconf = &ccw_st_exists_autoconf,
|
||||
|
||||
.add_active_ids = &ccw_st_add_active_ids,
|
||||
.add_persistent_ids = &ccw_st_add_persistent_ids,
|
||||
.add_autoconf_ids = &ccw_st_add_autoconf_ids,
|
||||
|
||||
.read_active = &ccw_st_read_active,
|
||||
.read_persistent = &ccw_st_read_persistent,
|
||||
.read_autoconf = &ccw_st_read_autoconf,
|
||||
|
||||
.configure_active = &ccw_st_configure_active,
|
||||
.configure_persistent = &ccw_st_configure_persistent,
|
||||
.configure_autoconf = &ccw_st_configure_autoconf,
|
||||
|
||||
.deconfigure_active = &ccw_st_deconfigure_active,
|
||||
.deconfigure_persistent = &ccw_st_deconfigure_persistent,
|
||||
.deconfigure_autoconf = &ccw_st_deconfigure_autoconf,
|
||||
|
||||
.check_pre_configure = &ccw_st_check_pre_configure,
|
||||
|
||||
|
||||
@@ -426,6 +426,8 @@ static void ccwgroup_st_online_set(struct subtype *st, struct device *dev,
|
||||
}
|
||||
if (SCOPE_PERSISTENT(config))
|
||||
setting_list_apply(dev->persistent.settings, a, name, value);
|
||||
if (SCOPE_AUTOCONF(config))
|
||||
setting_list_apply(dev->autoconf.settings, a, name, value);
|
||||
}
|
||||
|
||||
static int get_online(struct setting_list *list)
|
||||
@@ -446,18 +448,20 @@ static int get_online(struct setting_list *list)
|
||||
}
|
||||
|
||||
/* Return -1 if online state is not configured, 0 for offline and 1 for online.
|
||||
* If multiple configurations are specified, return the minimum of both. */
|
||||
* If multiple configurations are specified, return the minimum of all. */
|
||||
static int ccwgroup_st_online_get(struct subtype *st, struct device *dev,
|
||||
config_t config)
|
||||
{
|
||||
int act_online = 1, pers_online = 1;
|
||||
int act_online = 1, pers_online = 1, auto_online = 1;
|
||||
|
||||
if (SCOPE_ACTIVE(config))
|
||||
act_online = get_online(dev->active.settings);
|
||||
if (SCOPE_PERSISTENT(config))
|
||||
pers_online = get_online(dev->persistent.settings);
|
||||
if (SCOPE_AUTOCONF(config))
|
||||
auto_online = get_online(dev->autoconf.settings);
|
||||
|
||||
return MIN(act_online, pers_online);
|
||||
return MIN(MIN(act_online, pers_online), auto_online);
|
||||
}
|
||||
|
||||
/* Determine if the online state of the specified device was modified. */
|
||||
@@ -476,6 +480,11 @@ static bool ccwgroup_st_online_specified(struct subtype *st,
|
||||
if (s && s->specified)
|
||||
return true;
|
||||
}
|
||||
if (SCOPE_AUTOCONF(config) && dev->autoconf.settings) {
|
||||
s = setting_list_find(dev->autoconf.settings, "online");
|
||||
if (s && s->specified)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -682,7 +691,18 @@ static exit_code_t ccwgroup_st_read_persistent(struct subtype *st,
|
||||
|
||||
expand_id(data->ccwgroupdrv, dev);
|
||||
|
||||
return udev_ccwgroup_read_device(dev);
|
||||
return udev_ccwgroup_read_device(dev, false);
|
||||
}
|
||||
|
||||
static exit_code_t ccwgroup_st_read_autoconf(struct subtype *st,
|
||||
struct device *dev,
|
||||
read_scope_t scope)
|
||||
{
|
||||
struct ccwgroup_subtype_data *data = st->data;
|
||||
|
||||
expand_id(data->ccwgroupdrv, dev);
|
||||
|
||||
return udev_ccwgroup_read_device(dev, true);
|
||||
}
|
||||
|
||||
static exit_code_t ccwgroup_st_configure_active(struct subtype *st,
|
||||
@@ -693,8 +713,9 @@ static exit_code_t ccwgroup_st_configure_active(struct subtype *st,
|
||||
return device_write_active_settings(dev);
|
||||
}
|
||||
|
||||
static exit_code_t ccwgroup_st_configure_persistent(struct subtype *st,
|
||||
struct device *dev)
|
||||
static exit_code_t _ccwgroup_st_configure_persistent(struct subtype *st,
|
||||
struct device *dev,
|
||||
bool autoconf)
|
||||
{
|
||||
struct ccwgroup_subtype_data *data = st->data;
|
||||
struct ccwgroup_devid *devid = dev->devid;
|
||||
@@ -703,9 +724,22 @@ static exit_code_t ccwgroup_st_configure_persistent(struct subtype *st,
|
||||
delayed_err("Incomplete device ID specified\n");
|
||||
return EXIT_INCOMPLETE_ID;
|
||||
}
|
||||
return udev_ccwgroup_write_device(dev);
|
||||
return udev_ccwgroup_write_device(dev, autoconf);
|
||||
}
|
||||
|
||||
static exit_code_t ccwgroup_st_configure_persistent(struct subtype *st,
|
||||
struct device *dev)
|
||||
{
|
||||
return _ccwgroup_st_configure_persistent(st, dev, false);
|
||||
}
|
||||
|
||||
static exit_code_t ccwgroup_st_configure_autoconf(struct subtype *st,
|
||||
struct device *dev)
|
||||
{
|
||||
return _ccwgroup_st_configure_persistent(st, dev, true);
|
||||
}
|
||||
|
||||
|
||||
static char *ccwgroup_st_get_active_attrib_path(struct subtype *,
|
||||
struct device *, const char *);
|
||||
|
||||
@@ -733,7 +767,13 @@ static exit_code_t ccwgroup_st_deconfigure_active(struct subtype *st,
|
||||
static exit_code_t ccwgroup_st_deconfigure_persistent(struct subtype *st,
|
||||
struct device *dev)
|
||||
{
|
||||
return udev_ccwgroup_remove_rule(st->name, dev->id);
|
||||
return udev_ccwgroup_remove_rule(st->name, dev->id, false);
|
||||
}
|
||||
|
||||
static exit_code_t ccwgroup_st_deconfigure_autoconf(struct subtype *st,
|
||||
struct device *dev)
|
||||
{
|
||||
return udev_ccwgroup_remove_rule(st->name, dev->id, true);
|
||||
}
|
||||
|
||||
/* Check if a CCWGROUP device with the specified ID exists. */
|
||||
@@ -774,7 +814,12 @@ static bool ccwgroup_st_exists_active(struct subtype *st, const char *id)
|
||||
|
||||
static bool ccwgroup_st_exists_persistent(struct subtype *st, const char *id)
|
||||
{
|
||||
return udev_ccwgroup_exists(st->name, id);
|
||||
return udev_ccwgroup_exists(st->name, id, false);
|
||||
}
|
||||
|
||||
static bool ccwgroup_st_exists_autoconf(struct subtype *st, const char *id)
|
||||
{
|
||||
return udev_ccwgroup_exists(st->name, id, true);
|
||||
}
|
||||
|
||||
int ccwgroup_qsort_cmp(const void *a_ptr, const void *b_ptr)
|
||||
@@ -796,7 +841,13 @@ static void ccwgroup_st_add_active_ids(struct subtype *st,
|
||||
static void ccwgroup_st_add_persistent_ids(struct subtype *st,
|
||||
struct util_list *ids)
|
||||
{
|
||||
udev_ccwgroup_add_device_ids(st->name, ids);
|
||||
udev_ccwgroup_add_device_ids(st->name, ids, false);
|
||||
}
|
||||
|
||||
static void ccwgroup_st_add_autoconf_ids(struct subtype *st,
|
||||
struct util_list *ids)
|
||||
{
|
||||
udev_ccwgroup_add_device_ids(st->name, ids, true);
|
||||
}
|
||||
|
||||
/* Check if CCW device ID @b is part of CCW group device ID @a. */
|
||||
@@ -1185,18 +1236,23 @@ struct subtype ccwgroup_subtype = {
|
||||
|
||||
.exists_active = &ccwgroup_st_exists_active,
|
||||
.exists_persistent = &ccwgroup_st_exists_persistent,
|
||||
.exists_autoconf = &ccwgroup_st_exists_autoconf,
|
||||
|
||||
.add_active_ids = &ccwgroup_st_add_active_ids,
|
||||
.add_persistent_ids = &ccwgroup_st_add_persistent_ids,
|
||||
.add_autoconf_ids = &ccwgroup_st_add_autoconf_ids,
|
||||
|
||||
.read_active = &ccwgroup_st_read_active,
|
||||
.read_persistent = &ccwgroup_st_read_persistent,
|
||||
.read_autoconf = &ccwgroup_st_read_autoconf,
|
||||
|
||||
.configure_active = &ccwgroup_st_configure_active,
|
||||
.configure_persistent = &ccwgroup_st_configure_persistent,
|
||||
.configure_autoconf = &ccwgroup_st_configure_autoconf,
|
||||
|
||||
.deconfigure_active = &ccwgroup_st_deconfigure_active,
|
||||
.deconfigure_persistent = &ccwgroup_st_deconfigure_persistent,
|
||||
.deconfigure_autoconf = &ccwgroup_st_deconfigure_autoconf,
|
||||
|
||||
.online_set = &ccwgroup_st_online_set,
|
||||
.online_get = &ccwgroup_st_online_get,
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "devnode.h"
|
||||
#include "devtype.h"
|
||||
#include "export.h"
|
||||
#include "firmware.h"
|
||||
#include "inuse.h"
|
||||
#include "misc.h"
|
||||
#include "module.h"
|
||||
@@ -85,6 +86,7 @@ struct options {
|
||||
config_t config;
|
||||
unsigned int active:1;
|
||||
unsigned int persistent:1;
|
||||
unsigned int auto_conf:1;
|
||||
struct util_list *remove; /* List of struct strlist_node */
|
||||
unsigned int remove_all:1;
|
||||
unsigned int force:1;
|
||||
@@ -94,6 +96,7 @@ struct options {
|
||||
struct util_list *base; /* List of struct strlist_node */
|
||||
unsigned int verbose:1;
|
||||
unsigned int quiet:1;
|
||||
unsigned int no_settle:1;
|
||||
};
|
||||
|
||||
/* Makefile converts chzdev_usage.txt into C file which we include here. */
|
||||
@@ -135,6 +138,8 @@ enum {
|
||||
OPT_VERSION = 'v',
|
||||
OPT_VERBOSE = 'V',
|
||||
OPT_QUIET = 'q',
|
||||
OPT_NO_SETTLE = (OPT_ANONYMOUS_BASE+__COUNTER__),
|
||||
OPT_AUTO_CONF = (OPT_ANONYMOUS_BASE+__COUNTER__),
|
||||
};
|
||||
|
||||
static struct opts_conflict conflict_list[] = {
|
||||
@@ -169,11 +174,13 @@ static struct opts_conflict conflict_list[] = {
|
||||
OPTS_CONFLICT(OPT_APPLY,
|
||||
OPT_DECONFIGURE, OPT_LIST_ATTRIBS, OPT_HELP_ATTRIBS,
|
||||
OPT_LIST_TYPES, OPT_EXPORT, OPT_IMPORT, OPT_REMOVE,
|
||||
OPT_REMOVE_ALL, OPT_ACTIVE, OPT_PERSISTENT, 0),
|
||||
OPT_REMOVE_ALL, OPT_ACTIVE, 0),
|
||||
OPTS_CONFLICT(OPT_ONLINE,
|
||||
OPT_OFFLINE),
|
||||
OPTS_CONFLICT(OPT_QUIET,
|
||||
OPT_VERBOSE),
|
||||
OPTS_CONFLICT(OPT_AUTO_CONF,
|
||||
OPT_TYPE, OPT_LIST_ATTRIBS, OPT_LIST_TYPES),
|
||||
OPTS_CONFLICT(0, 0),
|
||||
};
|
||||
|
||||
@@ -207,6 +214,7 @@ static const struct option opt_list[] = {
|
||||
/* Options. */
|
||||
{ "active", no_argument, NULL, OPT_ACTIVE },
|
||||
{ "persistent", no_argument, NULL, OPT_PERSISTENT },
|
||||
{ "auto-conf", no_argument, NULL, OPT_AUTO_CONF },
|
||||
{ "remove", required_argument, NULL, OPT_REMOVE },
|
||||
{ "remove-all", no_argument, NULL, OPT_REMOVE_ALL },
|
||||
{ "force", no_argument, NULL, OPT_FORCE },
|
||||
@@ -216,6 +224,7 @@ static const struct option opt_list[] = {
|
||||
{ "base", required_argument, NULL, OPT_BASE },
|
||||
{ "verbose", no_argument, NULL, OPT_VERBOSE },
|
||||
{ "quiet", no_argument, NULL, OPT_QUIET },
|
||||
{ "no-settle", no_argument, NULL, OPT_NO_SETTLE },
|
||||
{ NULL, no_argument, NULL, 0 },
|
||||
};
|
||||
|
||||
@@ -879,6 +888,11 @@ static exit_code_t parse_options(struct options *opts, int argc, char *argv[])
|
||||
opts->persistent = 1;
|
||||
break;
|
||||
|
||||
case OPT_AUTO_CONF:
|
||||
/* --auto-conf */
|
||||
opts->auto_conf = 1;
|
||||
break;
|
||||
|
||||
case OPT_REMOVE:
|
||||
/* --remove ATTRIB */
|
||||
strlist_add(opts->remove, "%s", optarg);
|
||||
@@ -936,6 +950,11 @@ static exit_code_t parse_options(struct options *opts, int argc, char *argv[])
|
||||
opts->quiet = 1;
|
||||
break;
|
||||
|
||||
case OPT_NO_SETTLE:
|
||||
/* --no-settle */
|
||||
opts->no_settle = 1;
|
||||
break;
|
||||
|
||||
case ':':
|
||||
/* Missing option argument. */
|
||||
syntax("Option '%s' requires an argument\n",
|
||||
@@ -968,7 +987,13 @@ static exit_code_t parse_options(struct options *opts, int argc, char *argv[])
|
||||
goto out;
|
||||
|
||||
/* Determine configuration set. */
|
||||
opts->config = get_config(opts->active, opts->persistent);
|
||||
if (!opts->active && !opts->persistent && !opts->auto_conf) {
|
||||
/* Default configuration targets are active + persistent */
|
||||
opts->config = config_active | config_persistent;
|
||||
} else {
|
||||
opts->config = get_config(opts->active, opts->persistent,
|
||||
opts->auto_conf);
|
||||
}
|
||||
|
||||
/* Handle positional parameters. */
|
||||
rc = parse_positional(opts, argc, argv, optind);
|
||||
@@ -1040,13 +1065,15 @@ static void remove_all_settings(struct setting_list *settings, int active)
|
||||
/* Perform --remove-all operation for specified config on device. */
|
||||
static exit_code_t device_remove_all(struct device *dev, config_t config)
|
||||
{
|
||||
int active, persistent;
|
||||
int active, persistent, autoconf;
|
||||
|
||||
active = SCOPE_ACTIVE(config) ?
|
||||
count_removable(dev->active.settings, 1) : 0;
|
||||
persistent = SCOPE_PERSISTENT(config) ?
|
||||
count_removable(dev->persistent.settings, 0) : 0;
|
||||
if (active == 0 && persistent == 0) {
|
||||
autoconf = SCOPE_AUTOCONF(config) ?
|
||||
count_removable(dev->autoconf.settings, 0) : 0;
|
||||
if (active == 0 && persistent == 0 && autoconf == 0) {
|
||||
delayed_err("No removable settings found\n");
|
||||
return EXIT_SETTING_NOT_FOUND;
|
||||
}
|
||||
@@ -1054,6 +1081,8 @@ static exit_code_t device_remove_all(struct device *dev, config_t config)
|
||||
remove_all_settings(dev->active.settings, 1);
|
||||
if (persistent)
|
||||
remove_all_settings(dev->persistent.settings, 0);
|
||||
if (autoconf)
|
||||
remove_all_settings(dev->autoconf.settings, 0);
|
||||
|
||||
return EXIT_OK;
|
||||
}
|
||||
@@ -1123,6 +1152,13 @@ static exit_code_t device_remove_settings(struct device *dev,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (SCOPE_AUTOCONF(config)) {
|
||||
rc = remove_settings(dev->autoconf.settings, names, found,
|
||||
notfound, 0);
|
||||
if (rc)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!util_list_is_empty(notfound)) {
|
||||
flat = strlist_flatten(notfound, " ");
|
||||
delayed_err("Setting not found: %s\n", flat);
|
||||
@@ -1190,7 +1226,8 @@ static void print_dev_config_info(struct device *dev, config_t config)
|
||||
|
||||
changes = setting_get_changes(
|
||||
SCOPE_ACTIVE(config) ? dev->active.settings : NULL,
|
||||
SCOPE_PERSISTENT(config) ? dev->persistent.settings : NULL);
|
||||
SCOPE_PERSISTENT(config) ? dev->persistent.settings : NULL,
|
||||
SCOPE_AUTOCONF(config) ? dev->autoconf.settings : NULL);
|
||||
if (changes)
|
||||
info(" Changes: %s\n", changes);
|
||||
free(changes);
|
||||
@@ -1248,6 +1285,12 @@ static exit_code_t cfg_mod_existence(struct device *dev, config_t config)
|
||||
dev->persistent.modified = 1;
|
||||
}
|
||||
|
||||
/* Create autoconf config if necessary. */
|
||||
if (SCOPE_AUTOCONF(config) && !dev->autoconf.exists) {
|
||||
dev->autoconf.exists = 1;
|
||||
dev->autoconf.modified = 1;
|
||||
}
|
||||
|
||||
return EXIT_OK;
|
||||
}
|
||||
|
||||
@@ -1287,11 +1330,14 @@ online:
|
||||
/* Make sure there's an online attribute. */
|
||||
ensure_online(dev, config_active);
|
||||
ensure_online(dev, config_persistent);
|
||||
ensure_online(dev, config_autoconf);
|
||||
|
||||
mand:
|
||||
/* Ensure default values for mandatory attributes. */
|
||||
setting_list_apply_defaults(dev->persistent.settings,
|
||||
dev->subtype->dev_attribs, true);
|
||||
setting_list_apply_defaults(dev->autoconf.settings,
|
||||
dev->subtype->dev_attribs, true);
|
||||
|
||||
return EXIT_OK;
|
||||
}
|
||||
@@ -1324,10 +1370,11 @@ static exit_code_t cfg_write(struct device *dev, int prereq, config_t config,
|
||||
struct subtype *st = dev->subtype;
|
||||
exit_code_t rc = EXIT_OK;
|
||||
|
||||
if (!device_needs_writing(dev, config))
|
||||
if (!device_needs_writing(dev, config) && !force)
|
||||
goto out;
|
||||
|
||||
if (check_active && config == config_persistent &&
|
||||
if (check_active && !SCOPE_ACTIVE(config) &&
|
||||
(SCOPE_PERSISTENT(config) || SCOPE_AUTOCONF(config)) &&
|
||||
(!dev->active.exists && !dev->active.definable)) {
|
||||
rc = handle_nonexistent(dev);
|
||||
if (rc)
|
||||
@@ -1368,7 +1415,7 @@ static exit_code_t cfg_configure(struct subtype *st, const char *id,
|
||||
if (proc_ptr)
|
||||
*proc_ptr = 0;
|
||||
|
||||
/* Read current device data. Note that we read data from both
|
||||
/* Read current device data. Note that we read data from all
|
||||
* configurations to enable QETH autodetection and subtype
|
||||
* detection (e.g. dasd -> dasd_fba).*/
|
||||
dev = NULL;
|
||||
@@ -1389,23 +1436,17 @@ static exit_code_t cfg_configure(struct subtype *st, const char *id,
|
||||
|
||||
/* Exit here if we're only trying and device cannot be configured. */
|
||||
if (try && !(dev->active.exists || dev->active.definable ||
|
||||
dev->persistent.exists)) {
|
||||
dev->persistent.exists || dev->autoconf.exists)) {
|
||||
return EXIT_DEVICE_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (config == config_persistent) {
|
||||
/* Abort if a modification action is triggered for a
|
||||
* non-existing persistent device. */
|
||||
if (!dev->persistent.exists &&
|
||||
(!util_list_is_empty(opts->remove) || opts->remove_all))
|
||||
return EXIT_DEVICE_NOT_FOUND;
|
||||
/* Create device if needed by action. */
|
||||
if (opts->enable || !util_list_is_empty(opts->settings)) {
|
||||
rc = cfg_mod_existence(dev, config);
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Apply changes to device existence. */
|
||||
rc = cfg_mod_existence(dev, config);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
/* Apply changes to device settings. */
|
||||
rc = cfg_mod_settings(dev, opts, prereq);
|
||||
if (rc)
|
||||
@@ -1417,10 +1458,12 @@ static exit_code_t cfg_configure(struct subtype *st, const char *id,
|
||||
|
||||
/* Apply persistent configuration to active configuration. */
|
||||
static exit_code_t cfg_apply(struct subtype *st, const char *id, int prereq,
|
||||
struct device **dev_ptr, int *proc_ptr)
|
||||
struct device **dev_ptr, int *proc_ptr,
|
||||
bool autoconf)
|
||||
{
|
||||
exit_code_t rc;
|
||||
struct device *dev;
|
||||
struct device_state *state;
|
||||
|
||||
/* Reset processed flag. */
|
||||
if (proc_ptr)
|
||||
@@ -1443,8 +1486,9 @@ static exit_code_t cfg_apply(struct subtype *st, const char *id, int prereq,
|
||||
*proc_ptr = 1;
|
||||
dev->processed = 1;
|
||||
|
||||
state = autoconf ? &dev->autoconf : &dev->persistent;
|
||||
/* Exit here if there is no persistent configuration. */
|
||||
if (!dev->persistent.exists)
|
||||
if (!state->exists)
|
||||
return EXIT_NO_DATA;
|
||||
|
||||
/* Apply changes to device existence. */
|
||||
@@ -1453,8 +1497,7 @@ static exit_code_t cfg_apply(struct subtype *st, const char *id, int prereq,
|
||||
return rc;
|
||||
|
||||
/* Copy persistent settings to active configuration. */
|
||||
rc = device_apply_settings(dev, config_active,
|
||||
&dev->persistent.settings->list);
|
||||
rc = device_apply_settings(dev, config_active, &state->settings->list);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
@@ -1468,7 +1511,8 @@ static exit_code_t cfg_import(struct subtype *st, const char *id,
|
||||
struct device **dev_ptr, int *proc_ptr)
|
||||
{
|
||||
exit_code_t rc;
|
||||
struct setting_list *active = NULL, *persistent = NULL;
|
||||
struct setting_list *active = NULL, *persistent = NULL,
|
||||
*autoconf = NULL;
|
||||
struct device *dev;
|
||||
|
||||
/* Reset processed flag. */
|
||||
@@ -1486,6 +1530,7 @@ static exit_code_t cfg_import(struct subtype *st, const char *id,
|
||||
return EXIT_OK;
|
||||
active = setting_list_copy(dev->active.settings);
|
||||
persistent = setting_list_copy(dev->persistent.settings);
|
||||
autoconf = setting_list_copy(dev->autoconf.settings);
|
||||
} else if (!prereq) {
|
||||
/* Should not happen. */
|
||||
return EXIT_OK;
|
||||
@@ -1515,14 +1560,20 @@ static exit_code_t cfg_import(struct subtype *st, const char *id,
|
||||
&persistent->list);
|
||||
if (rc)
|
||||
goto out;
|
||||
rc = device_apply_settings(dev, config_autoconf,
|
||||
&autoconf->list);
|
||||
if (rc)
|
||||
goto out;
|
||||
}
|
||||
ensure_online(dev, config_active);
|
||||
ensure_online(dev, config_persistent);
|
||||
ensure_online(dev, config_autoconf);
|
||||
|
||||
/* Write resulting device data. */
|
||||
rc = cfg_write(dev, prereq, config, 0);
|
||||
|
||||
out:
|
||||
setting_list_free(autoconf);
|
||||
setting_list_free(persistent);
|
||||
setting_list_free(active);
|
||||
|
||||
@@ -1600,11 +1651,13 @@ static exit_code_t print_config_result(struct selected_dev_node *sel,
|
||||
if (opts->deconfigure) {
|
||||
op = "deconfigure";
|
||||
verb = "deconfigured";
|
||||
if (dev)
|
||||
if (dev) {
|
||||
already = !dev->active.modified &&
|
||||
!dev->persistent.modified;
|
||||
else if (rc == EXIT_DEVICE_NOT_FOUND &&
|
||||
config == config_persistent) {
|
||||
!dev->persistent.modified &&
|
||||
!dev->autoconf.modified;
|
||||
} else if (rc == EXIT_DEVICE_NOT_FOUND &&
|
||||
(!SCOPE_ACTIVE(config) && (SCOPE_PERSISTENT(config) ||
|
||||
SCOPE_AUTOCONF(config)))) {
|
||||
rc = EXIT_OK;
|
||||
already = 1;
|
||||
}
|
||||
@@ -1615,6 +1668,10 @@ static exit_code_t print_config_result(struct selected_dev_node *sel,
|
||||
already = device_needs_writing(dev, config) ? 0 : 1;
|
||||
}
|
||||
|
||||
/* Re-do actions if run with --force */
|
||||
if (force)
|
||||
already = 0;
|
||||
|
||||
if (dev) {
|
||||
devname = dev->subtype->devname;
|
||||
devid = dev->id;
|
||||
@@ -1672,9 +1729,10 @@ static exit_code_t cfg_prereqs(struct subtype *st, const char *id,
|
||||
prereqs = selected_dev_list_new();
|
||||
subtype_add_prereqs(st, id, prereqs);
|
||||
util_list_iterate(prereqs, sel) {
|
||||
if (opts->apply)
|
||||
rc = cfg_apply(sel->st, sel->id, 1, &dev, &proc);
|
||||
else if (opts->import) {
|
||||
if (opts->apply) {
|
||||
rc = cfg_apply(sel->st, sel->id, 1, &dev, &proc,
|
||||
opts->auto_conf);
|
||||
} else if (opts->import) {
|
||||
rc = cfg_import(sel->st, sel->id, config, 1, &dev,
|
||||
&proc);
|
||||
} else {
|
||||
@@ -1747,9 +1805,11 @@ static exit_code_t configure_devices(struct options *opts, int specified,
|
||||
struct namespace *ns;
|
||||
const char *param;
|
||||
struct device *dev;
|
||||
config_t config = opts->config;
|
||||
|
||||
/* Determine list of selected devices. */
|
||||
if (opts->config == config_persistent ||
|
||||
if ((!SCOPE_ACTIVE(config) &&
|
||||
(SCOPE_PERSISTENT(config) || SCOPE_AUTOCONF(config))) ||
|
||||
(opts->select->subtype && opts->select->subtype->support_definable))
|
||||
existing = 0;
|
||||
else
|
||||
@@ -1795,9 +1855,10 @@ static exit_code_t configure_devices(struct options *opts, int specified,
|
||||
goto next;
|
||||
|
||||
/* Configure actual target device. */
|
||||
if (opts->apply)
|
||||
rc = cfg_apply(sel->st, sel->id, 0, &dev, &proc);
|
||||
else {
|
||||
if (opts->apply) {
|
||||
rc = cfg_apply(sel->st, sel->id, 0, &dev, &proc,
|
||||
opts->auto_conf);
|
||||
} else {
|
||||
rc = cfg_configure(sel->st, sel->id, opts, 0,
|
||||
0, &dev, &proc);
|
||||
}
|
||||
@@ -1893,7 +1954,7 @@ static exit_code_t deconfigure_one_device(struct subtype *st, const char *id,
|
||||
dev->processed = 1;
|
||||
|
||||
if (try && !(dev->active.exists || dev->active.definable ||
|
||||
dev->persistent.exists)) {
|
||||
dev->persistent.exists || dev->autoconf.exists)) {
|
||||
/* Attempt to deconfigure this device will fail. */
|
||||
return EXIT_DEVICE_NOT_FOUND;
|
||||
}
|
||||
@@ -1903,7 +1964,8 @@ static exit_code_t deconfigure_one_device(struct subtype *st, const char *id,
|
||||
* dev. */
|
||||
if (SCOPE_ACTIVE(config) &&
|
||||
!(dev->active.exists || dev->active.definable)) {
|
||||
if (!SCOPE_PERSISTENT(config) || !dev->persistent.exists)
|
||||
if (!((SCOPE_PERSISTENT(config) && dev->persistent.exists) ||
|
||||
(SCOPE_AUTOCONF(config) && dev->autoconf.exists)))
|
||||
return EXIT_DEVICE_NOT_FOUND;
|
||||
}
|
||||
|
||||
@@ -1927,7 +1989,12 @@ static exit_code_t deconfigure_one_device(struct subtype *st, const char *id,
|
||||
dev->persistent.deconfigured = 1;
|
||||
dev->persistent.modified = 1;
|
||||
}
|
||||
if (!dev->active.modified && !dev->persistent.modified)
|
||||
if (SCOPE_AUTOCONF(config) && dev->autoconf.exists) {
|
||||
dev->autoconf.deconfigured = 1;
|
||||
dev->autoconf.modified = 1;
|
||||
}
|
||||
if (!dev->active.modified && !dev->persistent.modified &&
|
||||
!dev->autoconf.modified)
|
||||
return EXIT_OK;
|
||||
|
||||
/* Pre-write check. */
|
||||
@@ -2071,7 +2138,8 @@ static void print_type_config_info(struct devtype *dt, const char *title,
|
||||
|
||||
changes = setting_get_changes(
|
||||
SCOPE_ACTIVE(config) ? dt->active_settings : NULL,
|
||||
SCOPE_PERSISTENT(config) ? dt->persistent_settings : NULL);
|
||||
SCOPE_PERSISTENT(config) ? dt->persistent_settings : NULL,
|
||||
NULL);
|
||||
if (changes)
|
||||
info(" %s: %s\n", title, changes);
|
||||
free(changes);
|
||||
@@ -2485,6 +2553,8 @@ static void action_note(const char *msg, config_t config)
|
||||
info("%s the active configuration only\n", msg);
|
||||
else if (config == config_persistent)
|
||||
info("%s the persistent configuration only\n", msg);
|
||||
else if (config == config_autoconf)
|
||||
info("%s the auto-configuration only\n", msg);
|
||||
}
|
||||
|
||||
/* Export configuration of selected devices and/or device type to file. */
|
||||
@@ -2500,9 +2570,9 @@ static exit_code_t do_export(struct options *opts)
|
||||
/* Open output stream. */
|
||||
if (strcmp(opts->export, "-") == 0) {
|
||||
fd = stdout;
|
||||
info("Exporting configuration data to standard output\n");
|
||||
info("Exporting data to standard output\n");
|
||||
} else {
|
||||
info("Exporting configuration data to %s\n", opts->export);
|
||||
info("Exporting data to %s\n", opts->export);
|
||||
if (!util_path_exists(opts->export)) {
|
||||
rc = path_create(opts->export);
|
||||
if (rc)
|
||||
@@ -2606,7 +2676,7 @@ static exit_code_t import_device(struct device *dev, struct options *opts)
|
||||
struct subtype *st = dev->subtype;
|
||||
exit_code_t rc;
|
||||
config_t config;
|
||||
int proc = 0, active, persistent;
|
||||
int proc = 0, active, persistent, autoconf;
|
||||
|
||||
if (SCOPE_ACTIVE(opts->config))
|
||||
active = (dev->active.exists || dev->active.definable);
|
||||
@@ -2616,7 +2686,16 @@ static exit_code_t import_device(struct device *dev, struct options *opts)
|
||||
persistent = dev->persistent.exists;
|
||||
else
|
||||
persistent = 0;
|
||||
config = get_config(active, persistent);
|
||||
if (SCOPE_AUTOCONF(opts->config))
|
||||
autoconf = dev->autoconf.exists;
|
||||
else
|
||||
autoconf = 0;
|
||||
|
||||
if (!active && !persistent && !autoconf) {
|
||||
/* Nothing to import */
|
||||
return EXIT_OK;
|
||||
}
|
||||
config = get_config(active, persistent, autoconf);
|
||||
|
||||
/* First check for prerequisite devices that need to be configured. */
|
||||
rc = cfg_prereqs(st, dev->id, opts, config, 0);
|
||||
@@ -2643,17 +2722,9 @@ static bool import_device_selected(struct device *dev, struct options *opts)
|
||||
if (!select_opts_dev_specified(select))
|
||||
return false;
|
||||
|
||||
/* --active */
|
||||
if (opts->config == config_active) {
|
||||
if (!dev->active.exists && !dev->active.definable)
|
||||
return false;
|
||||
}
|
||||
|
||||
/* --persistent */
|
||||
if (opts->config == config_persistent) {
|
||||
if (!dev->persistent.exists)
|
||||
return false;
|
||||
}
|
||||
/* Target configuration */
|
||||
if ((device_get_config(dev) & opts->config) == 0)
|
||||
return false;
|
||||
|
||||
/* Devtype */
|
||||
if (select->devtype && dt != select->devtype)
|
||||
@@ -2735,6 +2806,7 @@ static exit_code_t do_import(struct options *opts)
|
||||
exit_code_t drc = EXIT_OK;
|
||||
const char *filename;
|
||||
int found;
|
||||
bool is_firmware;
|
||||
|
||||
/* Open input stream. */
|
||||
if (strcmp(opts->import, "-") == 0) {
|
||||
@@ -2744,16 +2816,23 @@ static exit_code_t do_import(struct options *opts)
|
||||
fd = fopen(opts->import, "r");
|
||||
filename = opts->import;
|
||||
}
|
||||
info("Importing configuration data from %s\n", filename);
|
||||
|
||||
if (!fd) {
|
||||
error("Could not open file %s: %s\n", opts->import,
|
||||
strerror(errno));
|
||||
return EXIT_RUNTIME_ERROR;
|
||||
}
|
||||
|
||||
is_firmware = firmware_detect(fd);
|
||||
info("Importing data from %s%s\n", filename,
|
||||
is_firmware ? " (firmware format)" : "");
|
||||
|
||||
/* Read data. */
|
||||
objects = ptrlist_new();
|
||||
rc = export_read(fd, filename, objects);
|
||||
if (is_firmware)
|
||||
rc = firmware_read(fd, filename, -1, opts->config, objects);
|
||||
else
|
||||
rc = export_read(fd, filename, objects);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
@@ -2766,8 +2845,8 @@ static exit_code_t do_import(struct options *opts)
|
||||
"selection\n", filename);
|
||||
rc = EXIT_EMPTY_SELECTION;
|
||||
} else {
|
||||
error("%s: No settings found to import\n", filename);
|
||||
rc = EXIT_NO_DATA;
|
||||
info("%s: No settings found to import\n", filename);
|
||||
rc = EXIT_OK;
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
@@ -2895,6 +2974,7 @@ int main(int argc, char *argv[])
|
||||
force = opts.force;
|
||||
yes = opts.yes;
|
||||
dryrun = opts.dryrun;
|
||||
udev_no_settle = opts.no_settle;
|
||||
path_set_base(opts.base);
|
||||
|
||||
if (dryrun)
|
||||
@@ -2945,8 +3025,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if ((pers_mod_devs || pers_mod_devtypes) && !opts.no_root_check &&
|
||||
!dryrun) {
|
||||
/* If the root device/device type has been modified, additional
|
||||
* work might be necessary. */
|
||||
/* If the root device/device type or early devices have been
|
||||
* modified, additional work might be necessary. */
|
||||
rc = root_check();
|
||||
if (rc && !drc)
|
||||
drc = rc;
|
||||
|
||||
@@ -54,5 +54,7 @@ OPTIONS
|
||||
--no-root-update Skip root device update
|
||||
--dry-run Display changes without applying
|
||||
--base PATH Use PATH as base for accessing files
|
||||
--no-settle Do not wait for udev to settle
|
||||
--auto-conf Apply changes to auto-configuration only
|
||||
-V, --verbose Print additional run-time information
|
||||
-q, --quiet Print only minimal run-time information
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "ctc_auto.h"
|
||||
#include "device.h"
|
||||
#include "devtype.h"
|
||||
#include "internal.h"
|
||||
#include "misc.h"
|
||||
#include "namespace.h"
|
||||
#include "path.h"
|
||||
@@ -425,6 +426,7 @@ static struct subtype ctc_subtype = {
|
||||
&ccw_attr_online,
|
||||
&ctc_attr_buffer,
|
||||
&ctc_attr_protocol,
|
||||
&internal_attr_early,
|
||||
),
|
||||
.unknown_dev_attribs = 1,
|
||||
.support_definable = 1,
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "dasd.h"
|
||||
#include "device.h"
|
||||
#include "devtype.h"
|
||||
#include "internal.h"
|
||||
#include "misc.h"
|
||||
#include "modprobe.h"
|
||||
#include "module.h"
|
||||
@@ -316,34 +317,34 @@ static struct attrib dasd_attr_safe_offline = {
|
||||
* DASD subtype methods.
|
||||
*/
|
||||
|
||||
static bool _check_use_diag(struct setting_list *list)
|
||||
{
|
||||
struct setting *u;
|
||||
|
||||
u = setting_list_find(list, dasd_attr_use_diag.name);
|
||||
if (u && u->modified) {
|
||||
if (u->value && atoi(u->value) == 1) {
|
||||
delayed_warn("Cannot set 'use_diag=1' on non-z/VM system\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Check if use_diag setting can be correctly applied. */
|
||||
static exit_code_t check_use_diag(struct device *dev, config_t config)
|
||||
{
|
||||
struct setting *u;
|
||||
int zvm = is_zvm();
|
||||
if (is_zvm())
|
||||
return EXIT_OK;
|
||||
|
||||
if (SCOPE_ACTIVE(config)) {
|
||||
u = setting_list_find(dev->active.settings,
|
||||
dasd_attr_use_diag.name);
|
||||
if (u && u->modified) {
|
||||
if (u->value && atoi(u->value) == 1 && !zvm) {
|
||||
delayed_warn("Cannot set 'use_diag=1' on "
|
||||
"non-z/VM system\n");
|
||||
return EXIT_INVALID_CONFIG;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (SCOPE_PERSISTENT(config)) {
|
||||
u = setting_list_find(dev->persistent.settings,
|
||||
dasd_attr_use_diag.name);
|
||||
if (u && u->modified) {
|
||||
if (u->value && atoi(u->value) == 1 && !zvm) {
|
||||
delayed_warn("Cannot set 'use_diag=1' on "
|
||||
"non-z/VM system\n");
|
||||
return EXIT_INVALID_CONFIG;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (SCOPE_ACTIVE(config) && !_check_use_diag(dev->active.settings))
|
||||
return EXIT_INVALID_CONFIG;
|
||||
if (SCOPE_PERSISTENT(config) &&
|
||||
!_check_use_diag(dev->persistent.settings))
|
||||
return EXIT_INVALID_CONFIG;
|
||||
if (SCOPE_AUTOCONF(config) &&
|
||||
!_check_use_diag(dev->autoconf.settings))
|
||||
return EXIT_INVALID_CONFIG;
|
||||
|
||||
return EXIT_OK;
|
||||
}
|
||||
@@ -376,6 +377,8 @@ static void dasd_st_add_modules(struct subtype *st, struct device *dev,
|
||||
dasd_attr_use_diag.name, &changed, &aset);
|
||||
setting_list_get_bool_state(dev->persistent.settings,
|
||||
dasd_attr_use_diag.name, &changed, &pset);
|
||||
setting_list_get_bool_state(dev->autoconf.settings,
|
||||
dasd_attr_use_diag.name, &changed, &pset);
|
||||
|
||||
if (aset || pset)
|
||||
strlist_add_unique(modules, DASD_DIAG_MOD_NAME);
|
||||
@@ -589,7 +592,7 @@ static struct ccw_subtype_data dasd_eckd_data = {
|
||||
.mod = "dasd_eckd_mod",
|
||||
};
|
||||
|
||||
static struct subtype dasd_subtype_eckd = {
|
||||
struct subtype dasd_subtype_eckd = {
|
||||
.super = &ccw_subtype,
|
||||
.devtype = &dasd_devtype,
|
||||
.name = "dasd-eckd",
|
||||
@@ -614,6 +617,7 @@ static struct subtype dasd_subtype_eckd = {
|
||||
&dasd_attr_reservation_policy,
|
||||
&dasd_attr_last_known_reservation_state,
|
||||
&dasd_attr_safe_offline,
|
||||
&internal_attr_early,
|
||||
),
|
||||
.unknown_dev_attribs = 1,
|
||||
|
||||
@@ -626,7 +630,7 @@ static struct ccw_subtype_data dasd_fba_data = {
|
||||
.mod = "dasd_fba_mod",
|
||||
};
|
||||
|
||||
static struct subtype dasd_subtype_fba = {
|
||||
struct subtype dasd_subtype_fba = {
|
||||
.super = &ccw_subtype,
|
||||
.devtype = &dasd_devtype,
|
||||
.name = "dasd-fba",
|
||||
@@ -649,6 +653,7 @@ static struct subtype dasd_subtype_fba = {
|
||||
&dasd_attr_reservation_policy,
|
||||
&dasd_attr_last_known_reservation_state,
|
||||
&dasd_attr_safe_offline,
|
||||
&internal_attr_early,
|
||||
),
|
||||
.unknown_dev_attribs = 1,
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "attrib.h"
|
||||
#include "device.h"
|
||||
#include "devtype.h"
|
||||
#include "internal.h"
|
||||
#include "misc.h"
|
||||
#include "namespace.h"
|
||||
#include "setting.h"
|
||||
@@ -40,6 +41,7 @@ struct device *device_new(struct subtype *st, const char *id)
|
||||
|
||||
dev->active.settings = setting_list_new();
|
||||
dev->persistent.settings = setting_list_new();
|
||||
dev->autoconf.settings = setting_list_new();
|
||||
|
||||
return dev;
|
||||
}
|
||||
@@ -53,6 +55,7 @@ void device_free(struct device *dev)
|
||||
free(dev->devid);
|
||||
setting_list_free(dev->active.settings);
|
||||
setting_list_free(dev->persistent.settings);
|
||||
setting_list_free(dev->autoconf.settings);
|
||||
free(dev);
|
||||
}
|
||||
|
||||
@@ -83,6 +86,15 @@ void device_print(struct device *dev, int level)
|
||||
setting_list_print(dev->persistent.settings, level + 8);
|
||||
else
|
||||
printf("%*s<none>\n", level + 8, "");
|
||||
|
||||
printf("%*sautoconf:\n", level + 4, "");
|
||||
printf("%*sexists=%d mod=%d deconf=%d\n",
|
||||
level + 8, "", dev->autoconf.exists, dev->autoconf.modified,
|
||||
dev->autoconf.deconfigured);
|
||||
if (dev->autoconf.settings)
|
||||
setting_list_print(dev->autoconf.settings, level + 8);
|
||||
else
|
||||
printf("%*s<none>\n", level + 8, "");
|
||||
}
|
||||
|
||||
static const void *device_hash_get_id(void *dev_ptr)
|
||||
@@ -182,6 +194,10 @@ bool device_needs_writing(struct device *dev, config_t config)
|
||||
(dev->persistent.modified || dev->persistent.deconfigured ||
|
||||
setting_list_modified(dev->persistent.settings)))
|
||||
return true;
|
||||
if (SCOPE_AUTOCONF(config) &&
|
||||
(dev->autoconf.modified || dev->autoconf.deconfigured ||
|
||||
setting_list_modified(dev->autoconf.settings)))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -204,6 +220,11 @@ static exit_code_t apply_setting(struct device *dev, config_t config,
|
||||
/* Check for activeonly. */
|
||||
if (!force && SCOPE_PERSISTENT(config) && a->activeonly)
|
||||
goto err_activeonly_forceable;
|
||||
if (!force && SCOPE_AUTOCONF(config) && a->activeonly)
|
||||
goto err_activeonly_forceable;
|
||||
/* Check for internal. */
|
||||
if (config == config_active && a->internal)
|
||||
goto err_int_noactive;
|
||||
/* Check for multiple values. */
|
||||
if (!force && !a->multi && strlist_find(processed, key))
|
||||
goto err_multi_forceable;
|
||||
@@ -213,6 +234,9 @@ static exit_code_t apply_setting(struct device *dev, config_t config,
|
||||
goto err_unknown;
|
||||
if (!force)
|
||||
goto err_unknown_forceable;
|
||||
/* Check for internal. */
|
||||
if (config == config_active && internal_by_name(key))
|
||||
goto err_int_noactive;
|
||||
}
|
||||
|
||||
strlist_add(processed, "%s", key);
|
||||
@@ -231,8 +255,15 @@ static exit_code_t apply_setting(struct device *dev, config_t config,
|
||||
a, key, value);
|
||||
}
|
||||
|
||||
/* Apply to autoconf config. */
|
||||
if (SCOPE_AUTOCONF(config)) {
|
||||
setting_list_apply_specified(dev->autoconf.settings,
|
||||
a, key, value);
|
||||
}
|
||||
|
||||
/* Additional warning when trying to persist read-only setting. */
|
||||
if (config == config_persistent) {
|
||||
if (!SCOPE_ACTIVE(config) && (SCOPE_PERSISTENT(config) ||
|
||||
SCOPE_AUTOCONF(config))) {
|
||||
s = setting_list_find(dev->active.settings, key);
|
||||
if (s && s->readonly)
|
||||
warn_readonly = true;
|
||||
@@ -270,6 +301,11 @@ err_activeonly_forceable:
|
||||
delayed_forceable("Attribute '%s' should only be changed in the active "
|
||||
"config\n", a->name);
|
||||
return EXIT_INVALID_SETTING;
|
||||
|
||||
err_int_noactive:
|
||||
delayed_err("Internal attribute '%s' cannot be set in the active config\n",
|
||||
key);
|
||||
return EXIT_INVALID_SETTING;
|
||||
}
|
||||
|
||||
/* Apply device settings from strlist to device. */
|
||||
@@ -341,6 +377,8 @@ void device_reset(struct device *dev, config_t config)
|
||||
reset_device_state(&dev->active);
|
||||
if (SCOPE_PERSISTENT(config))
|
||||
reset_device_state(&dev->persistent);
|
||||
if (SCOPE_AUTOCONF(config))
|
||||
reset_device_state(&dev->autoconf);
|
||||
dev->processed = 0;
|
||||
}
|
||||
|
||||
@@ -516,6 +554,9 @@ exit_code_t device_write_active_settings(struct device *dev)
|
||||
s = p->ptr;
|
||||
if (!s->modified || s->removed)
|
||||
continue;
|
||||
if ((s->attrib && s->attrib->internal) ||
|
||||
internal_by_name(s->name))
|
||||
continue;
|
||||
|
||||
path = subtype_get_active_attrib_path(st, dev, s->name);
|
||||
if (!path) {
|
||||
@@ -567,6 +608,44 @@ exit_code_t device_check_settings(struct device *dev, config_t config,
|
||||
err))
|
||||
return EXIT_INVALID_CONFIG;
|
||||
}
|
||||
if (SCOPE_AUTOCONF(config)) {
|
||||
if (!setting_list_check_conflict(dev->autoconf.settings,
|
||||
config_autoconf,
|
||||
err))
|
||||
return EXIT_INVALID_CONFIG;
|
||||
}
|
||||
|
||||
return EXIT_OK;
|
||||
}
|
||||
|
||||
struct setting_list *device_get_setting_list(struct device *dev,
|
||||
config_t config)
|
||||
{
|
||||
struct setting_list *settings = NULL;
|
||||
|
||||
if (config == config_active)
|
||||
settings = dev->active.settings;
|
||||
else if (config == config_persistent)
|
||||
settings = dev->persistent.settings;
|
||||
else if (config == config_autoconf)
|
||||
settings = dev->autoconf.settings;
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
/* Return configuration set in which device exists. */
|
||||
config_t device_get_config(struct device *dev)
|
||||
{
|
||||
config_t config = 0;
|
||||
|
||||
if (dev->active.exists || dev->active.definable)
|
||||
config |= config_active;
|
||||
|
||||
if (dev->persistent.exists)
|
||||
config |= config_persistent;
|
||||
|
||||
if (dev->autoconf.exists)
|
||||
config |= config_autoconf;
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ static bool is_exportable(struct setting *s, config_t config)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (SCOPE_PERSISTENT(config)) {
|
||||
if (SCOPE_PERSISTENT(config) || SCOPE_AUTOCONF(config)) {
|
||||
if (setting_is_set(s))
|
||||
return true;
|
||||
}
|
||||
@@ -148,10 +148,9 @@ static int count_exportable(struct device *dev, config_t config)
|
||||
struct setting *s;
|
||||
int count;
|
||||
|
||||
if (config == config_active)
|
||||
list = dev->active.settings;
|
||||
else
|
||||
list = dev->persistent.settings;
|
||||
list = device_get_setting_list(dev, config);
|
||||
if (!list)
|
||||
return 0;
|
||||
count = 0;
|
||||
|
||||
util_list_iterate(&list->list, s) {
|
||||
@@ -169,12 +168,26 @@ exit_code_t export_write_device(FILE *fd, struct device *dev, config_t config,
|
||||
exit_code_t rc;
|
||||
struct setting_list *settings;
|
||||
|
||||
if (config == config_all) {
|
||||
rc = export_write_device(fd, dev, config_active, first_ptr);
|
||||
if (rc)
|
||||
return rc;
|
||||
return export_write_device(fd, dev, config_persistent,
|
||||
first_ptr);
|
||||
if (!SCOPE_SINGLE(config)) {
|
||||
if (SCOPE_ACTIVE(config)) {
|
||||
rc = export_write_device(fd, dev, config_active,
|
||||
first_ptr);
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
if (SCOPE_PERSISTENT(config)) {
|
||||
rc = export_write_device(fd, dev, config_persistent,
|
||||
first_ptr);
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
if (SCOPE_AUTOCONF(config)) {
|
||||
rc = export_write_device(fd, dev, config_autoconf,
|
||||
first_ptr);
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
return EXIT_OK;
|
||||
}
|
||||
|
||||
if (config == config_active) {
|
||||
@@ -185,10 +198,14 @@ exit_code_t export_write_device(FILE *fd, struct device *dev, config_t config,
|
||||
!dev->subtype->support_definable)
|
||||
return EXIT_OK;
|
||||
settings = dev->active.settings;
|
||||
} else {
|
||||
} else if (config == config_persistent) {
|
||||
if (!dev->persistent.exists)
|
||||
return EXIT_OK;
|
||||
settings = dev->persistent.settings;
|
||||
} else {
|
||||
if (!dev->autoconf.exists)
|
||||
return EXIT_OK;
|
||||
settings = dev->autoconf.settings;
|
||||
}
|
||||
|
||||
write_header(fd, config, dev->subtype->name, dev->id, first_ptr);
|
||||
@@ -204,12 +221,21 @@ exit_code_t export_write_devtype(FILE *fd, struct devtype *dt, config_t config,
|
||||
exit_code_t rc;
|
||||
struct setting_list *settings;
|
||||
|
||||
if (config == config_all) {
|
||||
rc = export_write_devtype(fd, dt, config_active, first_ptr);
|
||||
if (rc)
|
||||
return rc;
|
||||
return export_write_devtype(fd, dt, config_persistent,
|
||||
first_ptr);
|
||||
if (!SCOPE_SINGLE(config)) {
|
||||
if (SCOPE_ACTIVE(config)) {
|
||||
rc = export_write_devtype(fd, dt, config_active,
|
||||
first_ptr);
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
if (SCOPE_PERSISTENT(config)) {
|
||||
rc = export_write_devtype(fd, dt, config_persistent,
|
||||
first_ptr);
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
/* Scope autoconf not supported for devtype */
|
||||
return EXIT_OK;
|
||||
}
|
||||
|
||||
if (config == config_active)
|
||||
@@ -282,19 +308,6 @@ static bool parse_setting(const char *line, char **key_ptr, char **val_ptr)
|
||||
return true;
|
||||
}
|
||||
|
||||
static struct setting_list *dev_get_setting_list(struct device *dev,
|
||||
config_t config)
|
||||
{
|
||||
struct setting_list *settings = NULL;
|
||||
|
||||
if (config == config_active)
|
||||
settings = dev->active.settings;
|
||||
else
|
||||
settings = dev->persistent.settings;
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
static struct setting_list *dt_get_setting_list(struct devtype *dt,
|
||||
config_t config)
|
||||
{
|
||||
@@ -392,6 +405,10 @@ static exit_code_t handle_header(const char *filename, int lineno,
|
||||
setting_list_clear(dev->persistent.settings);
|
||||
dev->persistent.exists = 1;
|
||||
}
|
||||
if (SCOPE_AUTOCONF(hdr->config)) {
|
||||
setting_list_clear(dev->autoconf.settings);
|
||||
dev->autoconf.exists = 1;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
@@ -410,13 +427,26 @@ static exit_code_t handle_setting(const char *filename, int lineno,
|
||||
struct attrib **attribs, *a;
|
||||
struct setting_list *list;
|
||||
|
||||
if (config == config_all) {
|
||||
rc = handle_setting(filename, lineno, key, value, dt, dev,
|
||||
config_active);
|
||||
if (rc)
|
||||
return rc;
|
||||
return handle_setting(filename, lineno, key, value, dt, dev,
|
||||
config_persistent);
|
||||
if (!SCOPE_SINGLE(config)) {
|
||||
if (SCOPE_ACTIVE(config)) {
|
||||
rc = handle_setting(filename, lineno, key, value, dt,
|
||||
dev, config_active);
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
if (SCOPE_PERSISTENT(config)) {
|
||||
rc = handle_setting(filename, lineno, key, value, dt,
|
||||
dev, config_persistent);
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
if (SCOPE_AUTOCONF(config)) {
|
||||
rc = handle_setting(filename, lineno, key, value, dt,
|
||||
dev, config_autoconf);
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
return EXIT_OK;
|
||||
}
|
||||
|
||||
if (dt) {
|
||||
@@ -426,7 +456,7 @@ static exit_code_t handle_setting(const char *filename, int lineno,
|
||||
} else if (dev) {
|
||||
/* We're inside a device section. */
|
||||
attribs = dev->subtype->dev_attribs;
|
||||
list = dev_get_setting_list(dev, config);
|
||||
list = device_get_setting_list(dev, config);
|
||||
} else
|
||||
return EXIT_OK;
|
||||
|
||||
@@ -444,7 +474,7 @@ static exit_code_t handle_setting(const char *filename, int lineno,
|
||||
return EXIT_OK;
|
||||
}
|
||||
|
||||
static struct export_object *object_new(export_t type, void *ptr)
|
||||
struct export_object *object_new(export_t type, void *ptr)
|
||||
{
|
||||
struct export_object *obj;
|
||||
|
||||
@@ -465,7 +495,8 @@ static bool empty_device(struct device *dev)
|
||||
if (dev->subtype->support_definable)
|
||||
return false;
|
||||
if (util_list_is_empty(&dev->active.settings->list) &&
|
||||
util_list_is_empty(&dev->persistent.settings->list))
|
||||
util_list_is_empty(&dev->persistent.settings->list) &&
|
||||
util_list_is_empty(&dev->autoconf.settings->list))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
682
zdev/src/firmware.c
Normal file
682
zdev/src/firmware.c
Normal file
@@ -0,0 +1,682 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2017
|
||||
*
|
||||
* 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 <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "attrib.h"
|
||||
#include "ccw.h"
|
||||
#include "ccwgroup.h"
|
||||
#include "dasd.h"
|
||||
#include "device.h"
|
||||
#include "export.h"
|
||||
#include "firmware.h"
|
||||
#include "misc.h"
|
||||
#include "qeth.h"
|
||||
#include "subtype.h"
|
||||
#include "zfcp_host.h"
|
||||
#include "zfcp_lun.h"
|
||||
|
||||
/* In-memory firmware file representation. */
|
||||
struct fw_file {
|
||||
const char *name;
|
||||
char *buffer;
|
||||
size_t size;
|
||||
char *last_access;
|
||||
size_t last_size;
|
||||
};
|
||||
|
||||
/* Record access to fields of the buffered file for use in warning messages. */
|
||||
#define fwacc(f, x) ((f)->last_access = (char *) &(x), \
|
||||
(f)->last_size = sizeof(x), x)
|
||||
|
||||
/*
|
||||
* Firmware file format definitions.
|
||||
*/
|
||||
|
||||
/* Firmware file header. */
|
||||
struct fw_filehdr {
|
||||
uint32_t magic;
|
||||
uint16_t ver;
|
||||
uint16_t hdr_len;
|
||||
uint32_t file_len;
|
||||
uint32_t seq;
|
||||
uint32_t zeroes;
|
||||
uint16_t de_count;
|
||||
char unused[10];
|
||||
} __packed;
|
||||
|
||||
#define FW_HDR_MAGIC 0x7a646576 /* ASCII "zdev" */
|
||||
#define FW_HDR_VER_Z14 0x0000
|
||||
|
||||
/* I/O device ID. */
|
||||
struct fw_iodevid {
|
||||
uint8_t cssid;
|
||||
uint8_t ssid;
|
||||
uint16_t devno;
|
||||
} __packed;
|
||||
|
||||
#define FW_IODEVID_FLAG_MCSS 0x01
|
||||
|
||||
/* Device setting. */
|
||||
struct fw_setting {
|
||||
uint16_t len;
|
||||
uint8_t key_type;
|
||||
uint8_t key_len;
|
||||
uint8_t val_type;
|
||||
uint8_t val_len;
|
||||
char data[];
|
||||
} __packed;
|
||||
|
||||
#define FW_SETTING_KEYTYPE_ASCII 0x00
|
||||
#define FW_SETTING_VALTYPE_ASCII 0x00
|
||||
#define FW_SETTING_VALTYPE_UINT 0x01
|
||||
|
||||
/* Device settings list. */
|
||||
struct fw_setlist {
|
||||
uint16_t len;
|
||||
char data[];
|
||||
} __packed;
|
||||
|
||||
/* Device entry header. */
|
||||
struct fw_dehdr {
|
||||
uint16_t type;
|
||||
uint16_t len;
|
||||
uint32_t seq;
|
||||
} __packed;
|
||||
|
||||
#define FW_DE_HDR_TYPE_DASD 0x0001
|
||||
#define FW_DE_HDR_TYPE_ZFCP_HOST 0x0002
|
||||
#define FW_DE_HDR_TYPE_ZFCP_LUN 0x0003
|
||||
#define FW_DE_HDR_TYPE_QETH 0x0004
|
||||
|
||||
/* DASD device entry. */
|
||||
struct fw_dasd {
|
||||
struct fw_dehdr hdr;
|
||||
uint8_t id_flags;
|
||||
struct fw_iodevid id;
|
||||
char settings[];
|
||||
} __packed;
|
||||
|
||||
/* zFCP host device entry. */
|
||||
struct fw_zfcp_host {
|
||||
struct fw_dehdr hdr;
|
||||
uint8_t id_flags;
|
||||
struct fw_iodevid id;
|
||||
char settings[];
|
||||
} __packed;
|
||||
|
||||
/* zFCP LUN device entry. */
|
||||
struct fw_zfcp_lun {
|
||||
struct fw_dehdr hdr;
|
||||
uint8_t id_flags;
|
||||
struct fw_iodevid id;
|
||||
uint64_t wwpn;
|
||||
uint64_t fcp_lun;
|
||||
char settings[];
|
||||
} __packed;
|
||||
|
||||
/* QETH device entry. */
|
||||
struct fw_qeth {
|
||||
struct fw_dehdr hdr;
|
||||
uint8_t id_flags;
|
||||
struct fw_iodevid read_id;
|
||||
struct fw_iodevid write_id;
|
||||
struct fw_iodevid data_id;
|
||||
char settings[];
|
||||
} __packed;
|
||||
|
||||
/* Emit a warning that refers to a position in a firmware file. */
|
||||
static void fwwarn(struct fw_file *f, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
off_t start = (off_t) (f->last_access - f->buffer),
|
||||
end = start + f->last_size - 1;
|
||||
|
||||
fprintf(stderr, "%s: ", f->name);
|
||||
if (start == end)
|
||||
fprintf(stderr, "Byte 0x%zx: ", start);
|
||||
else
|
||||
fprintf(stderr, "Bytes 0x%zx-0x%zx: ", start, end);
|
||||
|
||||
va_start(args, fmt);
|
||||
vfprintf(stderr, fmt, args);
|
||||
va_end(args);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
/* Basic file format header sanity check. */
|
||||
static bool check_header(struct fw_file *f, struct fw_filehdr *hdr)
|
||||
{
|
||||
if (fwacc(f, hdr->magic) != FW_HDR_MAGIC)
|
||||
fwwarn(f, "Invalid file magic (0x%08x)", hdr->magic);
|
||||
else if (fwacc(f, hdr->ver) != FW_HDR_VER_Z14)
|
||||
fwwarn(f, "Unsupported file version (0x%04x)", hdr->ver);
|
||||
else
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#define READ_RETRY 3
|
||||
|
||||
/* Read a firmware configuration file. */
|
||||
static exit_code_t read_fw(struct fw_file *file, FILE *fd, const char *filename)
|
||||
{
|
||||
struct fw_file f = { NULL };
|
||||
struct fw_filehdr *hdr;
|
||||
char *buffer, *buffer2;
|
||||
size_t size, size2;
|
||||
int retry;
|
||||
exit_code_t rc = EXIT_OK;
|
||||
|
||||
for (retry = 0; retry < READ_RETRY; retry++) {
|
||||
/* Read complete file once */
|
||||
rc = misc_read_fd(fd, (void **) &buffer, &size);
|
||||
if (rc) {
|
||||
warn("%s: Could not read file", filename);
|
||||
return rc;
|
||||
}
|
||||
if (!buffer) {
|
||||
/* Empty file - skip silently as this is the default
|
||||
* on machines without firmware support. */
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Re-read complete file to detect in-flight modifications. */
|
||||
if (fseek(fd, 0, SEEK_SET) == -1) {
|
||||
/* Could be a pipe, socket, or FIFO - accept v1. */
|
||||
break;
|
||||
}
|
||||
rc = misc_read_fd(fd, (void **) &buffer2, &size2);
|
||||
if (rc || !buffer2) {
|
||||
/* Could not get second version - accept v1. */
|
||||
break;
|
||||
}
|
||||
|
||||
if (size == size2 && memcmp(buffer, buffer2, size) == 0) {
|
||||
/* No change */
|
||||
free(buffer2);
|
||||
break;
|
||||
}
|
||||
|
||||
free(buffer);
|
||||
free(buffer2);
|
||||
}
|
||||
|
||||
if (retry >= READ_RETRY) {
|
||||
warnx("%s: File changed %d times while reading - aborting",
|
||||
filename, retry);
|
||||
return EXIT_RUNTIME_ERROR;
|
||||
}
|
||||
|
||||
/* Perform basic checks */
|
||||
f.name = filename;
|
||||
f.buffer = buffer;
|
||||
f.size = size;
|
||||
hdr = (void *) buffer;
|
||||
if (!check_header(&f, hdr)) {
|
||||
free(buffer);
|
||||
return EXIT_FORMAT_ERROR;
|
||||
}
|
||||
if (fwacc(&f, hdr->file_len) > size) {
|
||||
fwwarn(&f, "File length mismatch (expect %zu) - adjusting",
|
||||
size);
|
||||
hdr->file_len = size;
|
||||
}
|
||||
|
||||
*file = f;
|
||||
|
||||
return EXIT_OK;
|
||||
}
|
||||
|
||||
/* Return textual representation of a device entry type. */
|
||||
static const char *type_to_str(uint16_t type)
|
||||
{
|
||||
switch (type) {
|
||||
case FW_DE_HDR_TYPE_DASD:
|
||||
return "dasd";
|
||||
case FW_DE_HDR_TYPE_ZFCP_HOST:
|
||||
return "zfcp-host";
|
||||
case FW_DE_HDR_TYPE_ZFCP_LUN:
|
||||
return "zfcp-lun";
|
||||
case FW_DE_HDR_TYPE_QETH:
|
||||
return "qeth";
|
||||
default:
|
||||
return "<unknown>";
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert a binary format device setting of the specified length to integer. */
|
||||
static unsigned long parse_value(char *data, uint8_t len)
|
||||
{
|
||||
switch (len) {
|
||||
case 1:
|
||||
return (unsigned long) *((uint8_t *) data);
|
||||
case 2:
|
||||
return (unsigned long) *((uint16_t *) data);
|
||||
case 4:
|
||||
return (unsigned long) *((uint32_t *) data);
|
||||
case 8:
|
||||
return (unsigned long) *((uint64_t *) data);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Perform sanity checks on device setting. */
|
||||
static bool check_setting(struct fw_file *f, struct fw_setting *set)
|
||||
{
|
||||
/* Key sanity checks */
|
||||
if (fwacc(f, set->key_type) != FW_SETTING_KEYTYPE_ASCII) {
|
||||
fwwarn(f, "Unsupported key type: %d", set->key_type);
|
||||
return false;
|
||||
}
|
||||
if (fwacc(f, set->key_len) < 1) {
|
||||
fwwarn(f, "Unsupported key length: %d", set->key_len);
|
||||
return false;
|
||||
}
|
||||
if (sizeof(struct fw_setting) + fwacc(f, set->key_len) > set->len) {
|
||||
fwwarn(f, "Key length exceeds setting");
|
||||
return false;
|
||||
}
|
||||
if (fwacc(f, set->data[set->key_len - 1])) {
|
||||
fwwarn(f, "Key not null-terminated");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Value sanity checks */
|
||||
if (fwacc(f, set->val_type) != FW_SETTING_VALTYPE_UINT &&
|
||||
fwacc(f, set->val_type) != FW_SETTING_VALTYPE_ASCII) {
|
||||
fwwarn(f, "Unsupported value type: %d", set->val_type);
|
||||
return false;
|
||||
}
|
||||
if (fwacc(f, set->val_len) < 1) {
|
||||
fwwarn(f, "Unsupported value length: %d", set->val_len);
|
||||
return false;
|
||||
}
|
||||
if (sizeof(struct fw_setting) + set->key_len +
|
||||
fwacc(f, set->val_len) > set->len) {
|
||||
fwwarn(f, "Value length exceeds setting");
|
||||
return false;
|
||||
}
|
||||
if ((set->val_type == FW_SETTING_VALTYPE_ASCII) &&
|
||||
fwacc(f, set->data[set->key_len + set->val_len - 1])) {
|
||||
fwwarn(f, "Value not null-terminated");
|
||||
return false;
|
||||
}
|
||||
if (set->val_type == FW_SETTING_VALTYPE_UINT) {
|
||||
switch (fwacc(f, set->val_len)) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
case 8:
|
||||
break;
|
||||
default:
|
||||
fwwarn(f, "Unsupported integer value length: %d",
|
||||
set->val_len);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Add a setting to the device. Emit a warning if the setting is not known. */
|
||||
static void _add_setting(const char *filename, struct device *dev,
|
||||
config_t config, const char *key, const char *value)
|
||||
{
|
||||
struct attrib *a;
|
||||
struct setting_list *list;
|
||||
|
||||
list = device_get_setting_list(dev, config);
|
||||
a = attrib_find(dev->subtype->dev_attribs, key);
|
||||
if (!a) {
|
||||
warnx("%s: Applying unknown device setting %s=%s", filename,
|
||||
key, value);
|
||||
}
|
||||
setting_list_apply(list, a, key, value);
|
||||
}
|
||||
|
||||
static void add_setting(const char *filename, struct device *dev,
|
||||
config_t config, const char *key, const char *value)
|
||||
{
|
||||
if (SCOPE_ACTIVE(config))
|
||||
_add_setting(filename, dev, config_active, key, value);
|
||||
if (SCOPE_PERSISTENT(config))
|
||||
_add_setting(filename, dev, config_persistent, key, value);
|
||||
if (SCOPE_AUTOCONF(config))
|
||||
_add_setting(filename, dev, config_autoconf, key, value);
|
||||
}
|
||||
|
||||
/* Parse a single device setting in firmware format and apply it to the
|
||||
* specified device. */
|
||||
static void parse_setting(struct fw_file *f, struct fw_setting *set,
|
||||
struct device *dev, config_t config)
|
||||
{
|
||||
char *ascii_key, *ascii_val;
|
||||
unsigned long ulong_val;
|
||||
|
||||
if (!check_setting(f, set))
|
||||
return;
|
||||
|
||||
ascii_key = &set->data[0];
|
||||
if (set->val_type == FW_SETTING_VALTYPE_UINT) {
|
||||
ulong_val = parse_value(&set->data[set->key_len], set->val_len);
|
||||
ascii_val = misc_asprintf("%lu", ulong_val);
|
||||
add_setting(f->name, dev, config, ascii_key, ascii_val);
|
||||
free(ascii_val);
|
||||
} else {
|
||||
ascii_val = &set->data[set->key_len];
|
||||
add_setting(f->name, dev, config, ascii_key, ascii_val);
|
||||
}
|
||||
}
|
||||
|
||||
/* Parse a device settings list in firmware format and apply the resulting
|
||||
* settings to the specified device. */
|
||||
static void parse_settings(struct fw_file *f, char *data, struct device *dev,
|
||||
config_t config)
|
||||
{
|
||||
struct fw_setlist *list = (struct fw_setlist *) data;
|
||||
struct fw_setting *set;
|
||||
uint16_t off;
|
||||
|
||||
for (off = sizeof(struct fw_setlist); off < list->len;
|
||||
off += set->len) {
|
||||
set = (struct fw_setting *) &data[off];
|
||||
if (fwacc(f, set->len) < sizeof(struct fw_setting)) {
|
||||
fwwarn(f, "Setting too short");
|
||||
break;
|
||||
}
|
||||
if (off + fwacc(f, set->len) > list->len) {
|
||||
fwwarn(f, "Setting too long");
|
||||
break;
|
||||
}
|
||||
parse_setting(f, set, dev, config);
|
||||
}
|
||||
}
|
||||
|
||||
/* Perform sanity checks on an I/O device ID. */
|
||||
static bool check_iodevid(struct fw_file *f, uint8_t *flags,
|
||||
struct fw_iodevid *id)
|
||||
{
|
||||
|
||||
if (fwacc(f, *flags) & FW_IODEVID_FLAG_MCSS) {
|
||||
fwwarn(f, "Unsupported entry in non-default CSS");
|
||||
return false;
|
||||
}
|
||||
if (fwacc(f, id->cssid) != 0) {
|
||||
fwwarn(f, "Non-zero CSS-ID");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Perform sanity checks on a device entry. */
|
||||
static bool check_de_size(struct fw_file *f, struct fw_dehdr *de, size_t size)
|
||||
{
|
||||
if (fwacc(f, de->len) < size) {
|
||||
fwwarn(f, "Device entry too short (expect %zu)", size);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Convert an I/O device ID to CCW device ID format. */
|
||||
static void io_to_ccw(struct ccw_devid *c, struct fw_iodevid *i)
|
||||
{
|
||||
c->cssid = i->cssid;
|
||||
c->ssid = i->ssid;
|
||||
c->devno = i->devno;
|
||||
}
|
||||
|
||||
/* Register a new device configuration. */
|
||||
static struct device *add_device(struct fw_file *f, struct subtype *st,
|
||||
const char *id, config_t config,
|
||||
struct util_list *objects)
|
||||
{
|
||||
struct device *dev;
|
||||
|
||||
if (!st->devices)
|
||||
st->devices = device_list_new(st);
|
||||
|
||||
dev = device_list_find(st->devices, id, NULL);
|
||||
if (!dev) {
|
||||
dev = device_new(st, id);
|
||||
if (!dev) {
|
||||
warnx("%s: Skipping invalid %s device ID %s", f->name,
|
||||
st->name, id);
|
||||
return NULL;
|
||||
}
|
||||
device_list_add(st->devices, dev);
|
||||
}
|
||||
ptrlist_add(objects, object_new(export_device, dev));
|
||||
|
||||
/* Prepare device for new settings. */
|
||||
if (SCOPE_ACTIVE(config)) {
|
||||
setting_list_clear(dev->active.settings);
|
||||
if (dev->subtype->support_definable)
|
||||
dev->active.definable = 1;
|
||||
else
|
||||
dev->active.exists = 1;
|
||||
}
|
||||
if (SCOPE_PERSISTENT(config)) {
|
||||
setting_list_clear(dev->persistent.settings);
|
||||
dev->persistent.exists = 1;
|
||||
}
|
||||
if (SCOPE_AUTOCONF(config)) {
|
||||
setting_list_clear(dev->autoconf.settings);
|
||||
dev->autoconf.exists = 1;
|
||||
}
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
/* Parse a DASD device entry. */
|
||||
static void parse_dasd(struct fw_file *f, struct fw_dehdr *de, config_t config,
|
||||
struct util_list *objects)
|
||||
{
|
||||
struct fw_dasd *dasd = (struct fw_dasd *) de;
|
||||
struct ccw_devid devid;
|
||||
struct device *dev_eckd, *dev_fba;
|
||||
char *id;
|
||||
|
||||
if (!check_de_size(f, de, sizeof(struct fw_dasd)))
|
||||
return;
|
||||
if (!check_iodevid(f, &dasd->id_flags, &dasd->id))
|
||||
return;
|
||||
|
||||
/* Could be either dasd_eckd or dasd_fba - add both entries */
|
||||
io_to_ccw(&devid, &dasd->id);
|
||||
id = ccw_devid_to_str(&devid);
|
||||
dev_eckd = add_device(f, &dasd_subtype_eckd, id, config, objects);
|
||||
dev_fba = add_device(f, &dasd_subtype_fba, id, config, objects);
|
||||
free(id);
|
||||
|
||||
if (dasd->hdr.len > sizeof(struct fw_dasd)) {
|
||||
if (dev_eckd)
|
||||
parse_settings(f, dasd->settings, dev_eckd, config);
|
||||
if (dev_fba)
|
||||
parse_settings(f, dasd->settings, dev_fba, config);
|
||||
}
|
||||
}
|
||||
|
||||
/* Parse a zFCP host device entry. */
|
||||
static void parse_zfcp_host(struct fw_file *f, struct fw_dehdr *de,
|
||||
config_t config, struct util_list *objects)
|
||||
{
|
||||
struct fw_zfcp_host *zfcp_host = (struct fw_zfcp_host *) de;
|
||||
struct ccw_devid devid;
|
||||
struct device *dev;
|
||||
char *id;
|
||||
|
||||
if (!check_de_size(f, de, sizeof(struct fw_zfcp_host)))
|
||||
return;
|
||||
if (!check_iodevid(f, &zfcp_host->id_flags, &zfcp_host->id))
|
||||
return;
|
||||
|
||||
/* Add zfcp_host entry */
|
||||
io_to_ccw(&devid, &zfcp_host->id);
|
||||
id = ccw_devid_to_str(&devid);
|
||||
dev = add_device(f, &zfcp_host_subtype, id, config, objects);
|
||||
free(id);
|
||||
|
||||
if (dev && zfcp_host->hdr.len > sizeof(struct fw_zfcp_host))
|
||||
parse_settings(f, zfcp_host->settings, dev, config);
|
||||
}
|
||||
|
||||
/* Parse a zFCP LUN device entry. */
|
||||
static void parse_zfcp_lun(struct fw_file *f, struct fw_dehdr *de,
|
||||
config_t config, struct util_list *objects)
|
||||
{
|
||||
struct fw_zfcp_lun *zfcp_lun = (struct fw_zfcp_lun *) de;
|
||||
struct zfcp_lun_devid devid;
|
||||
struct device *dev;
|
||||
char *id;
|
||||
|
||||
if (!check_de_size(f, de, sizeof(struct fw_zfcp_lun)))
|
||||
return;
|
||||
if (!check_iodevid(f, &zfcp_lun->id_flags, &zfcp_lun->id))
|
||||
return;
|
||||
|
||||
/* Add zfcp_lun entry */
|
||||
io_to_ccw(&devid.fcp_dev, &zfcp_lun->id);
|
||||
devid.wwpn = zfcp_lun->wwpn;
|
||||
devid.lun = zfcp_lun->fcp_lun;
|
||||
id = zfcp_lun_devid_to_str(&devid);
|
||||
dev = add_device(f, &zfcp_lun_subtype, id, config, objects);
|
||||
free(id);
|
||||
|
||||
if (dev && zfcp_lun->hdr.len > sizeof(struct fw_zfcp_lun))
|
||||
parse_settings(f, zfcp_lun->settings, dev, config);
|
||||
|
||||
}
|
||||
|
||||
/* Parse a QETH device entry. */
|
||||
static void parse_qeth(struct fw_file *f, struct fw_dehdr *de, config_t config,
|
||||
struct util_list *objects)
|
||||
{
|
||||
struct fw_qeth *qeth = (struct fw_qeth *) de;
|
||||
struct ccwgroup_devid devid;
|
||||
struct device *dev;
|
||||
char *id;
|
||||
|
||||
if (!check_de_size(f, de, sizeof(struct fw_qeth)))
|
||||
return;
|
||||
if (!check_iodevid(f, &qeth->id_flags, &qeth->read_id) ||
|
||||
!check_iodevid(f, &qeth->id_flags, &qeth->write_id) ||
|
||||
!check_iodevid(f, &qeth->id_flags, &qeth->data_id))
|
||||
return;
|
||||
|
||||
/* Add qeth entry */
|
||||
devid.num = 3;
|
||||
io_to_ccw(&devid.devid[0], &qeth->read_id);
|
||||
io_to_ccw(&devid.devid[1], &qeth->write_id);
|
||||
io_to_ccw(&devid.devid[2], &qeth->data_id);
|
||||
id = ccwgroup_devid_to_str(&devid);
|
||||
dev = add_device(f, &qeth_subtype_qeth, id, config, objects);
|
||||
free(id);
|
||||
|
||||
if (dev && qeth->hdr.len > sizeof(struct fw_qeth))
|
||||
parse_settings(f, qeth->settings, dev, config);
|
||||
}
|
||||
|
||||
/* Parse a firmware file. */
|
||||
static void parse_fw(struct fw_file *f, long skip, config_t config,
|
||||
struct util_list *objects)
|
||||
{
|
||||
char *data = f->buffer;
|
||||
struct fw_filehdr *hdr = (struct fw_filehdr *) data;
|
||||
struct fw_dehdr *de;
|
||||
uint16_t count = 0;
|
||||
uint32_t off;
|
||||
|
||||
for (off = hdr->hdr_len; off < hdr->file_len; off += de->len) {
|
||||
count++;
|
||||
de = (struct fw_dehdr *) &data[off];
|
||||
if (fwacc(f, de->len) == 0) {
|
||||
fwwarn(f, "Empty device entry");
|
||||
break;
|
||||
}
|
||||
if (off + fwacc(f, de->len) > hdr->file_len) {
|
||||
fwwarn(f, "Device entry too long");
|
||||
break;
|
||||
}
|
||||
if (skip >= 0 && de->seq <= skip) {
|
||||
debug("Skipping %s entry due to sequence (%08x)\n",
|
||||
type_to_str(de->type), de->seq);
|
||||
continue;
|
||||
}
|
||||
switch (fwacc(f, de->type)) {
|
||||
case FW_DE_HDR_TYPE_DASD:
|
||||
parse_dasd(f, de, config, objects);
|
||||
break;
|
||||
case FW_DE_HDR_TYPE_ZFCP_HOST:
|
||||
parse_zfcp_host(f, de, config, objects);
|
||||
break;
|
||||
case FW_DE_HDR_TYPE_ZFCP_LUN:
|
||||
parse_zfcp_lun(f, de, config, objects);
|
||||
break;
|
||||
case FW_DE_HDR_TYPE_QETH:
|
||||
parse_qeth(f, de, config, objects);
|
||||
break;
|
||||
default:
|
||||
fwwarn(f, "Unknown entry (type=%04x)", de->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (count != fwacc(f, hdr->de_count))
|
||||
fwwarn(f, "Device entry count mismatch");
|
||||
}
|
||||
|
||||
/* Read configuration objects from @fd in firmware file format. Add pointers to
|
||||
* newly allocated struct export_objects to ptrlist @objects. If @skip is a
|
||||
* positive number, skip over entries with a sequence number equal to or
|
||||
* greater than @skip. */
|
||||
exit_code_t firmware_read(FILE *fd, const char *filename, long skip,
|
||||
config_t config, struct util_list *objects)
|
||||
{
|
||||
struct fw_file file;
|
||||
exit_code_t rc;
|
||||
|
||||
rc = read_fw(&file, fd, filename);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
parse_fw(&file, skip, config, objects);
|
||||
free(file.buffer);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Check if @fd refers to a file in binary firmware format. */
|
||||
bool firmware_detect(FILE *fd)
|
||||
{
|
||||
int c;
|
||||
|
||||
c = fgetc(fd);
|
||||
ungetc(c, fd);
|
||||
|
||||
/* Note: A full check would require looking at least at the first 4
|
||||
* bytes, but fd might be non-seekable (e.g. pipe). Since there is no
|
||||
* way that a textual import file can start with a 'z', looking at
|
||||
* the first char should be enough. */
|
||||
|
||||
return c == 'z';
|
||||
}
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "devnode.h"
|
||||
#include "devtype.h"
|
||||
#include "generic_ccw.h"
|
||||
#include "internal.h"
|
||||
#include "namespace.h"
|
||||
#include "path.h"
|
||||
#include "subtype.h"
|
||||
@@ -182,6 +183,7 @@ static struct subtype generic_ccw_subtype = {
|
||||
.dev_attribs = ATTRIB_ARRAY(
|
||||
&ccw_attr_online,
|
||||
&ccw_attr_cmb_enable,
|
||||
&internal_attr_early,
|
||||
),
|
||||
.unknown_dev_attribs = 1,
|
||||
.generic = 1,
|
||||
|
||||
38
zdev/src/internal.c
Normal file
38
zdev/src/internal.c
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* zdev - Modify and display the persistent configuration of devices
|
||||
*
|
||||
* Copyright IBM Corp. 2017
|
||||
*
|
||||
* 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 <stdbool.h>
|
||||
|
||||
#include "attrib.h"
|
||||
#include "internal.h"
|
||||
#include "misc.h"
|
||||
|
||||
struct attrib internal_attr_early = {
|
||||
.name = INTERNAL_ATTR_EARLY,
|
||||
.title = "Activate device early during boot",
|
||||
.desc = "Control the time of activation of a device:\n"
|
||||
" 0: Device is activated normally during boot\n"
|
||||
" 1: Device is activated early in the boot process, by the\n"
|
||||
" initial RAM-disk\n",
|
||||
.defval = "0",
|
||||
.accept = ACCEPT_ARRAY(ACCEPT_RANGE(0, 1)),
|
||||
.internal = 1,
|
||||
};
|
||||
|
||||
/* Return identifier of internal attribute with specified @name. */
|
||||
const char *internal_get_name(const char *name)
|
||||
{
|
||||
return name + sizeof(INTERNAL_ATTR_PREFIX) - 1;
|
||||
}
|
||||
|
||||
/* Check if attribute is internal by name. */
|
||||
bool internal_by_name(const char *name)
|
||||
{
|
||||
return starts_with(name, INTERNAL_ATTR_PREFIX);
|
||||
}
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "ccwgroup.h"
|
||||
#include "device.h"
|
||||
#include "devtype.h"
|
||||
#include "internal.h"
|
||||
#include "lcs.h"
|
||||
#include "lcs_auto.h"
|
||||
#include "misc.h"
|
||||
@@ -362,6 +363,7 @@ static struct subtype lcs_subtype = {
|
||||
&ccw_attr_online,
|
||||
&lcs_attr_lancmd_timeout,
|
||||
&lcs_attr_recover,
|
||||
&internal_attr_early,
|
||||
),
|
||||
.unknown_dev_attribs = 1,
|
||||
.support_definable = 1,
|
||||
|
||||
@@ -59,6 +59,7 @@ struct options {
|
||||
config_t config;
|
||||
unsigned int active:1;
|
||||
unsigned int persistent:1;
|
||||
unsigned int auto_conf:1;
|
||||
struct util_list *columns; /* List of struct strlist_node */
|
||||
unsigned int no_headings:1;
|
||||
struct util_list *base; /* List of struct strlist_node */
|
||||
@@ -98,6 +99,7 @@ enum {
|
||||
OPT_VERBOSE = 'V',
|
||||
OPT_QUIET = 'q',
|
||||
OPT_PAIRS = 'P',
|
||||
OPT_AUTO_CONF = (OPT_ANONYMOUS_BASE+__COUNTER__),
|
||||
};
|
||||
|
||||
static struct opts_conflict conflict_list[] = {
|
||||
@@ -150,6 +152,7 @@ static const struct option opt_list[] = {
|
||||
/* Options. */
|
||||
{ "active", no_argument, NULL, OPT_ACTIVE },
|
||||
{ "persistent", no_argument, NULL, OPT_PERSISTENT },
|
||||
{ "auto-conf", no_argument, NULL, OPT_AUTO_CONF },
|
||||
{ "columns", required_argument, NULL, OPT_COLUMNS },
|
||||
{ "no-headings", no_argument, NULL, OPT_NO_HEADINGS },
|
||||
{ "base", required_argument, NULL, OPT_BASE },
|
||||
@@ -623,6 +626,11 @@ static exit_code_t parse_options(struct options *opts, int argc, char *argv[])
|
||||
opts->persistent = 1;
|
||||
break;
|
||||
|
||||
case OPT_AUTO_CONF:
|
||||
/* --auto-conf */
|
||||
opts->auto_conf = 1;
|
||||
break;
|
||||
|
||||
case OPT_COLUMNS:
|
||||
/* --columns COLUMN */
|
||||
strlist_add_multi(opts->columns, optarg, ",", 0);
|
||||
@@ -685,7 +693,15 @@ static exit_code_t parse_options(struct options *opts, int argc, char *argv[])
|
||||
goto out;
|
||||
|
||||
/* Determine configuration set. */
|
||||
opts->config = get_config(opts->active, opts->persistent);
|
||||
if (!opts->active && !opts->persistent && !opts->auto_conf) {
|
||||
/* Default display targets are active + persistent - note that
|
||||
* autoconf data is still shown when available to make users
|
||||
* aware of this type of data. */
|
||||
opts->config = config_active | config_persistent;
|
||||
} else {
|
||||
opts->config = get_config(opts->active, opts->persistent,
|
||||
opts->auto_conf);
|
||||
}
|
||||
|
||||
/* Handle positional parameters. */
|
||||
rc = parse_positional(opts, argc, argv, optind);
|
||||
@@ -725,6 +741,7 @@ enum dev_table_id {
|
||||
dev_netdevs,
|
||||
dev_exists,
|
||||
dev_pers,
|
||||
dev_auto,
|
||||
dev_online,
|
||||
dev_failed,
|
||||
dev_modules,
|
||||
@@ -744,6 +761,8 @@ static struct column *dev_table = COLUMN_ARRAY(
|
||||
"Device exists in the active configuration"),
|
||||
COLUMN("PERS", align_left, dev_pers, 1,
|
||||
"Device is configured persistently"),
|
||||
COLUMN("AUTO", align_left, dev_auto, 0,
|
||||
"Auto-configuration exists for device"),
|
||||
COLUMN("FAILED", align_left, dev_failed, 0,
|
||||
"Device is in error"),
|
||||
COLUMN("NAMES", align_left, dev_names, 1,
|
||||
@@ -762,21 +781,34 @@ static struct column *dev_table = COLUMN_ARRAY(
|
||||
"Path to specific attribute in active configuration")
|
||||
);
|
||||
|
||||
static char *merge_str(const char *act, const char *pers)
|
||||
static char *merge_str(const char *act, const char *pers, const char *ac,
|
||||
config_t config)
|
||||
{
|
||||
char *str;
|
||||
size_t len;
|
||||
|
||||
if (act && pers) {
|
||||
if (strcmp(act, pers) == 0)
|
||||
str = misc_strdup(act);
|
||||
else
|
||||
str = misc_asprintf("%s/%s", act, pers);
|
||||
} else if (act)
|
||||
str = misc_strdup(act);
|
||||
else if (pers)
|
||||
str = misc_strdup(pers);
|
||||
else
|
||||
str = misc_strdup("-");
|
||||
act = act ? act : "-";
|
||||
pers = pers ? pers : "-";
|
||||
ac = ac ? ac : "-";
|
||||
|
||||
if (strcmp(act, pers) == 0 && strcmp(act, ac) == 0)
|
||||
return misc_strdup(act);
|
||||
|
||||
len = strlen(act) + strlen(pers) + strlen(ac) + /* 3 * / + NUL */ 4;
|
||||
str = misc_malloc(len);
|
||||
|
||||
if (SCOPE_ACTIVE(config))
|
||||
strcat(str, act);
|
||||
if (SCOPE_PERSISTENT(config)) {
|
||||
if (*str)
|
||||
strcat(str, "/");
|
||||
strcat(str, pers);
|
||||
}
|
||||
if (SCOPE_AUTOCONF(config)) {
|
||||
if (*str)
|
||||
strcat(str, "/");
|
||||
strcat(str, ac);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
@@ -821,10 +853,9 @@ static char *get_attr(struct device *dev, const char *name, config_t config)
|
||||
struct setting_list *list;
|
||||
struct setting *s;
|
||||
|
||||
if (config == config_active)
|
||||
list = dev->active.settings;
|
||||
else
|
||||
list = dev->persistent.settings;
|
||||
list = device_get_setting_list(dev, config);
|
||||
if (!list)
|
||||
return NULL;
|
||||
s = setting_list_find(list, name);
|
||||
if (!s) {
|
||||
if (config == config_active) {
|
||||
@@ -841,7 +872,7 @@ static char *get_attr(struct device *dev, const char *name, config_t config)
|
||||
static char *dev_table_get_attr(struct device *dev, const char *attr,
|
||||
config_t config)
|
||||
{
|
||||
char *act = NULL, *pers = NULL, *str;
|
||||
char *act = NULL, *pers = NULL, *ac = NULL, *str;
|
||||
const char *name;
|
||||
|
||||
name = strchr(attr, ':');
|
||||
@@ -853,10 +884,13 @@ static char *dev_table_get_attr(struct device *dev, const char *attr,
|
||||
act = get_attr(dev, name, config_active);
|
||||
if (SCOPE_PERSISTENT(config))
|
||||
pers = get_attr(dev, name, config_persistent);
|
||||
if (SCOPE_AUTOCONF(config))
|
||||
ac = get_attr(dev, name, config_autoconf);
|
||||
|
||||
str = merge_str(act, pers);
|
||||
str = merge_str(act, pers, ac, config);
|
||||
free(act);
|
||||
free(pers);
|
||||
free(ac);
|
||||
|
||||
return str;
|
||||
}
|
||||
@@ -904,7 +938,11 @@ static char *dev_table_get_value(void *item, int id, const char *heading,
|
||||
return misc_strdup(YESNO(dev->active.exists ||
|
||||
dev->active.definable));
|
||||
case dev_pers:
|
||||
if (!dev->persistent.exists && dev->autoconf.exists)
|
||||
return misc_strdup("auto");
|
||||
return misc_strdup(YESNO(dev->persistent.exists));
|
||||
case dev_auto:
|
||||
return misc_strdup(YESNO(dev->autoconf.exists));
|
||||
case dev_online:
|
||||
return dev_table_get_online(dev, config_active);
|
||||
case dev_failed:
|
||||
@@ -942,6 +980,7 @@ static read_scope_t get_scope(struct options *opts)
|
||||
case dev_netdevs:
|
||||
case dev_exists:
|
||||
case dev_pers:
|
||||
case dev_auto:
|
||||
case dev_online:
|
||||
case dev_modules:
|
||||
continue;
|
||||
@@ -960,14 +999,21 @@ static struct util_list *dev_table_build(struct options *opts,
|
||||
struct util_list *selected, *devices = NULL;
|
||||
struct selected_dev_node *sel;
|
||||
struct device *dev;
|
||||
int active, persistent;
|
||||
int active, persistent, autoconf;
|
||||
read_scope_t scope;
|
||||
exit_code_t rc;
|
||||
config_t config = opts->config;
|
||||
|
||||
scope = get_scope(opts);
|
||||
selected = selected_dev_list_new();
|
||||
|
||||
/* Read auto-config data when no configuration set was specified to
|
||||
* make user aware of auto-config data. */
|
||||
if (!opts->active && !opts->persistent && !opts->auto_conf)
|
||||
config |= config_autoconf;
|
||||
|
||||
rc = select_devices(opts->select, selected, 1, 0, opts->pairs,
|
||||
opts->config, scope, err_print);
|
||||
config, scope, err_print);
|
||||
if (rc)
|
||||
goto out;
|
||||
devices = ptrlist_new();
|
||||
@@ -987,7 +1033,8 @@ static struct util_list *dev_table_build(struct options *opts,
|
||||
/* Only process existing devices. */
|
||||
active = dev->active.exists || dev->active.definable;
|
||||
persistent = dev->persistent.exists;
|
||||
if (!active && !persistent)
|
||||
autoconf = dev->autoconf.exists;
|
||||
if (!active && !persistent && !autoconf)
|
||||
continue;
|
||||
|
||||
ptrlist_add(devices, dev);
|
||||
@@ -1025,9 +1072,11 @@ static exit_code_t do_list_devices(struct options *opts)
|
||||
if (!items)
|
||||
return EXIT_EMPTY_SELECTION;
|
||||
|
||||
/* Adjust columns visible depending on --active and --persistent. */
|
||||
/* Adjust columns visible depending on selected config set. */
|
||||
table_set_default(dev_table, dev_online, SCOPE_ACTIVE(opts->config));
|
||||
table_set_default(dev_table, dev_pers, SCOPE_PERSISTENT(opts->config));
|
||||
table_set_default(dev_table, dev_auto, SCOPE_AUTOCONF(opts->config) &&
|
||||
!SCOPE_PERSISTENT(opts->config));
|
||||
table_set_default(dev_table, dev_names, SCOPE_ACTIVE(opts->config));
|
||||
|
||||
/* Display table. */
|
||||
@@ -1057,17 +1106,20 @@ enum settings_table_id {
|
||||
settings_readonly,
|
||||
settings_active,
|
||||
settings_persistent,
|
||||
settings_autoconf,
|
||||
};
|
||||
|
||||
static struct column *settings_table = COLUMN_ARRAY(
|
||||
COLUMN("ATTRIBUTE", align_left, settings_attribute, 1, ""),
|
||||
COLUMN("READONLY", align_left, settings_readonly, 1, ""),
|
||||
COLUMN("ACTIVE", align_left, settings_active, 1, ""),
|
||||
COLUMN("PERSISTENT", align_left, settings_persistent, 1, "")
|
||||
COLUMN("PERSISTENT", align_left, settings_persistent, 1, ""),
|
||||
COLUMN("AUTOCONF", align_left, settings_autoconf, 0, "")
|
||||
);
|
||||
|
||||
static struct util_list *settings_table_build(struct setting_list *active,
|
||||
struct setting_list *persistent,
|
||||
struct setting_list *autoconf,
|
||||
bool readonly)
|
||||
{
|
||||
struct util_list *names, *items;
|
||||
@@ -1088,6 +1140,10 @@ static struct util_list *settings_table_build(struct setting_list *active,
|
||||
util_list_iterate(&persistent->list, s)
|
||||
strlist_add(names, s->name);
|
||||
}
|
||||
if (autoconf && !readonly) {
|
||||
util_list_iterate(&autoconf->list, s)
|
||||
strlist_add(names, s->name);
|
||||
}
|
||||
strlist_sort_unique(names, str_cmp);
|
||||
|
||||
/* Convert strlist to ptrlist. */
|
||||
@@ -1102,6 +1158,7 @@ static struct util_list *settings_table_build(struct setting_list *active,
|
||||
struct settings_table_data {
|
||||
struct setting_list *active;
|
||||
struct setting_list *persistent;
|
||||
struct setting_list *autoconf;
|
||||
int pairs;
|
||||
bool readonly;
|
||||
};
|
||||
@@ -1124,12 +1181,17 @@ static char *settings_table_get_value(void *item, int id, const char *heading,
|
||||
case settings_persistent:
|
||||
list = stdata->persistent;
|
||||
break;
|
||||
case settings_autoconf:
|
||||
list = stdata->autoconf;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (list) {
|
||||
s = setting_list_find(list, name);
|
||||
if (s && !(id == settings_persistent && s->derived)) {
|
||||
if (s &&
|
||||
!((id == settings_persistent || id == settings_autoconf) &&
|
||||
s->derived)) {
|
||||
if (stdata->pairs)
|
||||
return misc_strdup(s->value);
|
||||
else
|
||||
@@ -1145,6 +1207,7 @@ static char *settings_table_get_value(void *item, int id, const char *heading,
|
||||
|
||||
static void settings_table_print(struct setting_list *active,
|
||||
struct setting_list *persistent,
|
||||
struct setting_list *autoconf,
|
||||
struct options *opts, int ind, bool readonly,
|
||||
bool neednl)
|
||||
{
|
||||
@@ -1154,7 +1217,7 @@ static void settings_table_print(struct setting_list *active,
|
||||
items = settings_table_build(
|
||||
SCOPE_ACTIVE(opts->config) ? active : NULL,
|
||||
SCOPE_PERSISTENT(opts->config) ? persistent : NULL,
|
||||
readonly);
|
||||
autoconf, readonly);
|
||||
if (util_list_is_empty(items)) {
|
||||
if (!opts->pairs && !readonly)
|
||||
indent(ind, "%sNo settings found\n",
|
||||
@@ -1170,8 +1233,12 @@ static void settings_table_print(struct setting_list *active,
|
||||
SCOPE_ACTIVE(opts->config));
|
||||
table_set_default(settings_table, settings_persistent,
|
||||
SCOPE_PERSISTENT(opts->config) && !readonly ? 1 : 0);
|
||||
table_set_default(settings_table, settings_autoconf,
|
||||
(SCOPE_AUTOCONF(opts->config) || autoconf) &&
|
||||
!readonly ? 1 : 0);
|
||||
data.active = active;
|
||||
data.persistent = persistent;
|
||||
data.autoconf = autoconf;
|
||||
data.pairs = opts->pairs;
|
||||
table_print(settings_table, settings_table_get_value, &data, items,
|
||||
NULL, 1, opts->pairs, ind, 0);
|
||||
@@ -1253,7 +1320,7 @@ static exit_code_t do_info_type(struct options *opts)
|
||||
}
|
||||
} else {
|
||||
settings_table_print(dt->active_settings,
|
||||
dt->persistent_settings, opts,
|
||||
dt->persistent_settings, NULL, opts,
|
||||
INFO_INDENT, false, false);
|
||||
}
|
||||
|
||||
@@ -1280,7 +1347,7 @@ static void do_info_one_device(struct device *dev, struct options *opts)
|
||||
{
|
||||
struct subtype *st = dev->subtype;
|
||||
char *names, *bdevs, *cdevs, *ndevs, *modules, *online, *path, *key;
|
||||
const char *id, *type, *exists, *persist, *prefix;
|
||||
const char *id, *type, *exists, *persist, *ac, *prefix;
|
||||
struct util_list *resources, *errors;
|
||||
struct strlist_node *s;
|
||||
bool first;
|
||||
@@ -1299,6 +1366,7 @@ static void do_info_one_device(struct device *dev, struct options *opts)
|
||||
errors = subtype_get_errors(dev->subtype, dev->id);
|
||||
exists = YESNO(dev->active.exists || dev->active.definable);
|
||||
persist = YESNO(dev->persistent.exists);
|
||||
ac = YESNO(dev->autoconf.exists);
|
||||
|
||||
/* Print information. */
|
||||
if (opts->pairs) {
|
||||
@@ -1316,6 +1384,8 @@ static void do_info_one_device(struct device *dev, struct options *opts)
|
||||
print_pair("ONLINE", online);
|
||||
print_pair("EXISTS", exists);
|
||||
print_pair("PERSISTENT", persist);
|
||||
if (SCOPE_AUTOCONF(opts->config) || dev->autoconf.exists)
|
||||
print_pair("AUTOCONF", ac);
|
||||
if (errors) {
|
||||
util_list_iterate(errors, s)
|
||||
print_pair("ERROR", s->str);
|
||||
@@ -1341,6 +1411,8 @@ static void do_info_one_device(struct device *dev, struct options *opts)
|
||||
print_info("Online", online);
|
||||
print_info("Exists", exists);
|
||||
print_info("Persistent", persist);
|
||||
if (SCOPE_AUTOCONF(opts->config) || dev->autoconf.exists)
|
||||
print_info("Auto-configured", ac);
|
||||
if (errors) {
|
||||
first = true;
|
||||
util_list_iterate(errors, s) {
|
||||
@@ -1382,11 +1454,17 @@ static void do_info_one_device(struct device *dev, struct options *opts)
|
||||
|
||||
settings_table_print(dev->active.exists ? dev->active.settings : NULL,
|
||||
dev->persistent.exists ? dev->persistent.settings :
|
||||
NULL, opts, INFO_INDENT, false, !opts->pairs);
|
||||
NULL,
|
||||
dev->autoconf.exists ? dev->autoconf.settings :
|
||||
NULL,
|
||||
opts, INFO_INDENT, false, !opts->pairs);
|
||||
|
||||
settings_table_print(dev->active.exists ? dev->active.settings : NULL,
|
||||
dev->persistent.exists ? dev->persistent.settings :
|
||||
NULL, opts, INFO_INDENT, true, !opts->pairs);
|
||||
NULL,
|
||||
dev->autoconf.exists ? dev->autoconf.settings :
|
||||
NULL,
|
||||
opts, INFO_INDENT, true, !opts->pairs);
|
||||
|
||||
strlist_free(errors);
|
||||
free(online);
|
||||
@@ -1404,9 +1482,10 @@ static exit_code_t do_info_devices(struct options *opts)
|
||||
struct util_list *selected;
|
||||
struct selected_dev_node *sel;
|
||||
struct device *dev;
|
||||
int found, active, persistent;
|
||||
int found, active, persistent, autoconf;
|
||||
exit_code_t rc, drc = EXIT_OK;
|
||||
read_scope_t scope;
|
||||
config_t config = opts->config;
|
||||
|
||||
if (opts->info > 1)
|
||||
scope = scope_all;
|
||||
@@ -1415,7 +1494,13 @@ static exit_code_t do_info_devices(struct options *opts)
|
||||
|
||||
/* Get list of selected devices. */
|
||||
selected = selected_dev_list_new();
|
||||
select_devices(opts->select, selected, 1, 0, opts->pairs, opts->config,
|
||||
|
||||
/* Read auto-config data when no configuration set was specified to
|
||||
* make user aware of auto-config data. */
|
||||
if (!opts->active && !opts->persistent && !opts->auto_conf)
|
||||
config |= config_autoconf;
|
||||
|
||||
select_devices(opts->select, selected, 1, 0, opts->pairs, config,
|
||||
scope, err_print);
|
||||
|
||||
/* Process selected devices. */
|
||||
@@ -1434,9 +1519,8 @@ static exit_code_t do_info_devices(struct options *opts)
|
||||
/* Only process existing devices. */
|
||||
active = dev->active.exists || dev->active.definable;
|
||||
persistent = dev->persistent.exists;
|
||||
if ((opts->config == config_active && !active) ||
|
||||
(opts->config == config_persistent && !persistent) ||
|
||||
(opts->config == config_all && !active && !persistent))
|
||||
autoconf = dev->autoconf.exists;
|
||||
if (!active && !persistent && !autoconf)
|
||||
continue;
|
||||
if (found > 0)
|
||||
printf("\n");
|
||||
|
||||
@@ -41,5 +41,6 @@ OPTIONS
|
||||
-n, --no-headings Do not print column headings
|
||||
--base PATH Use PATH as base for accessing files
|
||||
--pairs Produce output in KEY="VALUE" format
|
||||
--auto-conf Only show auto-configuration data
|
||||
-V, --verbose Print additional run-time information
|
||||
-q, --quiet Print only minimal run-time information
|
||||
|
||||
@@ -98,26 +98,47 @@ static void dryrun_end_data(void)
|
||||
|
||||
#define READ_CHUNK_SIZE 4096
|
||||
|
||||
/* Read text from @fd and return resulting NULL-terminated text buffer.
|
||||
* If @chomp is non-zero, remove trailing newline character. Return %NULL
|
||||
* on error or when unprintable characters are read. */
|
||||
static char *read_fd(FILE *fd, int chomp)
|
||||
/* Read all data from @fd and return address of resulting buffer in
|
||||
* @buffer_ptr. If @size_ptr is non-zero, use it to store the size of the
|
||||
* resulting buffer. Return %EXIT_OK on success. */
|
||||
exit_code_t misc_read_fd(FILE *fd, void **buffer_ptr, size_t *size_ptr)
|
||||
{
|
||||
char *buffer = NULL;
|
||||
size_t done, i;
|
||||
size_t done = 0;
|
||||
|
||||
done = 0;
|
||||
while (!feof(fd)) {
|
||||
buffer = realloc(buffer, done + READ_CHUNK_SIZE + 1);
|
||||
buffer = realloc(buffer, done + READ_CHUNK_SIZE);
|
||||
if (!buffer)
|
||||
oom();
|
||||
done += fread(&buffer[done], 1, READ_CHUNK_SIZE, fd);
|
||||
if (ferror(fd)) {
|
||||
free(buffer);
|
||||
return NULL;
|
||||
return EXIT_RUNTIME_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
buffer = realloc(buffer, done);
|
||||
if (!buffer && done > 0)
|
||||
oom();
|
||||
|
||||
*buffer_ptr = buffer;
|
||||
if (size_ptr)
|
||||
*size_ptr = done;
|
||||
|
||||
return EXIT_OK;
|
||||
}
|
||||
|
||||
/* Read text from @fd and return resulting NULL-terminated text buffer.
|
||||
* If @chomp is non-zero, remove trailing newline character. Return %NULL
|
||||
* on error or when unprintable characters are read. */
|
||||
static char *read_fd(FILE *fd, int chomp)
|
||||
{
|
||||
char *buffer;
|
||||
size_t done, i;
|
||||
|
||||
if (misc_read_fd(fd, (void **) &buffer, &done))
|
||||
return NULL;
|
||||
|
||||
/* Check if this is a text file at all (required to filter out
|
||||
* binary sysfs attributes). */
|
||||
for (i = 0; i < done; i++) {
|
||||
@@ -131,12 +152,13 @@ static char *read_fd(FILE *fd, int chomp)
|
||||
if (chomp && done > 0 && buffer[done - 1] == '\n')
|
||||
done--;
|
||||
|
||||
if (buffer) {
|
||||
/* NULL-terminate. */
|
||||
buffer[done++] = 0;
|
||||
}
|
||||
/* NULL-terminate. */
|
||||
buffer = realloc(buffer, done + 1);
|
||||
if (!buffer)
|
||||
oom();
|
||||
buffer[done] = 0;
|
||||
|
||||
return realloc(buffer, done);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static int count_newline(const char *str)
|
||||
@@ -1085,14 +1107,18 @@ char *misc_readlink(const char *path)
|
||||
}
|
||||
|
||||
/* Determine configuration set. */
|
||||
config_t get_config(int active, int persistent)
|
||||
config_t get_config(int active, int persistent, int autoconf)
|
||||
{
|
||||
if ((!active && !persistent) || (active && persistent))
|
||||
return config_all;
|
||||
else if (active)
|
||||
return config_active;
|
||||
else
|
||||
return config_persistent;
|
||||
config_t config = 0;
|
||||
|
||||
if (active)
|
||||
config |= config_active;
|
||||
if (persistent)
|
||||
config |= config_persistent;
|
||||
if (autoconf)
|
||||
config |= config_autoconf;
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
/* Determine if program is running under z/VM. */
|
||||
@@ -1226,11 +1252,12 @@ const char *config_to_str(config_t config)
|
||||
return "active";
|
||||
case config_persistent:
|
||||
return "persistent";
|
||||
case config_autoconf:
|
||||
return "autoconf";
|
||||
case config_all:
|
||||
return "all";
|
||||
}
|
||||
/* Should not happen. */
|
||||
return "";
|
||||
return "multiple";
|
||||
}
|
||||
|
||||
/* Convert textual config representation to config_t. */
|
||||
@@ -1240,6 +1267,8 @@ bool str_to_config(const char *str, config_t *config_ptr)
|
||||
*config_ptr = config_active;
|
||||
else if (strcasecmp(str, "persistent") == 0)
|
||||
*config_ptr = config_persistent;
|
||||
else if (strcasecmp(str, "autoconf") == 0)
|
||||
*config_ptr = config_autoconf;
|
||||
else if (strcasecmp(str, "all") == 0)
|
||||
*config_ptr = config_all;
|
||||
else
|
||||
@@ -1688,3 +1717,18 @@ void debug_init(int argc, char *argv[])
|
||||
fprintf(stderr, "%s\"%s\"", i > 0 ? ", " : "", argv[i]);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
/* Return the last occurrence of @needle in @haystack, or %NULL if @needle
|
||||
* was not found. */
|
||||
char *misc_strrstr(const char *haystack, const char *needle)
|
||||
{
|
||||
char *result, *next;
|
||||
|
||||
result = strstr(haystack, needle);
|
||||
if (result) {
|
||||
while ((next = strstr(result + 1, needle)))
|
||||
result = next;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -297,21 +297,25 @@ char *path_get_ccwgroup_devices(const char *drv)
|
||||
}
|
||||
|
||||
/* Return path to udev rule. */
|
||||
char *path_get_udev_rule(const char *type, const char *id)
|
||||
char *path_get_udev_rule(const char *type, const char *id, bool vol)
|
||||
{
|
||||
const char *path = vol ? PATH_UDEV_RULES_VOLATILE : PATH_UDEV_RULES;
|
||||
|
||||
if (id) {
|
||||
return path_get("%s/%s-%s-%s%s", PATH_UDEV_RULES,
|
||||
return path_get("%s/%s-%s-%s%s", path,
|
||||
UDEV_PREFIX, type, id, UDEV_SUFFIX);
|
||||
}
|
||||
|
||||
return path_get("%s/%s-%s%s", PATH_UDEV_RULES,
|
||||
return path_get("%s/%s-%s%s", path,
|
||||
UDEV_PREFIX, type, UDEV_SUFFIX);
|
||||
}
|
||||
|
||||
/* Return path to directory containing all udev rules. */
|
||||
char *path_get_udev_rules(void)
|
||||
char *path_get_udev_rules(bool vol)
|
||||
{
|
||||
return path_get("%s", PATH_UDEV_RULES);
|
||||
const char *path = vol ? PATH_UDEV_RULES_VOLATILE : PATH_UDEV_RULES;
|
||||
|
||||
return path_get("%s", path);
|
||||
}
|
||||
|
||||
/* Return path to the specified file in the proc file system. */
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "ccwgroup.h"
|
||||
#include "device.h"
|
||||
#include "devtype.h"
|
||||
#include "internal.h"
|
||||
#include "misc.h"
|
||||
#include "namespace.h"
|
||||
#include "nic.h"
|
||||
@@ -1207,7 +1208,7 @@ static exit_code_t check_layer2(struct device *dev, config_t config)
|
||||
{
|
||||
struct setting *l;
|
||||
int layer2_detected, layer2_active = -1, layer2_persistent = -1,
|
||||
layer2_modified = 0;
|
||||
layer2_autoconf = -1, layer2_modified = 0;
|
||||
exit_code_t rc = EXIT_OK;
|
||||
|
||||
layer2_detected = detect_layer2(dev);
|
||||
@@ -1231,13 +1232,25 @@ static exit_code_t check_layer2(struct device *dev, config_t config)
|
||||
if (rc)
|
||||
goto out;
|
||||
}
|
||||
l = setting_list_find(dev->autoconf.settings, qeth_attr_layer2.name);
|
||||
if (l) {
|
||||
layer2_autoconf = atoi(l->value);
|
||||
layer2_modified |= l->modified;
|
||||
} else if (SCOPE_AUTOCONF(config)) {
|
||||
rc = generate_layer2("autoconf", dev->autoconf.settings,
|
||||
&layer2_autoconf, &layer2_modified);
|
||||
if (rc)
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Check correct layer2 setting. */
|
||||
if (layer2_detected != -1) {
|
||||
if ((SCOPE_ACTIVE(config) && layer2_active != -1 &&
|
||||
layer2_active != layer2_detected) ||
|
||||
(SCOPE_PERSISTENT(config) && layer2_persistent != -1 &&
|
||||
layer2_persistent != layer2_detected)) {
|
||||
layer2_persistent != layer2_detected) ||
|
||||
(SCOPE_AUTOCONF(config) && layer2_autoconf != -1 &&
|
||||
layer2_autoconf != layer2_detected)) {
|
||||
rc = layer2_mismatch(layer2_detected, layer2_modified);
|
||||
if (rc)
|
||||
goto out;
|
||||
@@ -1256,14 +1269,25 @@ static exit_code_t check_layer2(struct device *dev, config_t config)
|
||||
if (rc)
|
||||
goto out;
|
||||
}
|
||||
if (SCOPE_AUTOCONF(config)) {
|
||||
rc = check_ineffective_settings(dev->autoconf.settings,
|
||||
layer2_autoconf);
|
||||
if (rc)
|
||||
goto out;
|
||||
}
|
||||
/* check for conflicting layer2 attribute groups */
|
||||
if (SCOPE_ACTIVE(config)) {
|
||||
rc = check_conflicting_settings(dev->active.settings);
|
||||
if (rc)
|
||||
goto out;
|
||||
}
|
||||
if (SCOPE_PERSISTENT(config))
|
||||
if (SCOPE_PERSISTENT(config)) {
|
||||
rc = check_conflicting_settings(dev->persistent.settings);
|
||||
if (rc)
|
||||
goto out;
|
||||
}
|
||||
if (SCOPE_AUTOCONF(config))
|
||||
rc = check_conflicting_settings(dev->autoconf.settings);
|
||||
|
||||
out:
|
||||
return rc;
|
||||
@@ -1277,7 +1301,8 @@ static exit_code_t qeth_st_check_pre_configure(struct subtype *st,
|
||||
|
||||
/* No need to check if device is deconfigured. */
|
||||
if ((SCOPE_ACTIVE(config) && dev->active.deconfigured) ||
|
||||
(SCOPE_PERSISTENT(config) && dev->persistent.deconfigured))
|
||||
(SCOPE_PERSISTENT(config) && dev->persistent.deconfigured) ||
|
||||
(SCOPE_AUTOCONF(config) && dev->autoconf.deconfigured))
|
||||
return EXIT_OK;
|
||||
|
||||
rc = check_layer2(dev, config);
|
||||
@@ -1369,7 +1394,7 @@ static struct ccwgroup_subtype_data qeth_data = {
|
||||
.num_devs = QETH_NUM_DEVS,
|
||||
};
|
||||
|
||||
static struct subtype qeth_subtype_qeth = {
|
||||
struct subtype qeth_subtype_qeth = {
|
||||
.super = &ccwgroup_subtype,
|
||||
.devtype = &qeth_devtype,
|
||||
.name = "qeth",
|
||||
@@ -1421,6 +1446,7 @@ static struct subtype qeth_subtype_qeth = {
|
||||
&qeth_attr_vnicc_takeover_learning,
|
||||
&qeth_attr_vnicc_bridge_invisible,
|
||||
&qeth_attr_vnicc_rx_bcast,
|
||||
&internal_attr_early,
|
||||
),
|
||||
.unknown_dev_attribs = 1,
|
||||
.support_definable = 1,
|
||||
|
||||
@@ -8,11 +8,13 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lib/util_path.h"
|
||||
|
||||
#include "device.h"
|
||||
#include "devtype.h"
|
||||
#include "internal.h"
|
||||
#include "misc.h"
|
||||
#include "path.h"
|
||||
#include "root.h"
|
||||
@@ -20,31 +22,78 @@
|
||||
#include "setting.h"
|
||||
#include "subtype.h"
|
||||
|
||||
/* Determine if the root device was modified. If it was modified, run the
|
||||
* corresponding root-install scripts. */
|
||||
static bool is_early_removed(struct device *dev)
|
||||
{
|
||||
struct setting *s;
|
||||
|
||||
s = setting_list_find(dev->persistent.settings,
|
||||
internal_attr_early.name);
|
||||
if (!s || !s->modified)
|
||||
return false;
|
||||
if (!s->actual_value || strcmp(s->actual_value, "1") != 0)
|
||||
return false;
|
||||
if (s->removed || strcmp(s->value, "0") == 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void add_early_removed(struct util_list *selected)
|
||||
{
|
||||
int i, j;
|
||||
struct devtype *dt;
|
||||
struct subtype *st;
|
||||
struct device *dev;
|
||||
|
||||
for (i = 0; devtypes[i]; i++) {
|
||||
dt = devtypes[i];
|
||||
for (j = 0; dt->subtypes[j]; j++) {
|
||||
st = dt->subtypes[j];
|
||||
util_list_iterate(&st->devices->hash.list, dev) {
|
||||
if (is_early_removed(dev)) {
|
||||
selected_dev_list_add(selected, dt, st,
|
||||
dev->id, NULL, EXIT_OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Determine if initial RAM-disk needs updating. If so, run the corresponding
|
||||
* scripts if available. */
|
||||
exit_code_t root_check(void)
|
||||
{
|
||||
struct util_list *selected, *params, *mod = NULL;
|
||||
struct selected_dev_node *sel;
|
||||
struct device *dev;
|
||||
char *params_str;
|
||||
exit_code_t rc;
|
||||
exit_code_t rc = EXIT_OK;
|
||||
struct strlist_node *s;
|
||||
struct devtype *dt;
|
||||
struct select_opts *select;
|
||||
|
||||
debug("Checking for modified root device configuration\n");
|
||||
debug("Checking for required initial RAM-disk update\n");
|
||||
|
||||
/* Get list of devices that provide the root device. */
|
||||
/* Get list of devices that provide the root device or require
|
||||
* early configuration. */
|
||||
selected = selected_dev_list_new();
|
||||
rc = select_by_path(NULL, selected, config_active, scope_mandatory,
|
||||
NULL, NULL, PATH_ROOT, err_ignore);
|
||||
if (rc) {
|
||||
/* First add devices that had zdev:early removed or changed to 0.
|
||||
* The subsequent call to select_devices() will filter out any
|
||||
* duplicates. */
|
||||
add_early_removed(selected);
|
||||
/* Now add devices required for root file system. */
|
||||
if (select_by_path(NULL, selected, config_active, scope_mandatory,
|
||||
NULL, NULL, PATH_ROOT, err_ignore)) {
|
||||
/* Running from an unknown root device is not an error. */
|
||||
verb("Note: Could not determine if root device configuration "
|
||||
"needs to be updated\n");
|
||||
rc = 0;
|
||||
goto out;
|
||||
}
|
||||
/* Finally add devices with zdev:early=1. */
|
||||
select = select_opts_new();
|
||||
strlist_add(&select->by_attr, "%s=1", INTERNAL_ATTR_EARLY);
|
||||
select_devices(select, selected, 1, 0, 0,
|
||||
config_active | config_persistent, scope_mandatory,
|
||||
err_ignore);
|
||||
select_opts_free(select);
|
||||
|
||||
/* Determine if any of the devices or device types has been modified. */
|
||||
mod = strlist_new();
|
||||
@@ -60,7 +109,7 @@ exit_code_t root_check(void)
|
||||
/* Check devices. */
|
||||
dev = device_list_find(sel->st->devices, sel->id, NULL);
|
||||
if (dev && dev->persistent.exists &&
|
||||
device_needs_writing(dev, config_persistent)) {
|
||||
(device_needs_writing(dev, config_persistent) || force)) {
|
||||
strlist_add(mod, "%s %s", dev->subtype->devname,
|
||||
dev->id);
|
||||
}
|
||||
@@ -68,19 +117,18 @@ exit_code_t root_check(void)
|
||||
|
||||
if (util_list_is_empty(mod))
|
||||
goto out;
|
||||
info("Note: Some of the changes affect devices providing the root "
|
||||
"file system:\n");
|
||||
info("Note: The initial RAM-disk must be updated for these changes to take effect:\n");
|
||||
util_list_iterate(mod, s)
|
||||
info(" - %s\n", s->str);
|
||||
info(" Additional steps such as rebuilding the RAM-disk might be "
|
||||
"required.\n");
|
||||
|
||||
/* Check if script is available. */
|
||||
if (!util_path_is_reg_file(PATH_ROOT_SCRIPT))
|
||||
if (!util_path_is_reg_file(PATH_ROOT_SCRIPT)) {
|
||||
warn("A manual update of the initial RAM-disk is required.\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Ask for confirmation. */
|
||||
if (!confirm("Update persistent root device configuration now?")) {
|
||||
if (!confirm("Update initial RAM-disk now?")) {
|
||||
rc = EXIT_ABORTED;
|
||||
goto out;
|
||||
}
|
||||
@@ -97,7 +145,7 @@ exit_code_t root_check(void)
|
||||
/* Run update command. */
|
||||
if (misc_system(err_delayed_print, "%s %s", PATH_ROOT_SCRIPT,
|
||||
params_str) != 0) {
|
||||
error("Failure while updating root device configuration\n");
|
||||
error("Failure while updating initial RAM-disk\n");
|
||||
delayed_print(DELAY_INDENT);
|
||||
rc = EXIT_RUNTIME_ERROR;
|
||||
}
|
||||
|
||||
@@ -248,12 +248,13 @@ static void unblacklist_devices(struct select_opts *select)
|
||||
bool select_match_state(struct device *dev, struct select_opts *select)
|
||||
{
|
||||
struct subtype *st = dev->subtype;
|
||||
int exists, configured, online;
|
||||
int exists, configured, autoconf, online;
|
||||
struct util_list *errors;
|
||||
|
||||
exists = dev->active.exists || dev->active.definable;
|
||||
configured = dev->persistent.exists;
|
||||
if (select->all && !(exists || configured))
|
||||
autoconf = dev->autoconf.exists;
|
||||
if (select->all && !(exists || configured || autoconf))
|
||||
return false;
|
||||
if (select->existing && !exists)
|
||||
return false;
|
||||
@@ -862,7 +863,8 @@ static exit_code_t select_nocreate(struct select_opts *select,
|
||||
select->offline || select->online ||
|
||||
SCOPE_ACTIVE(config),
|
||||
select->configured || select->all ||
|
||||
SCOPE_PERSISTENT(config));
|
||||
SCOPE_PERSISTENT(config),
|
||||
select->all || SCOPE_AUTOCONF(config));
|
||||
|
||||
longrun_total = 0;
|
||||
if (quiet)
|
||||
@@ -870,7 +872,7 @@ static exit_code_t select_nocreate(struct select_opts *select,
|
||||
|
||||
/* Count devices. */
|
||||
verb("Scanning for devices in %s configuration%s:\n",
|
||||
config_to_str(id_config), id_config == config_all ? "s" : "");
|
||||
config_to_str(id_config), !SCOPE_SINGLE(id_config) ? "s" : "");
|
||||
for (i = 0; (dt = devtypes[i]); i++) {
|
||||
if (select->devtype && dt != select->devtype)
|
||||
continue;
|
||||
@@ -1128,6 +1130,13 @@ static exit_code_t by_attr_cb(struct subtype *st, const char *id,
|
||||
|
||||
/* Check for attribute value in persistent configuration. */
|
||||
s = setting_list_find(dev->persistent.settings, cb_data->key);
|
||||
if (s) {
|
||||
match = setting_match_value(s, cb_data->value);
|
||||
if (match)
|
||||
goto out;
|
||||
}
|
||||
/* Check for attribute value in autoconf configuration. */
|
||||
s = setting_list_find(dev->autoconf.settings, cb_data->key);
|
||||
if (s)
|
||||
match = setting_match_value(s, cb_data->value);
|
||||
|
||||
|
||||
@@ -646,7 +646,8 @@ static void add_changes(struct util_list *list, struct setting *s)
|
||||
|
||||
/* Return a newly allocated string containing the setting changes found
|
||||
* in PERS and ACT or NULL if no change was found. */
|
||||
char *setting_get_changes(struct setting_list *act, struct setting_list *pers)
|
||||
char *setting_get_changes(struct setting_list *act, struct setting_list *pers,
|
||||
struct setting_list *ac)
|
||||
{
|
||||
struct util_list *out;
|
||||
struct util_list *processed;
|
||||
@@ -668,6 +669,17 @@ char *setting_get_changes(struct setting_list *act, struct setting_list *pers)
|
||||
strlist_add(processed, s->name);
|
||||
}
|
||||
}
|
||||
if (ac) {
|
||||
util_list_iterate(&ac->list, s) {
|
||||
if (s->removed)
|
||||
strlist_add(out, "-%s", s->name);
|
||||
else if (s->modified)
|
||||
add_changes(out, s);
|
||||
else
|
||||
continue;
|
||||
strlist_add(processed, s->name);
|
||||
}
|
||||
}
|
||||
if (act) {
|
||||
util_list_iterate(&act->list, s) {
|
||||
if (!s->modified && !s->removed)
|
||||
|
||||
@@ -195,6 +195,13 @@ bool subtype_device_exists_persistent(struct subtype *st, const char *id)
|
||||
return super->exists_persistent(st, id);
|
||||
}
|
||||
|
||||
bool subtype_device_exists_autoconf(struct subtype *st, const char *id)
|
||||
{
|
||||
struct subtype *super = super_get(st, exists_autoconf, 1);
|
||||
|
||||
return super->exists_autoconf(st, id);
|
||||
}
|
||||
|
||||
void subtype_add_active_ids(struct subtype *st, struct util_list *ids)
|
||||
{
|
||||
struct subtype *super = super_get(st, add_active_ids, 1);
|
||||
@@ -209,6 +216,13 @@ void subtype_add_persistent_ids(struct subtype *st, struct util_list *ids)
|
||||
super->add_persistent_ids(st, ids);
|
||||
}
|
||||
|
||||
void subtype_add_autoconf_ids(struct subtype *st, struct util_list *ids)
|
||||
{
|
||||
struct subtype *super = super_get(st, add_autoconf_ids, 1);
|
||||
|
||||
super->add_autoconf_ids(st, ids);
|
||||
}
|
||||
|
||||
exit_code_t subtype_device_read_active(struct subtype *st, struct device *dev,
|
||||
read_scope_t scope)
|
||||
{
|
||||
@@ -226,6 +240,15 @@ exit_code_t subtype_device_read_persistent(struct subtype *st,
|
||||
return super->read_persistent(st, dev, scope);
|
||||
}
|
||||
|
||||
exit_code_t subtype_device_read_autoconf(struct subtype *st,
|
||||
struct device *dev,
|
||||
read_scope_t scope)
|
||||
{
|
||||
struct subtype *super = super_get(st, read_autoconf, 1);
|
||||
|
||||
return super->read_autoconf(st, dev, scope);
|
||||
}
|
||||
|
||||
exit_code_t subtype_device_configure_active(struct subtype *st,
|
||||
struct device *dev)
|
||||
{
|
||||
@@ -242,6 +265,14 @@ exit_code_t subtype_device_configure_persistent(struct subtype *st,
|
||||
return super->configure_persistent(st, dev);
|
||||
}
|
||||
|
||||
exit_code_t subtype_device_configure_autoconf(struct subtype *st,
|
||||
struct device *dev)
|
||||
{
|
||||
struct subtype *super = super_get(st, configure_autoconf, 1);
|
||||
|
||||
return super->configure_autoconf(st, dev);
|
||||
}
|
||||
|
||||
exit_code_t subtype_device_deconfigure_active(struct subtype *st,
|
||||
struct device *dev)
|
||||
{
|
||||
@@ -258,6 +289,14 @@ exit_code_t subtype_device_deconfigure_persistent(struct subtype *st,
|
||||
return super->deconfigure_persistent(st, dev);
|
||||
}
|
||||
|
||||
exit_code_t subtype_device_deconfigure_autoconf(struct subtype *st,
|
||||
struct device *dev)
|
||||
{
|
||||
struct subtype *super = super_get(st, deconfigure_autoconf, 1);
|
||||
|
||||
return super->deconfigure_autoconf(st, dev);
|
||||
}
|
||||
|
||||
exit_code_t subtype_check_pre_configure(struct subtype *st, struct device *dev,
|
||||
int prereq, config_t config)
|
||||
{
|
||||
@@ -299,7 +338,7 @@ void subtype_online_set(struct subtype *st, struct device *dev, int online,
|
||||
int subtype_online_get(struct subtype *st, struct device *dev, config_t config)
|
||||
{
|
||||
struct subtype *super = super_get(st, online_get, 0);
|
||||
int act_online = 1, pers_online = 1;
|
||||
int act_online = 1, pers_online = 1, auto_online = 1;
|
||||
|
||||
if (super)
|
||||
return super->online_get(st, dev, config);
|
||||
@@ -310,8 +349,10 @@ int subtype_online_get(struct subtype *st, struct device *dev, config_t config)
|
||||
act_online = dev->active.exists;
|
||||
if (SCOPE_PERSISTENT(config))
|
||||
pers_online = dev->persistent.exists;
|
||||
if (SCOPE_AUTOCONF(config))
|
||||
auto_online = dev->autoconf.exists;
|
||||
|
||||
return MIN(act_online, pers_online);
|
||||
return MIN(MIN(act_online, pers_online), auto_online);
|
||||
}
|
||||
|
||||
bool subtype_online_specified(struct subtype *st, struct device *dev,
|
||||
@@ -495,6 +536,10 @@ bool subtype_device_exists(struct subtype *st, const char *id, config_t config)
|
||||
if (!subtype_device_exists_persistent(st, id))
|
||||
return false;
|
||||
}
|
||||
if (SCOPE_AUTOCONF(config)) {
|
||||
if (!subtype_device_exists_autoconf(st, id))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -512,6 +557,8 @@ static struct util_list *get_ids(struct subtype *st, config_t config)
|
||||
}
|
||||
if (SCOPE_PERSISTENT(config))
|
||||
subtype_add_persistent_ids(st, ids);
|
||||
if (SCOPE_AUTOCONF(config))
|
||||
subtype_add_autoconf_ids(st, ids);
|
||||
|
||||
/* Provide a sorted view. */
|
||||
strlist_sort_unique(ids, st->namespace->qsort_cmp);
|
||||
@@ -683,6 +730,19 @@ static exit_code_t read_device(struct subtype *st, const char *id,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (SCOPE_AUTOCONF(config)) {
|
||||
if (subtype_device_exists_autoconf(st, id))
|
||||
rc = subtype_device_read_autoconf(st, dev, scope);
|
||||
else if (defined) {
|
||||
/* Need to copy detected settings to autoconf
|
||||
* config. */
|
||||
setting_list_merge(dev->autoconf.settings,
|
||||
dev->active.settings, false, false);
|
||||
}
|
||||
if (rc)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (add)
|
||||
device_list_add(st->devices, dev);
|
||||
|
||||
@@ -756,6 +816,25 @@ exit_code_t subtype_write_device(struct subtype *st, struct device *dev,
|
||||
if (!rc)
|
||||
namespace_set_modified(dev->subtype->namespace);
|
||||
}
|
||||
if (SCOPE_AUTOCONF(config)) {
|
||||
if (dev->autoconf.deconfigured) {
|
||||
/* Deconfigure device. */
|
||||
if (dev->autoconf.exists) {
|
||||
rc = subtype_device_deconfigure_autoconf(st,
|
||||
dev);
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
} else if (dev->autoconf.exists) {
|
||||
/* Configure device. */
|
||||
rc = subtype_device_configure_autoconf(st, dev);
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
if (!rc)
|
||||
namespace_set_modified(dev->subtype->namespace);
|
||||
}
|
||||
|
||||
|
||||
return EXIT_OK;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "udev.h"
|
||||
|
||||
int udev_need_settle = 0;
|
||||
int udev_no_settle;
|
||||
|
||||
/* Create a newly allocated udev entry. */
|
||||
static struct udev_entry_node *udev_entry_node_new(const char *key,
|
||||
@@ -359,7 +360,8 @@ static bool get_ids_cb(const char *filename, void *data)
|
||||
|
||||
/* Add the IDs for all devices of the specified subtype name for which a
|
||||
* udev rule exists to strlist LIST. */
|
||||
void udev_get_device_ids(const char *type, struct util_list *list)
|
||||
void udev_get_device_ids(const char *type, struct util_list *list,
|
||||
bool autoconf)
|
||||
{
|
||||
char *path, *prefix;
|
||||
struct util_list *files;
|
||||
@@ -368,7 +370,7 @@ void udev_get_device_ids(const char *type, struct util_list *list)
|
||||
|
||||
prefix = misc_asprintf("%s-%s-", UDEV_PREFIX, type);
|
||||
plen = strlen(prefix);
|
||||
path = path_get_udev_rules();
|
||||
path = path_get_udev_rules(autoconf);
|
||||
files = strlist_new();
|
||||
if (!misc_read_dir(path, files, get_ids_cb, prefix))
|
||||
goto out;
|
||||
@@ -387,12 +389,12 @@ out:
|
||||
}
|
||||
|
||||
/* Remove UDEV rule for device. */
|
||||
exit_code_t udev_remove_rule(const char *type, const char *id)
|
||||
exit_code_t udev_remove_rule(const char *type, const char *id, bool autoconf)
|
||||
{
|
||||
char *path;
|
||||
exit_code_t rc = EXIT_OK;
|
||||
|
||||
path = path_get_udev_rule(type, id);
|
||||
path = path_get_udev_rule(type, id, autoconf);
|
||||
if (util_path_is_reg_file(path))
|
||||
rc = remove_file(path);
|
||||
free(path);
|
||||
@@ -403,5 +405,39 @@ exit_code_t udev_remove_rule(const char *type, const char *id)
|
||||
/* Wait for all current udev events to finish. */
|
||||
void udev_settle(void)
|
||||
{
|
||||
if (udev_no_settle)
|
||||
return;
|
||||
misc_system(err_ignore, "%s settle", PATH_UDEVADM);
|
||||
}
|
||||
|
||||
/* Extract internal attribute settings from @entry and add to @list.
|
||||
* Associate corresponding attribute if found in @attribs. */
|
||||
void udev_add_internal_from_entry(struct setting_list *list,
|
||||
struct udev_entry_node *entry,
|
||||
struct attrib **attribs)
|
||||
{
|
||||
char *copy, *name, *end, *u;
|
||||
struct attrib *a;
|
||||
|
||||
/* ENV{zdev_var}="1" */
|
||||
copy = misc_strdup(entry->key);
|
||||
|
||||
/* Find attribute name start. */
|
||||
name = strchr(copy, '{');
|
||||
end = strrchr(copy, '}');
|
||||
if (!name || !end)
|
||||
goto out;
|
||||
*end = 0;
|
||||
name++;
|
||||
|
||||
/* zdev_ => zdev: */
|
||||
u = strchr(name, '_');
|
||||
if (u)
|
||||
*u = ':';
|
||||
|
||||
a = attrib_find(attribs, name);
|
||||
setting_list_apply_actual(list, a, name, entry->value);
|
||||
|
||||
out:
|
||||
free(copy);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "attrib.h"
|
||||
#include "ccw.h"
|
||||
#include "device.h"
|
||||
#include "internal.h"
|
||||
#include "misc.h"
|
||||
#include "path.h"
|
||||
#include "setting.h"
|
||||
@@ -25,7 +26,7 @@
|
||||
#include "udev_ccw.h"
|
||||
|
||||
/* Check if a udev rule for the specified ccw device exists. */
|
||||
bool udev_ccw_exists(const char *type, const char *id)
|
||||
bool udev_ccw_exists(const char *type, const char *id, bool autoconf)
|
||||
{
|
||||
char *path, *normid;
|
||||
bool rc;
|
||||
@@ -34,7 +35,7 @@ bool udev_ccw_exists(const char *type, const char *id)
|
||||
if (!normid)
|
||||
return false;
|
||||
|
||||
path = path_get_udev_rule(type, normid);
|
||||
path = path_get_udev_rule(type, normid, autoconf);
|
||||
rc = util_path_is_reg_file(path);
|
||||
free(path);
|
||||
free(normid);
|
||||
@@ -49,6 +50,12 @@ static void add_setting_from_entry(struct setting_list *list,
|
||||
char *copy, *name, *end;
|
||||
struct attrib *a;
|
||||
|
||||
/* ENV{zdev_var}="1" */
|
||||
if (starts_with(entry->key, "ENV{zdev_") &&
|
||||
strcmp(entry->op, "=") == 0) {
|
||||
udev_add_internal_from_entry(list, entry, attribs);
|
||||
return;
|
||||
}
|
||||
/* ATTR{[ccw/0.0.37bf]online}=1 */
|
||||
if (strncmp(entry->key, "ATTR{[ccw/", 10) != 0 ||
|
||||
strcmp(entry->op, "=") != 0)
|
||||
@@ -88,15 +95,16 @@ static void udev_file_get_settings(struct udev_file *file,
|
||||
}
|
||||
|
||||
/* Read the persistent configuration of a CCW device from a udev rule. */
|
||||
exit_code_t udev_ccw_read_device(struct device *dev)
|
||||
exit_code_t udev_ccw_read_device(struct device *dev, bool autoconf)
|
||||
{
|
||||
struct subtype *st = dev->subtype;
|
||||
struct device_state *state = &dev->persistent;
|
||||
struct device_state *state = autoconf ? &dev->autoconf :
|
||||
&dev->persistent;
|
||||
struct udev_file *file = NULL;
|
||||
exit_code_t rc;
|
||||
char *path;
|
||||
|
||||
path = path_get_udev_rule(st->name, dev->id);
|
||||
path = path_get_udev_rule(st->name, dev->id, autoconf);
|
||||
rc = udev_read_file(path, &file);
|
||||
if (rc)
|
||||
goto out;
|
||||
@@ -128,12 +136,13 @@ static char *get_label_id(const char *prefix, const char *type,
|
||||
}
|
||||
|
||||
/* Write the persistent configuration of a CCW device to a udev rule. */
|
||||
exit_code_t udev_ccw_write_device(struct device *dev)
|
||||
exit_code_t udev_ccw_write_device(struct device *dev, bool autoconf)
|
||||
{
|
||||
struct subtype *st = dev->subtype;
|
||||
struct ccw_subtype_data *data = st->data;
|
||||
const char *type = st->name, *drv = data->ccwdrv, *id = dev->id;
|
||||
struct device_state *state = &dev->persistent;
|
||||
struct device_state *state = autoconf ? &dev->autoconf :
|
||||
&dev->persistent;
|
||||
char *path, *cfg_label = NULL, *end_label = NULL;
|
||||
struct util_list *list;
|
||||
struct ptrlist_node *p;
|
||||
@@ -142,7 +151,7 @@ exit_code_t udev_ccw_write_device(struct device *dev)
|
||||
FILE *fd;
|
||||
|
||||
if (!state->exists)
|
||||
return udev_remove_rule(type, id);
|
||||
return udev_remove_rule(type, id, autoconf);
|
||||
|
||||
cfg_label = get_label_id("cfg", type, id);
|
||||
end_label = get_label_id("end", type, id);
|
||||
@@ -150,7 +159,7 @@ exit_code_t udev_ccw_write_device(struct device *dev)
|
||||
/* Apply attributes in correct order. */
|
||||
list = setting_list_get_sorted(state->settings);
|
||||
|
||||
path = path_get_udev_rule(type, id);
|
||||
path = path_get_udev_rule(type, id, autoconf);
|
||||
debug("Writing %s udev rule file %s\n", type, path);
|
||||
if (!util_path_exists(path)) {
|
||||
rc = path_create(path);
|
||||
@@ -188,7 +197,14 @@ exit_code_t udev_ccw_write_device(struct device *dev)
|
||||
s = p->ptr;
|
||||
if (s->removed)
|
||||
continue;
|
||||
fprintf(fd, "ATTR{[ccw/%s]%s}=\"%s\"\n", id, s->name, s->value);
|
||||
if ((s->attrib && s->attrib->internal) ||
|
||||
internal_by_name(s->name)) {
|
||||
fprintf(fd, "ENV{zdev_%s}=\"%s\"\n",
|
||||
internal_get_name(s->name), s->value);
|
||||
} else {
|
||||
fprintf(fd, "ATTR{[ccw/%s]%s}=\"%s\"\n", id, s->name,
|
||||
s->value);
|
||||
}
|
||||
}
|
||||
|
||||
/* Write udev rule epilog. */
|
||||
@@ -234,14 +250,18 @@ out:
|
||||
}
|
||||
|
||||
/* Write a udev rule to free devices from the cio-ignore blacklist. */
|
||||
exit_code_t udev_ccw_write_cio_ignore(const char *id_list)
|
||||
exit_code_t udev_ccw_write_cio_ignore(const char *id_list, bool autoconf)
|
||||
{
|
||||
char *path, *curr = NULL;
|
||||
char *path, *prefix, *curr = NULL;
|
||||
FILE *fd;
|
||||
exit_code_t rc = EXIT_OK;
|
||||
|
||||
/* Ensure that autoconf version of cio-ignore is not masked
|
||||
* by normal one. */
|
||||
prefix = autoconf ? "cio-ignore-autoconf" : "cio-ignore";
|
||||
|
||||
/* Create file. */
|
||||
path = path_get_udev_rule("cio-ignore", NULL);
|
||||
path = path_get_udev_rule(prefix, NULL, autoconf);
|
||||
|
||||
if (!*id_list) {
|
||||
/* Empty id_list string - remove file. */
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "attrib.h"
|
||||
#include "ccwgroup.h"
|
||||
#include "device.h"
|
||||
#include "internal.h"
|
||||
#include "misc.h"
|
||||
#include "path.h"
|
||||
#include "setting.h"
|
||||
@@ -25,34 +26,34 @@
|
||||
#include "udev_ccwgroup.h"
|
||||
|
||||
static char *get_rule_path_by_devid(const char *type,
|
||||
struct ccwgroup_devid *devid)
|
||||
struct ccwgroup_devid *devid, bool autoconf)
|
||||
{
|
||||
char *ccw_id, *path;
|
||||
|
||||
ccw_id = ccw_devid_to_str(&devid->devid[0]);
|
||||
path = path_get_udev_rule(type, ccw_id);
|
||||
path = path_get_udev_rule(type, ccw_id, autoconf);
|
||||
free(ccw_id);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
static char *get_rule_path(const char *type, const char *id)
|
||||
static char *get_rule_path(const char *type, const char *id, bool autoconf)
|
||||
{
|
||||
struct ccwgroup_devid devid;
|
||||
|
||||
if (ccwgroup_parse_devid(&devid, id, err_ignore) != EXIT_OK)
|
||||
return NULL;
|
||||
|
||||
return get_rule_path_by_devid(type, &devid);
|
||||
return get_rule_path_by_devid(type, &devid, autoconf);
|
||||
}
|
||||
|
||||
/* Check if a udev rule for the specified CCWGROUP device exists. */
|
||||
bool udev_ccwgroup_exists(const char *type, const char *id)
|
||||
bool udev_ccwgroup_exists(const char *type, const char *id, bool autoconf)
|
||||
{
|
||||
char *path;
|
||||
bool rc;
|
||||
|
||||
path = get_rule_path(type, id);
|
||||
path = get_rule_path(type, id, autoconf);
|
||||
if (!path)
|
||||
return false;
|
||||
rc = util_path_is_reg_file(path);
|
||||
@@ -68,6 +69,12 @@ static void add_setting_from_entry(struct setting_list *list,
|
||||
char *copy, *name, *end;
|
||||
struct attrib *a;
|
||||
|
||||
/* ENV{zdev_var}="1" */
|
||||
if (starts_with(entry->key, "ENV{zdev_") &&
|
||||
strcmp(entry->op, "=") == 0) {
|
||||
udev_add_internal_from_entry(list, entry, attribs);
|
||||
return;
|
||||
}
|
||||
/* ATTR{[ccwgroup/0.0.f5f0]online}=1 */
|
||||
if (strncmp(entry->key, "ATTR{[ccwgroup/", 10) != 0 ||
|
||||
strcmp(entry->op, "=") != 0)
|
||||
@@ -143,15 +150,16 @@ static void expand_id(struct device *dev, struct udev_file *file)
|
||||
}
|
||||
|
||||
/* Read the persistent configuration of a CCWGROUP device from a udev rule. */
|
||||
exit_code_t udev_ccwgroup_read_device(struct device *dev)
|
||||
exit_code_t udev_ccwgroup_read_device(struct device *dev, bool autoconf)
|
||||
{
|
||||
struct subtype *st = dev->subtype;
|
||||
struct device_state *state = &dev->persistent;
|
||||
struct device_state *state = autoconf ? &dev->autoconf :
|
||||
&dev->persistent;
|
||||
struct udev_file *file = NULL;
|
||||
exit_code_t rc;
|
||||
char *path;
|
||||
|
||||
path = get_rule_path_by_devid(st->name, dev->devid);
|
||||
path = get_rule_path_by_devid(st->name, dev->devid, autoconf);
|
||||
rc = udev_read_file(path, &file);
|
||||
if (rc)
|
||||
goto out;
|
||||
@@ -184,9 +192,11 @@ static char *get_label_id(const char *prefix, const char *type,
|
||||
}
|
||||
|
||||
/* Write the persistent configuration of a CCWGROUP device to a udev rule. */
|
||||
exit_code_t udev_ccwgroup_write_device(struct device *dev)
|
||||
exit_code_t udev_ccwgroup_write_device(struct device *dev, bool autoconf)
|
||||
{
|
||||
struct subtype *st = dev->subtype;
|
||||
struct device_state *state = autoconf ? &dev->autoconf :
|
||||
&dev->persistent;
|
||||
struct ccwgroup_subtype_data *data = st->data;
|
||||
const char *type = st->name, *drv = data->ccwgroupdrv, *id = dev->id;
|
||||
struct ccwgroup_devid devid;
|
||||
@@ -200,21 +210,21 @@ exit_code_t udev_ccwgroup_write_device(struct device *dev)
|
||||
FILE *fd;
|
||||
unsigned int i;
|
||||
|
||||
if (!dev->persistent.exists)
|
||||
return udev_ccwgroup_remove_rule(type, id);
|
||||
if (!state->exists)
|
||||
return udev_ccwgroup_remove_rule(type, id, autoconf);
|
||||
|
||||
if (ccwgroup_parse_devid(&devid, id, err_ignore) != EXIT_OK)
|
||||
return EXIT_INVALID_ID;
|
||||
|
||||
ccw_id = ccw_devid_to_str(&devid.devid[0]);
|
||||
path = get_rule_path(type, ccw_id);
|
||||
path = get_rule_path(type, ccw_id, autoconf);
|
||||
|
||||
group_label = get_label_id("group", type, ccw_id);
|
||||
cfg_label = get_label_id("cfg", type, ccw_id);
|
||||
end_label = get_label_id("end", type, ccw_id);
|
||||
|
||||
/* Apply attributes in correct order. */
|
||||
list = setting_list_get_sorted(dev->persistent.settings);
|
||||
list = setting_list_get_sorted(state->settings);
|
||||
|
||||
debug("Writing %s udev rule file %s\n", type, path);
|
||||
if (!util_path_exists(path)) {
|
||||
@@ -279,6 +289,10 @@ exit_code_t udev_ccwgroup_write_device(struct device *dev)
|
||||
fprintf(fd, "ATTR{[ccwgroup/%s]%s}=\"%s\"\n",
|
||||
ccw_id, s->name, str->str);
|
||||
}
|
||||
} else if ((s->attrib && s->attrib->internal) ||
|
||||
internal_by_name(s->name)) {
|
||||
fprintf(fd, "ENV{zdev_%s}=\"%s\"\n",
|
||||
internal_get_name(s->name), s->value);
|
||||
} else {
|
||||
fprintf(fd, "ATTR{[ccwgroup/%s]%s}=\"%s\"\n", ccw_id,
|
||||
s->name, s->value);
|
||||
@@ -357,12 +371,13 @@ static exit_code_t get_ids_cb(const char *path, const char *filename,
|
||||
|
||||
/* Add the IDs for all devices of the specified subtype name for which a
|
||||
* udev rule exists to strlist LIST. */
|
||||
void udev_ccwgroup_add_device_ids(const char *type, struct util_list *list)
|
||||
void udev_ccwgroup_add_device_ids(const char *type, struct util_list *list,
|
||||
bool autoconf)
|
||||
{
|
||||
struct get_ids_cb_data cb_data;
|
||||
char *path;
|
||||
|
||||
path = path_get_udev_rules();
|
||||
path = path_get_udev_rules(autoconf);
|
||||
cb_data.prefix = misc_asprintf("%s-%s-", UDEV_PREFIX, type);
|
||||
cb_data.ids = list;
|
||||
|
||||
@@ -374,7 +389,8 @@ void udev_ccwgroup_add_device_ids(const char *type, struct util_list *list)
|
||||
}
|
||||
|
||||
/* Remove UDEV rule for CCWGROUP device. */
|
||||
exit_code_t udev_ccwgroup_remove_rule(const char *type, const char *id)
|
||||
exit_code_t udev_ccwgroup_remove_rule(const char *type, const char *id,
|
||||
bool autoconf)
|
||||
{
|
||||
char *partial_id, *path;
|
||||
exit_code_t rc = EXIT_OK;
|
||||
@@ -383,7 +399,7 @@ exit_code_t udev_ccwgroup_remove_rule(const char *type, const char *id)
|
||||
if (!partial_id)
|
||||
return EXIT_INVALID_ID;
|
||||
|
||||
path = path_get_udev_rule(type, partial_id);
|
||||
path = path_get_udev_rule(type, partial_id, autoconf);
|
||||
if (util_path_is_reg_file(path))
|
||||
rc = remove_file(path);
|
||||
free(path);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "attrib.h"
|
||||
#include "device.h"
|
||||
#include "internal.h"
|
||||
#include "misc.h"
|
||||
#include "path.h"
|
||||
#include "scsi.h"
|
||||
@@ -128,7 +129,7 @@ static bool zfcp_lun_devid_from_entry(struct zfcp_lun_devid *id_ptr,
|
||||
struct udev_entry_node *entry)
|
||||
{
|
||||
struct zfcp_lun_devid id;
|
||||
char *copy = NULL, *s;
|
||||
char *copy = NULL, *s, *e, *u;
|
||||
int i;
|
||||
bool rc = false;
|
||||
|
||||
@@ -182,6 +183,28 @@ static bool zfcp_lun_devid_from_entry(struct zfcp_lun_devid *id_ptr,
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*ENV{zdev_var__0_0_1941_0x500507630510c1ae_0x402340d400000000}="1"*/
|
||||
if (starts_with(entry->key, "ENV{zdev_")) {
|
||||
copy = misc_strdup(entry->key);
|
||||
|
||||
/* Find ID start (last __) and end (last }). */
|
||||
s = misc_strrstr(copy, "__");
|
||||
e = strrchr(copy, '}');
|
||||
if (!s || !e)
|
||||
goto out;
|
||||
*e = 0;
|
||||
s += 2;
|
||||
/* Convert variable name to ID format. */
|
||||
for (i = 0, u = s; (u = strchr(u, '_')); i++, u++) {
|
||||
if (i < 2)
|
||||
*u = '.';
|
||||
else
|
||||
*u = ':';
|
||||
}
|
||||
rc = zfcp_lun_parse_devid(&id, s, err_ignore) == EXIT_OK ?
|
||||
true : false;
|
||||
}
|
||||
|
||||
out:
|
||||
free(copy);
|
||||
if (rc)
|
||||
@@ -211,11 +234,46 @@ static struct zfcp_lun_node *zfcp_lun_node_from_entry(
|
||||
return node;
|
||||
}
|
||||
|
||||
static void add_internal_setting_from_entry(struct udev_entry_node *entry,
|
||||
struct zfcp_lun_node *node)
|
||||
{
|
||||
char *copy, *name, *end, *u;
|
||||
struct attrib *a;
|
||||
|
||||
/*ENV{zdev_var__0_0_1941_0x500507630510c1ae_0x402340d400000000}="1"*/
|
||||
copy = misc_strdup(entry->key);
|
||||
|
||||
/* Find attribute name start and end. */
|
||||
name = strchr(copy, '{');
|
||||
end = misc_strrstr(copy, "__");
|
||||
if (!name || !end)
|
||||
goto out;
|
||||
*end = 0;
|
||||
name++;
|
||||
|
||||
/* zdev_ => zdev: */
|
||||
u = strchr(name, '_');
|
||||
if (u)
|
||||
*u = ':';
|
||||
|
||||
a = attrib_find(zfcp_lun_subtype.dev_attribs, name);
|
||||
setting_list_apply_actual(node->fc_settings, a, name, entry->value);
|
||||
|
||||
out:
|
||||
free(copy);
|
||||
}
|
||||
|
||||
static void add_fc_setting_from_entry(struct udev_entry_node *entry,
|
||||
struct zfcp_lun_node *node)
|
||||
{
|
||||
char *copy, *s, *e;
|
||||
|
||||
/*ENV{zdev_var__0_0_1941_0x500507630510c1ae_0x402340d400000000}="1"*/
|
||||
if (starts_with(entry->key, "ENV{zdev_") &&
|
||||
strcmp(entry->op, "=") == 0) {
|
||||
add_internal_setting_from_entry(entry, node);
|
||||
return;
|
||||
}
|
||||
/*ATTR{[ccw/0.0.1941]0x500507630510c1ae/0x402340d400000000/failed}="0"*/
|
||||
if (!starts_with(entry->key, "ATTR{[ccw/"))
|
||||
return;
|
||||
@@ -369,14 +427,14 @@ static exit_code_t lun_cb(const char *path, const char *name, void *data)
|
||||
|
||||
/* Add the IDs for all zfcp lun devices for which a configuration exists to
|
||||
* LIST. */
|
||||
void udev_zfcp_lun_add_device_ids(struct util_list *list)
|
||||
void udev_zfcp_lun_add_device_ids(struct util_list *list, bool autoconf)
|
||||
{
|
||||
struct lun_cb_data cb_data;
|
||||
char *path;
|
||||
|
||||
cb_data.prefix = misc_asprintf("%s-%s-", UDEV_PREFIX, ZFCP_LUN_NAME);
|
||||
cb_data.list = list;
|
||||
path = path_get_udev_rules();
|
||||
path = path_get_udev_rules(autoconf);
|
||||
|
||||
if (util_path_is_dir(path))
|
||||
path_for_each(path, lun_cb, &cb_data);
|
||||
@@ -385,7 +443,9 @@ void udev_zfcp_lun_add_device_ids(struct util_list *list)
|
||||
free(cb_data.prefix);
|
||||
}
|
||||
|
||||
static char *get_zfcp_lun_path(const char *id)
|
||||
/* Return path to zfcp lun udev rule file containing configuration data for
|
||||
* all LUNs of a zfcp device. */
|
||||
static char *get_zfcp_lun_path(const char *id, bool autoconf)
|
||||
{
|
||||
char *copy, *e, *path;
|
||||
|
||||
@@ -393,12 +453,19 @@ static char *get_zfcp_lun_path(const char *id)
|
||||
e = strchr(copy, ':');
|
||||
if (e)
|
||||
*e = 0;
|
||||
path = path_get_udev_rule(ZFCP_LUN_NAME, copy);
|
||||
path = path_get_udev_rule(ZFCP_LUN_NAME, copy, autoconf);
|
||||
free(copy);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
/* Return path to zfcp lun udev rule file containing configuration data for
|
||||
* a single LUN. */
|
||||
static char *get_single_zfcp_lun_path(const char *id, bool autoconf)
|
||||
{
|
||||
return path_get_udev_rule(ZFCP_LUN_NAME, id, autoconf);
|
||||
}
|
||||
|
||||
/* Apply the settings found in NODE to STATE. */
|
||||
static void zfcp_lun_node_to_state(struct zfcp_lun_node *node,
|
||||
struct attrib **attribs,
|
||||
@@ -428,16 +495,22 @@ static void zfcp_lun_node_to_state(struct zfcp_lun_node *node,
|
||||
}
|
||||
|
||||
/* Read the persistent configuration of a zfcp lun from a udev rule. */
|
||||
exit_code_t udev_zfcp_lun_read_device(struct device *dev)
|
||||
exit_code_t udev_zfcp_lun_read_device(struct device *dev, bool autoconf)
|
||||
{
|
||||
struct subtype *st = dev->subtype;
|
||||
struct device_state *state = &dev->persistent;
|
||||
struct device_state *state = autoconf ? &dev->autoconf :
|
||||
&dev->persistent;
|
||||
struct util_list *luns;
|
||||
struct zfcp_lun_node *node;
|
||||
exit_code_t rc = EXIT_OK;
|
||||
char *path;
|
||||
|
||||
path = get_zfcp_lun_path(dev->id);
|
||||
/* Check for single lun file first then try multi lun file. */
|
||||
path = get_single_zfcp_lun_path(dev->id, autoconf);
|
||||
if (!util_path_exists(path)) {
|
||||
free(path);
|
||||
path = get_zfcp_lun_path(dev->id, autoconf);
|
||||
}
|
||||
|
||||
/* Get previous rule data. */
|
||||
luns = zfcp_lun_node_list_new();
|
||||
@@ -475,7 +548,7 @@ static struct zfcp_lun_node *state_to_zfcp_lun_node(struct zfcp_lun_devid *id,
|
||||
s->value);
|
||||
setting_list_add(node->scsi_settings, n);
|
||||
} else {
|
||||
n = setting_new(NULL, s->name, s->value);
|
||||
n = setting_new(s->attrib, s->name, s->value);
|
||||
setting_list_add(node->fc_settings, n);
|
||||
}
|
||||
}
|
||||
@@ -565,9 +638,21 @@ static exit_code_t write_luns_rule(const char *path, struct util_list *list)
|
||||
node->id.lun);
|
||||
|
||||
util_list_iterate(&node->fc_settings->list, s) {
|
||||
fprintf(fd, "ATTR{[ccw/%s]0x%016" PRIx64 "/0x%016"
|
||||
PRIx64 "/%s}=\"%s\"\n", hba_id, node->id.wwpn,
|
||||
node->id.lun, s->name, s->value);
|
||||
if ((s->attrib && s->attrib->internal) ||
|
||||
internal_by_name(s->name)) {
|
||||
fprintf(fd, "ENV{zdev_%s__%x_%x_%04x_0x%016"
|
||||
PRIx64 "_0x%016" PRIx64 "}=\"%s\"\n",
|
||||
internal_get_name(s->name),
|
||||
node->id.fcp_dev.cssid,
|
||||
node->id.fcp_dev.ssid,
|
||||
node->id.fcp_dev.devno, node->id.wwpn,
|
||||
node->id.lun, s->value);
|
||||
} else {
|
||||
fprintf(fd, "ATTR{[ccw/%s]0x%016" PRIx64
|
||||
"/0x%016" PRIx64 "/%s}=\"%s\"\n",
|
||||
hba_id, node->id.wwpn, node->id.lun,
|
||||
s->name, s->value);
|
||||
}
|
||||
}
|
||||
last_node = node;
|
||||
}
|
||||
@@ -599,8 +684,10 @@ out:
|
||||
|
||||
/* Update the udev rule file that configures the zfcp lun with the specified
|
||||
* ID. If @state is %NULL, remove the rule, otherwise create a rule that
|
||||
* applies the corresponding parameters. */
|
||||
static exit_code_t update_lun_rule(const char *id, struct device_state *state)
|
||||
* applies the corresponding parameters. If @single is set, update a single
|
||||
* lun rule file, otherwise update a multi lun rule file. */
|
||||
static exit_code_t update_lun_rule(const char *id, struct device_state *state,
|
||||
bool single, bool autoconf)
|
||||
{
|
||||
struct zfcp_lun_devid devid;
|
||||
struct util_list *luns;
|
||||
@@ -612,7 +699,8 @@ static exit_code_t update_lun_rule(const char *id, struct device_state *state)
|
||||
rc = zfcp_lun_parse_devid(&devid, id, err_delayed_print);
|
||||
if (rc)
|
||||
return rc;
|
||||
path = get_zfcp_lun_path(id);
|
||||
path = single ? get_single_zfcp_lun_path(id, autoconf) :
|
||||
get_zfcp_lun_path(id, autoconf);
|
||||
|
||||
/* Get previous rule data. */
|
||||
luns = zfcp_lun_node_list_new();
|
||||
@@ -648,27 +736,55 @@ static exit_code_t update_lun_rule(const char *id, struct device_state *state)
|
||||
|
||||
/* Write a udev-rule to configure the specified zfcp lun and associated
|
||||
* device state. */
|
||||
exit_code_t udev_zfcp_lun_write_device(struct device *dev)
|
||||
exit_code_t udev_zfcp_lun_write_device(struct device *dev, bool autoconf)
|
||||
{
|
||||
return update_lun_rule(dev->id, &dev->persistent);
|
||||
exit_code_t rc;
|
||||
struct device_state *state = autoconf ? &dev->autoconf :
|
||||
&dev->persistent;
|
||||
|
||||
rc = update_lun_rule(dev->id, state, true, autoconf);
|
||||
|
||||
/* We only want single lun rule files so remove any remaining
|
||||
* references in multi lun rule files. */
|
||||
update_lun_rule(dev->id, NULL, false, autoconf);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Remove the UDEV rule used to configure the zfcp lun with the specified ID. */
|
||||
exit_code_t udev_zfcp_lun_remove_rule(const char *id)
|
||||
exit_code_t udev_zfcp_lun_remove_rule(const char *id, bool autoconf)
|
||||
{
|
||||
return update_lun_rule(id, NULL);
|
||||
exit_code_t rc, rc2;
|
||||
|
||||
rc = update_lun_rule(id, NULL, true, autoconf);
|
||||
rc2 = update_lun_rule(id, NULL, false, autoconf);
|
||||
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
return rc2;
|
||||
}
|
||||
|
||||
/* Determine if a udev rule exists for configuring the specified zfcp lun. */
|
||||
bool udev_zfcp_lun_exists(const char *id)
|
||||
bool udev_zfcp_lun_exists(const char *id, bool autoconf)
|
||||
{
|
||||
struct zfcp_lun_devid devid;
|
||||
char *path, *rule, *pattern = NULL;
|
||||
char *path, *rule = NULL, *pattern = NULL;
|
||||
bool rc = false;
|
||||
|
||||
if (zfcp_lun_parse_devid(&devid, id, err_ignore) != EXIT_OK)
|
||||
return false;
|
||||
path = get_zfcp_lun_path(id);
|
||||
|
||||
/* Check for single lun rule file first. */
|
||||
path = get_single_zfcp_lun_path(id, autoconf);
|
||||
if (util_path_exists(path)) {
|
||||
rc = true;
|
||||
goto out;
|
||||
}
|
||||
free(path);
|
||||
|
||||
/* Check multi lun rule file next. */
|
||||
path = get_zfcp_lun_path(id, autoconf);
|
||||
rule = misc_read_text_file(path, 1, err_ignore);
|
||||
if (!rule)
|
||||
goto out;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "ccw.h"
|
||||
#include "device.h"
|
||||
#include "devtype.h"
|
||||
#include "internal.h"
|
||||
#include "misc.h"
|
||||
#include "path.h"
|
||||
#include "setting.h"
|
||||
@@ -247,6 +248,7 @@ struct subtype zfcp_host_subtype = {
|
||||
&zfcp_host_attr_failed,
|
||||
&zfcp_host_attr_port_remove,
|
||||
&zfcp_host_attr_port_rescan,
|
||||
&internal_attr_early,
|
||||
),
|
||||
.unknown_dev_attribs = 1,
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "devnode.h"
|
||||
#include "devtype.h"
|
||||
#include "misc.h"
|
||||
#include "internal.h"
|
||||
#include "namespace.h"
|
||||
#include "path.h"
|
||||
#include "scsi.h"
|
||||
@@ -467,7 +468,14 @@ static exit_code_t zfcp_lun_st_read_persistent(struct subtype *st,
|
||||
struct device *dev,
|
||||
read_scope_t scope)
|
||||
{
|
||||
return udev_zfcp_lun_read_device(dev);
|
||||
return udev_zfcp_lun_read_device(dev, false);
|
||||
}
|
||||
|
||||
static exit_code_t zfcp_lun_st_read_autoconf(struct subtype *st,
|
||||
struct device *dev,
|
||||
read_scope_t scope)
|
||||
{
|
||||
return udev_zfcp_lun_read_device(dev, true);
|
||||
}
|
||||
|
||||
static exit_code_t zfcp_lun_add(struct device *dev)
|
||||
@@ -564,7 +572,13 @@ static exit_code_t zfcp_lun_st_configure_active(struct subtype *st,
|
||||
static exit_code_t zfcp_lun_st_configure_persistent(struct subtype *st,
|
||||
struct device *dev)
|
||||
{
|
||||
return udev_zfcp_lun_write_device(dev);
|
||||
return udev_zfcp_lun_write_device(dev, false);
|
||||
}
|
||||
|
||||
static exit_code_t zfcp_lun_st_configure_autoconf(struct subtype *st,
|
||||
struct device *dev)
|
||||
{
|
||||
return udev_zfcp_lun_write_device(dev, true);
|
||||
}
|
||||
|
||||
static exit_code_t zfcp_lun_st_deconfigure_active(struct subtype *st,
|
||||
@@ -578,7 +592,13 @@ static exit_code_t zfcp_lun_st_deconfigure_active(struct subtype *st,
|
||||
static exit_code_t zfcp_lun_st_deconfigure_persistent(struct subtype *st,
|
||||
struct device *dev)
|
||||
{
|
||||
return udev_zfcp_lun_remove_rule(dev->id);
|
||||
return udev_zfcp_lun_remove_rule(dev->id, false);
|
||||
}
|
||||
|
||||
static exit_code_t zfcp_lun_st_deconfigure_autoconf(struct subtype *st,
|
||||
struct device *dev)
|
||||
{
|
||||
return udev_zfcp_lun_remove_rule(dev->id, true);
|
||||
}
|
||||
|
||||
static exit_code_t check_npiv(struct subtype *st, struct device *dev,
|
||||
@@ -606,7 +626,8 @@ static exit_code_t check_npiv(struct subtype *st, struct device *dev,
|
||||
if (!allow_lun_scan)
|
||||
goto out;
|
||||
|
||||
if (!(dev->active.deconfigured || dev->persistent.deconfigured)) {
|
||||
if (!(dev->active.deconfigured || dev->persistent.deconfigured ||
|
||||
dev->autoconf.deconfigured)) {
|
||||
delayed_info("Note: Auto LUN scan enabled - manual LUN "
|
||||
"configuration is redundant for %s %s\n",
|
||||
zfcp_host_subtype.devname, fcp_dev_id);
|
||||
@@ -643,7 +664,8 @@ static exit_code_t zfcp_lun_st_check_post_configure(struct subtype *st,
|
||||
|
||||
/* Don't show note when an attribute was modified. */
|
||||
if (setting_list_modified(dev->active.settings) ||
|
||||
setting_list_modified(dev->persistent.settings))
|
||||
setting_list_modified(dev->persistent.settings) ||
|
||||
setting_list_modified(dev->autoconf.settings))
|
||||
return EXIT_OK;
|
||||
|
||||
/* Check for NPIV but don't route exit code to caller - we only
|
||||
@@ -795,7 +817,12 @@ static bool zfcp_lun_st_exists_active(struct subtype *st, const char *id)
|
||||
|
||||
static bool zfcp_lun_st_exists_persistent(struct subtype *st, const char *id)
|
||||
{
|
||||
return udev_zfcp_lun_exists(id);
|
||||
return udev_zfcp_lun_exists(id, false);
|
||||
}
|
||||
|
||||
static bool zfcp_lun_st_exists_autoconf(struct subtype *st, const char *id)
|
||||
{
|
||||
return udev_zfcp_lun_exists(id, true);
|
||||
}
|
||||
|
||||
static exit_code_t zfcp_lun_st_is_definable(struct subtype *st, const char *id,
|
||||
@@ -889,7 +916,13 @@ static void zfcp_lun_st_add_active_ids(struct subtype *st,
|
||||
static void zfcp_lun_st_add_persistent_ids(struct subtype *st,
|
||||
struct util_list *ids)
|
||||
{
|
||||
udev_zfcp_lun_add_device_ids(ids);
|
||||
udev_zfcp_lun_add_device_ids(ids, false);
|
||||
}
|
||||
|
||||
static void zfcp_lun_st_add_autoconf_ids(struct subtype *st,
|
||||
struct util_list *ids)
|
||||
{
|
||||
udev_zfcp_lun_add_device_ids(ids, true);
|
||||
}
|
||||
|
||||
static exit_code_t add_sg_cb(const char *path, const char *filename, void *data)
|
||||
@@ -1065,6 +1098,7 @@ struct subtype zfcp_lun_subtype = {
|
||||
&zfcp_lun_attr_scsi_timeout,
|
||||
&zfcp_lun_attr_scsi_state,
|
||||
&zfcp_lun_attr_scsi_delete,
|
||||
&internal_attr_early,
|
||||
),
|
||||
.prefixes = STRING_ARRAY(SCSI_ATTR_PREFIX),
|
||||
.unknown_dev_attribs = 1,
|
||||
@@ -1072,18 +1106,23 @@ struct subtype zfcp_lun_subtype = {
|
||||
|
||||
.exists_active = &zfcp_lun_st_exists_active,
|
||||
.exists_persistent = &zfcp_lun_st_exists_persistent,
|
||||
.exists_autoconf = &zfcp_lun_st_exists_autoconf,
|
||||
|
||||
.add_active_ids = &zfcp_lun_st_add_active_ids,
|
||||
.add_persistent_ids = &zfcp_lun_st_add_persistent_ids,
|
||||
.add_autoconf_ids = &zfcp_lun_st_add_autoconf_ids,
|
||||
|
||||
.read_active = &zfcp_lun_st_read_active,
|
||||
.read_persistent = &zfcp_lun_st_read_persistent,
|
||||
.read_autoconf = &zfcp_lun_st_read_autoconf,
|
||||
|
||||
.configure_active = &zfcp_lun_st_configure_active,
|
||||
.configure_persistent = &zfcp_lun_st_configure_persistent,
|
||||
.configure_autoconf = &zfcp_lun_st_configure_autoconf,
|
||||
|
||||
.deconfigure_active = &zfcp_lun_st_deconfigure_active,
|
||||
.deconfigure_persistent = &zfcp_lun_st_deconfigure_persistent,
|
||||
.deconfigure_autoconf = &zfcp_lun_st_deconfigure_autoconf,
|
||||
|
||||
.check_pre_configure = &zfcp_lun_st_check_pre_configure,
|
||||
.check_post_configure = &zfcp_lun_st_check_post_configure,
|
||||
|
||||
@@ -41,12 +41,16 @@ all: check_dep_fuse check_dep_zlib zgetdump
|
||||
|
||||
OBJECTS = zgetdump.o opts.o zg.o \
|
||||
dfi.o dfi_vmcoreinfo.o \
|
||||
dfi_lkcd.o dfi_elf.o dfi_s390.o dfi_s390mv.o dfi_s390tape.o \
|
||||
dfi_kdump.o dfi_devmem.o \
|
||||
dfo.o dfo_elf.o dfo_s390.o \
|
||||
dfi_lkcd.o dfi_elf.o \
|
||||
dfi_s390.o dfi_s390_ext.o\
|
||||
dfi_s390mv.o dfi_s390mv_ext.o \
|
||||
dfi_s390tape.o dfi_kdump.o \
|
||||
dfi_devmem.o dfo.o \
|
||||
dfo_elf.o dfo_s390.o \
|
||||
df_s390.o \
|
||||
dt.o dt_s390sv.o dt_s390mv.o dt_scsi.o \
|
||||
stdout.o
|
||||
dt.o dt_s390sv.o dt_s390sv_ext.o \
|
||||
dt_s390mv.o dt_s390mv_ext.o \
|
||||
dt_scsi.o stdout.o \
|
||||
|
||||
ifeq ("$(HAVE_FUSE)","0")
|
||||
FUSE_CFLAGS = -DHAVE_FUSE=0 -D_FILE_OFFSET_BITS=64
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* S390 dump format common functions
|
||||
*
|
||||
* Copyright IBM Corp. 2001, 2017
|
||||
* 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.
|
||||
@@ -41,7 +41,7 @@ void df_s390_cpu_info_add(struct df_s390_hdr *hdr, u64 addr_max)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (hdr->version < 5) {
|
||||
if (hdr->version < 5 && hdr->magic == DF_S390_MAGIC) {
|
||||
/* No Prefix registers in header */
|
||||
hdr->cpu_cnt = 0;
|
||||
dfi_cpu_info_init(DFI_CPU_CONTENT_NONE);
|
||||
@@ -85,11 +85,14 @@ void df_s390_hdr_add(struct df_s390_hdr *hdr)
|
||||
dfi_arch_set(df_s390_to_dfi_arch(hdr->arch));
|
||||
if (hdr->cpu_id)
|
||||
dfi_attr_cpu_id_set(hdr->cpu_id);
|
||||
if (hdr->version >= 3 && hdr->mem_size_real)
|
||||
dfi_attr_mem_size_real_set(hdr->mem_size_real);
|
||||
if (hdr->version >= 2 && hdr->build_arch)
|
||||
if ((hdr->version >= 2 || hdr->magic == DF_S390_MAGIC_EXT) &&
|
||||
hdr->build_arch)
|
||||
dfi_attr_build_arch_set(df_s390_to_dfi_arch(hdr->build_arch));
|
||||
if (hdr->version >= 5 && hdr->real_cpu_cnt)
|
||||
if ((hdr->version >= 3 || hdr->magic == DF_S390_MAGIC_EXT) &&
|
||||
hdr->mem_size_real)
|
||||
dfi_attr_mem_size_real_set(hdr->mem_size_real);
|
||||
if ((hdr->version >= 5 || hdr->magic == DF_S390_MAGIC_EXT) &&
|
||||
hdr->real_cpu_cnt)
|
||||
dfi_attr_real_cpu_cnt_set(hdr->real_cpu_cnt);
|
||||
}
|
||||
|
||||
@@ -124,8 +127,38 @@ int df_s390_em_verify(struct df_s390_em *em, struct df_s390_hdr *hdr)
|
||||
void df_s390_dumper_read(struct zg_fh *fh, int blk_size,
|
||||
struct df_s390_dumper *dumper)
|
||||
{
|
||||
int offset = DF_S390_MAGIC_BLK_ECKD * blk_size;
|
||||
int bytes_to_read, offset = DF_S390_MAGIC_BLK_ECKD * blk_size;
|
||||
|
||||
/*
|
||||
* First read 3 fields at the start of the dumper. The magic number,
|
||||
* version and one extra field for the old dumper case (no magic
|
||||
* number, checking for specific assembler instructions).
|
||||
*/
|
||||
bytes_to_read = offsetof(struct df_s390_dumper, force);
|
||||
zg_seek(fh, offset, ZG_CHECK);
|
||||
zg_read(fh, dumper, sizeof(*dumper), ZG_CHECK);
|
||||
zg_read(fh, dumper, bytes_to_read, ZG_CHECK);
|
||||
if (memcmp(dumper->magic, OLD_DUMPER_HEX_INSTR1, 4) == 0 &&
|
||||
memcmp(&dumper->size, OLD_DUMPER_HEX_INSTR2, 2) == 0)
|
||||
/* We found basr r13,0 (old dumper) */
|
||||
dumper->version = 0;
|
||||
switch (dumper->version) {
|
||||
case 1:
|
||||
if (strncmp(dumper->magic, DF_S390_DUMPER_MAGIC_EXT, 7) == 0 ||
|
||||
strncmp(dumper->magic, DF_S390_DUMPER_MAGIC_MV_EXT, 7) == 0)
|
||||
dumper->size = DF_S390_DUMPER_SIZE_V3;
|
||||
else
|
||||
dumper->size = DF_S390_DUMPER_SIZE_V1;
|
||||
break;
|
||||
case 2:
|
||||
dumper->size = DF_S390_DUMPER_SIZE_V2;
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
dumper->size = DF_S390_DUMPER_SIZE_V3;
|
||||
}
|
||||
/* Read force and mem fields in the end of the dumper */
|
||||
bytes_to_read = sizeof(dumper->force) + sizeof(dumper->mem);
|
||||
offset += dumper->size - bytes_to_read;
|
||||
zg_seek(fh, offset, ZG_CHECK);
|
||||
zg_read(fh, &dumper->force, bytes_to_read, ZG_CHECK);
|
||||
}
|
||||
|
||||
124
zdump/df_s390.h
124
zdump/df_s390.h
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* S390 dump format common functions
|
||||
*
|
||||
* Copyright IBM Corp. 2001, 2017
|
||||
* 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.
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "zg.h"
|
||||
|
||||
#define DF_S390_MAGIC 0xa8190173618f23fdULL
|
||||
#define DF_S390_MAGIC_EXT 0xa8190173618f23feULL
|
||||
#define DF_S390_HDR_SIZE 0x1000
|
||||
#define DF_S390_EM_SIZE 16
|
||||
#define DF_S390_EM_STR "DUMP_END"
|
||||
@@ -68,6 +69,16 @@ struct df_s390_em {
|
||||
u64 tod;
|
||||
} __attribute__((packed));
|
||||
|
||||
/*
|
||||
* Segment header for s390 extended dump format
|
||||
*/
|
||||
struct df_s390_dump_segm_hdr {
|
||||
u64 start;
|
||||
u64 len;
|
||||
u64 stop_marker;
|
||||
u8 reserved[0x1000 - 24];
|
||||
} __attribute__((packed));
|
||||
|
||||
/*
|
||||
* Convert DFI arch to s390 arch
|
||||
*/
|
||||
@@ -84,96 +95,31 @@ static inline enum dfi_arch df_s390_to_dfi_arch(enum df_s390_arch df_s390_arch)
|
||||
return df_s390_arch == DF_S390_ARCH_64 ? DFI_ARCH_64 : DFI_ARCH_32;
|
||||
}
|
||||
|
||||
/*
|
||||
* Dump tool structure (version 1)
|
||||
*/
|
||||
struct df_s390_dumper_v1 {
|
||||
char code[0xff7 - 0x8];
|
||||
u8 force;
|
||||
u64 mem;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define DF_S390_DUMPER_SIZE_V1 0x1000
|
||||
|
||||
/*
|
||||
* Dump tool structure (version 2)
|
||||
*/
|
||||
struct df_s390_dumper_v2 {
|
||||
char code[0x1ff7 - 0x8];
|
||||
u8 force;
|
||||
u64 mem;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define DF_S390_DUMPER_SIZE_V2 0x2000
|
||||
|
||||
/*
|
||||
* Dump tool structure (version 3 and 4)
|
||||
*/
|
||||
struct df_s390_dumper_v3 {
|
||||
char code[0x2ff7 - 0x8];
|
||||
u8 force;
|
||||
u64 mem;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define DF_S390_DUMPER_SIZE_V3 0x3000
|
||||
#define DF_S390_DUMPER_SIZE_V1 0x1000
|
||||
#define DF_S390_DUMPER_SIZE_V2 0x2000
|
||||
#define DF_S390_DUMPER_SIZE_V3 0x3000
|
||||
#define DF_S390_DUMPER_MAGIC32 "ZECKD31"
|
||||
#define DF_S390_DUMPER_MAGIC64 "ZECKD64"
|
||||
#define DF_S390_DUMPER_MAGIC_EXT "XECKD64"
|
||||
#define DF_S390_DUMPER_MAGIC32_FBA "ZDFBA31"
|
||||
#define DF_S390_DUMPER_MAGIC64_FBA "ZDFBA64"
|
||||
#define DF_S390_DUMPER_MAGIC_FBA_EXT "XDFBA64"
|
||||
#define DF_S390_DUMPER_MAGIC_MV "ZMULT64"
|
||||
#define DF_S390_DUMPER_MAGIC_MV_EXT "XMULT64"
|
||||
#define OLD_DUMPER_HEX_INSTR1 "\x0d\x10\x47\xf0" /* BASR + 1st halfword of BC */
|
||||
#define OLD_DUMPER_HEX_INSTR2 "\x0d\xd0" /* BASR 13,0 */
|
||||
|
||||
/*
|
||||
* Dump tool structure
|
||||
*/
|
||||
struct df_s390_dumper {
|
||||
char magic[7];
|
||||
u8 version;
|
||||
union {
|
||||
struct df_s390_dumper_v1 v1;
|
||||
struct df_s390_dumper_v2 v2;
|
||||
struct df_s390_dumper_v3 v3;
|
||||
} d;
|
||||
char magic[7];
|
||||
u8 version;
|
||||
u32 size;
|
||||
u8 force;
|
||||
u64 mem;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/*
|
||||
* Dumper member access helpers
|
||||
*/
|
||||
#define df_s390_dumper_magic(dumper) ((dumper).magic)
|
||||
#define df_s390_dumper_version(dumper) ((dumper).version)
|
||||
static inline u64 df_s390_dumper_mem(struct df_s390_dumper *dumper)
|
||||
{
|
||||
switch (dumper->version) {
|
||||
case 1:
|
||||
return dumper->d.v1.mem;
|
||||
case 2:
|
||||
return dumper->d.v2.mem;
|
||||
case 3:
|
||||
default:
|
||||
return dumper->d.v3.mem;
|
||||
}
|
||||
}
|
||||
|
||||
static inline u8 df_s390_dumper_force(struct df_s390_dumper *dumper)
|
||||
{
|
||||
switch (dumper->version) {
|
||||
case 1:
|
||||
return dumper->d.v1.force;
|
||||
case 2:
|
||||
return dumper->d.v2.force;
|
||||
case 3:
|
||||
default:
|
||||
return dumper->d.v3.force;
|
||||
}
|
||||
}
|
||||
|
||||
static inline unsigned long df_s390_dumper_size(struct df_s390_dumper *dumper)
|
||||
{
|
||||
switch (dumper->version) {
|
||||
case 1:
|
||||
return 0x1000;
|
||||
case 2:
|
||||
return 0x2000;
|
||||
case 3:
|
||||
default:
|
||||
return 0x3000;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* s390 dump helpers
|
||||
*/
|
||||
@@ -185,10 +131,14 @@ extern void df_s390_dumper_read(struct zg_fh *fh, int32_t blk_size,
|
||||
struct df_s390_dumper *dumper);
|
||||
|
||||
/*
|
||||
* DASD multi-volume dumper functions
|
||||
* DASD dt and dfi functions
|
||||
*/
|
||||
extern int dt_s390mv_init(void);
|
||||
extern void dt_s390mv_exit(void);
|
||||
extern int dt_s390sv_init_gen(bool extended);
|
||||
extern int dt_s390mv_init_gen(bool extended);
|
||||
extern void dt_s390mv_info(void);
|
||||
|
||||
extern int dfi_s390_init_gen(bool extended);
|
||||
extern int dfi_s390mv_init_gen(bool extended);
|
||||
extern void dfi_s390mv_info(void);
|
||||
|
||||
#endif /* DF_S390_H */
|
||||
|
||||
111
zdump/dfi.c
111
zdump/dfi.c
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Generic input dump format functions (DFI - Dump Format Input)
|
||||
*
|
||||
* Copyright IBM Corp. 2001, 2017
|
||||
* 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.
|
||||
@@ -21,7 +21,9 @@
|
||||
static struct dfi *dfi_vec[] = {
|
||||
&dfi_s390tape,
|
||||
&dfi_devmem,
|
||||
&dfi_s390mv_ext,
|
||||
&dfi_s390mv,
|
||||
&dfi_s390_ext,
|
||||
&dfi_s390,
|
||||
&dfi_lkcd,
|
||||
&dfi_elf,
|
||||
@@ -70,6 +72,7 @@ struct attr {
|
||||
u32 *real_cpu_cnt;
|
||||
struct new_utsname *utsname;
|
||||
char *dump_method;
|
||||
u64 *file_size;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -149,12 +152,46 @@ static void mem_update(struct mem *mem)
|
||||
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");
|
||||
dfi_mem_chunk_iterate(mem_chunk) {
|
||||
STDERR(" %016llx - %016llx (%llu MB)\n", mem_chunk->start,
|
||||
mem_chunk->end, TO_MIB(mem_chunk->size));
|
||||
/*
|
||||
* 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));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -226,6 +263,9 @@ void dfi_info_print(void)
|
||||
if (l.attr.mem_size_real)
|
||||
STDERR(" Real memory range..: %lld MB\n",
|
||||
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));
|
||||
if (dfi_mem_range())
|
||||
mem_map_print();
|
||||
if (l.dfi->info_dump) {
|
||||
@@ -351,9 +391,27 @@ 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, free_fn);
|
||||
l.mem_virt.chunk_cache->volnr = volnr;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Add memory chunk
|
||||
*/
|
||||
@@ -361,8 +419,16 @@ 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)
|
||||
{
|
||||
mem_chunk_create(&l.mem_phys, start, size, data, read_fn, free_fn);
|
||||
mem_chunk_create(&l.mem_virt, start, size, data, read_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);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -401,6 +467,16 @@ struct dfi_mem_chunk *dfi_mem_chunk_first(void)
|
||||
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
|
||||
*/
|
||||
@@ -678,7 +754,7 @@ struct new_utsname *dfi_attr_utsname(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* Attribute: dump method
|
||||
* Attribute: Dump method
|
||||
*/
|
||||
void dfi_attr_dump_method_set(char *dump_method)
|
||||
{
|
||||
@@ -704,6 +780,21 @@ u64 *dfi_attr_mem_size_real(void)
|
||||
return l.attr.mem_size_real;
|
||||
}
|
||||
|
||||
/*
|
||||
* Attribute: Dump file size
|
||||
*/
|
||||
void dfi_attr_file_size_set(u64 file_size)
|
||||
{
|
||||
l.attr.file_size = zg_alloc(sizeof(*l.attr.file_size));
|
||||
*l.attr.file_size = file_size;
|
||||
}
|
||||
|
||||
u64 *dfi_attr_file_size(void)
|
||||
{
|
||||
return l.attr.file_size;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Attribute: Build architecture
|
||||
*/
|
||||
@@ -795,7 +886,10 @@ 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;
|
||||
dfi_mem_read(lc->vector_save_area_addr, &vx_sa, sizeof(vx_sa));
|
||||
if (dfi_mem_read_rc(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;
|
||||
}
|
||||
memcpy(cpu->vxrs_high, &vx_sa[16 * 16], sizeof(cpu->vxrs_high));
|
||||
for (i = 0; i < 16; i++)
|
||||
memcpy(&cpu->vxrs_low[i], &vx_sa[16 * i + 8], sizeof(u64));
|
||||
@@ -827,6 +921,7 @@ void dfi_cpu_add_from_lc(u32 lc_addr)
|
||||
{
|
||||
struct dfi_cpu *cpu = dfi_cpu_alloc();
|
||||
|
||||
cpu->cpu_id = l.cpus.cnt;
|
||||
switch (l.cpus.content) {
|
||||
case DFI_CPU_CONTENT_LC:
|
||||
cpu->prefix = lc_addr;
|
||||
|
||||
20
zdump/dfi.h
20
zdump/dfi.h
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Generic input dump format functions (DFI - Dump Format Input)
|
||||
*
|
||||
* Copyright IBM Corp. 2001, 2017
|
||||
* 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.
|
||||
@@ -97,6 +97,7 @@ struct dfi_cpu {
|
||||
u32 todpreg;
|
||||
u64 vxrs_low[16];
|
||||
struct dfi_vxrs vxrs_high[16];
|
||||
u16 cpu_id;
|
||||
};
|
||||
|
||||
struct dfi_cpu_32 {
|
||||
@@ -125,7 +126,7 @@ enum dfi_cpu_content {
|
||||
};
|
||||
|
||||
#define DFI_CPU_CONTENT_FAC_VX 0x00000001
|
||||
extern int dfi_cpu_content_fac_check(int falgs);
|
||||
extern int dfi_cpu_content_fac_check(int flags);
|
||||
extern void dfi_cpu_content_fac_add(int flags);
|
||||
|
||||
#define dfi_cpu_iterate(cpu) \
|
||||
@@ -158,13 +159,18 @@ struct dfi_mem_chunk {
|
||||
u64 start; /* Start address in memory */
|
||||
u64 end; /* End address in memory */
|
||||
u64 size; /* Size of chunk in dump file */
|
||||
u64 out_start; /* Start offset in dump file */
|
||||
u64 out_end; /* End offset 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);
|
||||
@@ -175,6 +181,7 @@ 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);
|
||||
@@ -202,7 +209,10 @@ extern void dfi_attr_dump_method_set(char *dump_method);
|
||||
extern 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();
|
||||
extern u64 *dfi_attr_mem_size_real(void);
|
||||
|
||||
extern void dfi_attr_file_size_set(u64 dump_size);
|
||||
extern 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);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user