2 TEST_DESCRIPTION
="root filesystem on NFS with multiple nics"
4 KVERSION
=${KVERSION-$(uname -r)}
6 # Uncomment this to debug failures
11 echo "MULTINIC TEST SETUP: Starting DHCP/NFS server"
13 $testdir/run-qemu
-hda server.ext2
-m 256M
-nographic \
14 -net nic
,macaddr
=52:54:00:12:34:56,model
=e1000 \
15 -net socket
,listen
=127.0.0.1:12345 \
16 -serial udp
:127.0.0.1:9999 \
17 -kernel /boot
/vmlinuz-
$KVERSION \
18 -append "selinux=0 root=/dev/sda rdinitdebug rdinfo rdnetdebug rw quiet console=ttyS0,115200n81" \
19 -initrd initramfs.server
-pidfile server.pid
-daemonize ||
return 1
20 sudo
chmod 644 server.pid ||
return 1
22 # Cleanup the terminal if we have one
25 echo Sleeping
10 seconds to give the server a
head start
37 echo "CLIENT TEST START: $test_name"
39 # Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
40 if ! dd if=/dev
/zero of
=client.img bs
=1M count
=1; then
41 echo "Unable to make client sda image" 1>&2
45 $testdir/run-qemu
-hda client.img
-m 512M
-nographic \
46 -net nic
,macaddr
=52:54:00:12:34:$mac1,model
=e1000 \
47 -net nic
,macaddr
=52:54:00:12:34:$mac2,model
=e1000 \
48 -net nic
,macaddr
=52:54:00:12:34:$mac3,model
=e1000 \
49 -net socket
,connect
=127.0.0.1:12345 \
50 -kernel /boot
/vmlinuz-
$KVERSION \
51 -append "$cmdline $DEBUGFAIL rd_retry=5 rdinitdebug rdinfo rdnetdebug ro quiet console=ttyS0,115200n81 selinux=0 rdcopystate" \
52 -initrd initramfs.testing
54 if [[ $?
-ne 0 ]] ||
! grep -m 1 -q OK client.img
; then
55 echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
62 if ! grep -m 1 -q $i client.img
; then
63 echo "CLIENT TEST END: $test_name [FAILED - BAD IF]"
68 echo "CLIENT TEST END: $test_name [OK]"
75 echo "Failed to start server" 1>&2
78 test_client ||
{ kill_server
; return 1; }
82 # Mac Numbering Scheme
83 # ...:00-02 receive IP adresses all others don't
84 # ...:02 receives a dhcp root-path
87 client_test
"MULTINIC root=nfs BOOTIF=" \
89 "root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00" \
92 # PXE Style BOOTIF= with dhcp root-path
93 client_test
"MULTINIC root=dhcp BOOTIF=" \
95 "root=dhcp BOOTIF=52-54-00-12-34-02" \
98 # Multinic case, where only one nic works
99 client_test
"MULTINIC root=nfs ip=dhcp" \
101 "root=nfs:192.168.50.1:/nfs/client ip=dhcp" \
104 # Require two interfaces
105 client_test
"MULTINIC root=nfs ip=eth1:dhcp ip=eth2:dhcp bootdev=eth1" \
107 "root=nfs:192.168.50.1:/nfs/client ip=eth1:dhcp ip=eth2:dhcp bootdev=eth1" \
108 "eth1 eth2" ||
return 1
110 # Require three interfaces with dhcp root-path
111 client_test
"MULTINIC root=dhcp ip=eth0:dhcp ip=eth1:dhcp ip=eth2:dhcp bootdev=eth2" \
113 "root=dhcp ip=eth0:dhcp ip=eth1:dhcp ip=eth2:dhcp bootdev=eth2" \
114 "eth0 eth1 eth2" ||
return 1
119 dd if=/dev
/zero of
=server.ext2 bs
=1M count
=60
120 mke2fs
-F server.ext2
122 sudo mount
-o loop server.ext2 mnt
127 .
$basedir/dracut-functions
128 dracut_install sh
ls shutdown poweroff stty
cat ps
ln ip \
129 /lib
/terminfo
/l
/linux dmesg mkdir
cp ping exportfs \
130 modprobe rpc.nfsd rpc.mountd showmount tcpdump \
131 /etc
/services
sleep mount
chmod
132 which portmap
>/dev
/null
2>&1 && dracut_install portmap
133 which rpcbind
>/dev
/null
2>&1 && dracut_install rpcbind
134 [ -f /etc
/netconfig
] && dracut_install
/etc
/netconfig
135 which dhcpd
>/dev
/null
2>&1 && dracut_install dhcpd
136 [ -x /usr
/sbin
/dhcpd3
] && inst
/usr
/sbin
/dhcpd3
/usr
/sbin
/dhcpd
137 instmods nfsd sunrpc ipv6
138 inst .
/server-init
/sbin
/init
139 inst .
/hosts
/etc
/hosts
140 inst .
/exports
/etc
/exports
141 inst .
/dhcpd.conf
/etc
/dhcpd.conf
142 dracut_install
/etc
/nsswitch.conf
/etc
/rpc
/etc
/protocols
143 dracut_install rpc.idmapd
/etc
/idmapd.conf
144 if ldd $
(which rpc.idmapd
) |
grep -q lib64
; then
150 dracut_install $
(ls {/usr
,}$LIBDIR/libnfsidmap
*.so
* 2>/dev
/null
)
151 dracut_install $
(ls {/usr
,}$LIBDIR/libnfsidmap
/*.so
2>/dev
/null
)
152 dracut_install $
(ls {/usr
,}$LIBDIR/libnss
*.so
2>/dev
/null
)
155 nsslibs
=$
(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc
/nsswitch.conf \
156 |
tr -s '[:space:]' '\n' |
sort -u |
tr -s '[:space:]' '|')
160 dracut_install $
(for i
in $
(ls {/usr
,}$LIBDIR/libnss
*.so
2>/dev
/null
); do echo $i;done |
egrep "$nsslibs")
163 mkdir
-p dev sys proc etc var
/run tmp var
/lib
/{dhcpd
,rpcbind
}
164 mkdir
-p var
/lib
/nfs
/{v4recovery
,rpc_pipefs
}
165 chmod 777 var
/lib
/rpcbind var
/lib
/nfs
167 inst
/etc
/nsswitch.conf
/etc
/nsswitch.conf
168 inst
/etc
/passwd
/etc
/passwd
169 inst
/etc
/group
/etc
/group
170 for i
in /lib
*/libnss_files
**;do
174 /sbin
/depmod
-a -b "$initdir" $kernel
175 cp -a /etc
/ld.so.conf
* $initdir/etc
176 sudo ldconfig
-r "$initdir"
179 # Make client root inside server root
180 initdir
=mnt
/nfs
/client
184 .
$basedir/dracut-functions
185 dracut_install sh shutdown poweroff stty
cat ps
ln ip \
186 /lib
/terminfo
/l
/linux mount dmesg mkdir \
188 inst .
/client-init
/sbin
/init
191 mkdir
-p dev sys proc etc
192 mkdir
-p var
/lib
/nfs
/rpc_pipefs
194 inst
/etc
/nsswitch.conf
/etc
/nsswitch.conf
195 inst
/etc
/passwd
/etc
/passwd
196 inst
/etc
/group
/etc
/group
197 for i
in /lib
*/libnss_files
*;do
201 cp -a /etc
/ld.so.conf
* $initdir/etc
202 sudo ldconfig
-r "$initdir"
208 # Make an overlay with needed tools for the test harness
212 .
$basedir/dracut-functions
213 dracut_install poweroff shutdown
214 inst_simple .
/hard-off.sh
/emergency
/01hard-off.sh
215 inst_simple .
/99-idesymlinks.rules
/etc
/udev
/rules.d
/99-idesymlinks.rules
218 # Make server's dracut image
219 $basedir/dracut
-l -i overlay
/ \
220 -m "dash udev-rules base rootfs-block debug kernel-modules" \
221 -d "piix ide-gd_mod ata_piix ext2 sd_mod e1000" \
222 -f initramfs.server
$KVERSION ||
return 1
224 # Make client's dracut image
225 $basedir/dracut
-l -i overlay
/ \
228 -d "piix sd_mod sr_mod ata_piix ide-gd_mod e1000 nfs sunrpc" \
229 -f initramfs.testing
$KVERSION ||
return 1
233 if [[ -s server.pid
]]; then
234 sudo
kill -TERM $
(cat server.pid
)
241 rm -f server.ext2 client.img initramfs.server initramfs.testing
244 .
$testdir/test-functions