Skip to content

Commit 288905d

Browse files
author
Lars Ekman
committedNov 11, 2021
ovl/lspci; added
1 parent 8537f43 commit 288905d

File tree

3 files changed

+173
-0
lines changed

3 files changed

+173
-0
lines changed
 

‎ovl/lspci/README.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Xcluster/ovl - lspci
2+
3+
Adds `lspci` and the hw database.
4+
5+
Example;
6+
```
7+
vm-002 ~ # lspci
8+
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
9+
00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
10+
00:01.1 IDE interface: Intel Corporation 82371SB PIIX3 IDE [Natoma/Triton II]
11+
00:01.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 03)
12+
00:02.0 VGA compatible controller: Device 1234:1111 (rev 02)
13+
00:03.0 Ethernet controller: Red Hat, Inc. Virtio network device
14+
00:04.0 Ethernet controller: Red Hat, Inc. Virtio network device
15+
00:05.0 Ethernet controller: Red Hat, Inc. Virtio network device
16+
00:06.0 Ethernet controller: Red Hat, Inc. Virtio network device
17+
00:07.0 Ethernet controller: Red Hat, Inc. Virtio network device
18+
00:08.0 Unclassified device [00ff]: Red Hat, Inc. Virtio RNG
19+
00:09.0 SCSI storage controller: Red Hat, Inc. Virtio block device
20+
00:0a.0 SCSI storage controller: Red Hat, Inc. Virtio block device
21+
```
22+

‎ovl/lspci/lspci.sh

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
#! /bin/sh
2+
##
3+
## lspci.sh --
4+
##
5+
## Help script for the xcluster ovl/lspci.
6+
##
7+
## Commands;
8+
##
9+
10+
prg=$(basename $0)
11+
dir=$(dirname $0); dir=$(readlink -f $dir)
12+
me=$dir/$prg
13+
tmp=/tmp/${prg}_$$
14+
15+
die() {
16+
echo "ERROR: $*" >&2
17+
rm -rf $tmp
18+
exit 1
19+
}
20+
help() {
21+
grep '^##' $0 | cut -c3-
22+
rm -rf $tmp
23+
exit 0
24+
}
25+
test -n "$1" || help
26+
echo "$1" | grep -qi "^help\|-h" && help
27+
28+
log() {
29+
echo "$prg: $*" >&2
30+
}
31+
dbg() {
32+
test -n "$__verbose" && echo "$prg: $*" >&2
33+
}
34+
35+
## env
36+
## Print environment.
37+
##
38+
cmd_env() {
39+
40+
if test "$cmd" = "env"; then
41+
set | grep -E '^(__.*)='
42+
retrun 0
43+
fi
44+
45+
test -n "$XCLUSTER" || die 'Not set [$XCLUSTER]'
46+
test -x "$XCLUSTER" || die "Not executable [$XCLUSTER]"
47+
eval $($XCLUSTER env)
48+
}
49+
50+
## test --list
51+
## test [--xterm] [test...] > logfile
52+
## Exec tests
53+
##
54+
cmd_test() {
55+
if test "$__list" = "yes"; then
56+
grep '^test_' $me | cut -d'(' -f1 | sed -e 's,test_,,'
57+
return 0
58+
fi
59+
60+
cmd_env
61+
start=starts
62+
test "$__xterm" = "yes" && start=start
63+
rm -f $XCLUSTER_TMP/cdrom.iso
64+
65+
if test -n "$1"; then
66+
for t in $@; do
67+
test_$t
68+
done
69+
else
70+
for t in basic; do
71+
test_$t
72+
done
73+
fi
74+
75+
now=$(date +%s)
76+
tlog "Xcluster test ended. Total time $((now-begin)) sec"
77+
78+
}
79+
80+
test_start() {
81+
export __image=$XCLUSTER_HOME/hd.img
82+
echo "$XOVLS" | grep -q private-reg && unset XOVLS
83+
test -n "$TOPOLOGY" && \
84+
. $($XCLUSTER ovld network-topology)/$TOPOLOGY/Envsettings
85+
xcluster_start network-topology iptools lspci
86+
}
87+
88+
test_basic() {
89+
tlog "=== lspci: Basic test"
90+
test_start
91+
xcluster_stop
92+
}
93+
94+
cmd_otc() {
95+
test -n "$__vm" || __vm=2
96+
otc $__vm $@
97+
}
98+
99+
. $($XCLUSTER ovld test)/default/usr/lib/xctest
100+
indent=''
101+
102+
# Get the command
103+
cmd=$1
104+
shift
105+
grep -q "^cmd_$cmd()" $0 $hook || die "Invalid command [$cmd]"
106+
107+
while echo "$1" | grep -q '^--'; do
108+
if echo $1 | grep -q =; then
109+
o=$(echo "$1" | cut -d= -f1 | sed -e 's,-,_,g')
110+
v=$(echo "$1" | cut -d= -f2-)
111+
eval "$o=\"$v\""
112+
else
113+
o=$(echo "$1" | sed -e 's,-,_,g')
114+
eval "$o=yes"
115+
fi
116+
shift
117+
done
118+
unset o v
119+
long_opts=`set | grep '^__' | cut -d= -f1`
120+
121+
# Execute command
122+
trap "die Interrupted" INT TERM
123+
cmd_$cmd "$@"
124+
status=$?
125+
rm -rf $tmp
126+
exit $status

‎ovl/lspci/tar

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#! /bin/sh
2+
# NOTE: A common pattern is to specify "-" (stdout) as out-file,
3+
# so there must be NO log printouts to stdout!
4+
5+
dir=$(dirname $0); dir=$(readlink -f $dir)
6+
tmp=/tmp/$USER/xcluster_$$
7+
die() {
8+
echo "ERROR: $*" >&2
9+
rm -rf $tmp
10+
exit 1
11+
}
12+
log() {
13+
echo "INFO: $*" >&2
14+
}
15+
16+
test -n "$1" || die "No out-file"
17+
18+
mkdir -p $tmp/usr/share/misc
19+
gzip -c /usr/share/misc/pci.ids > $tmp//usr/share/misc/pci.ids.gz
20+
$XCLUSTER install_prog --dest=$tmp lspci
21+
22+
cd $tmp
23+
tar cf "$1" *
24+
cd - > /dev/null
25+
rm -rf $tmp

0 commit comments

Comments
 (0)
Please sign in to comment.