Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QEMU Networking using slirp and vdeplug4 #235

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions boards/default/distros/fedora/fedora.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
serviceTemplate = """[Unit]
Requires=multi-user.target
After=multi-user.target
Requires=network-online.target
After=network-online.target
Before=firesim.target
Wants=firesim.target

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Requires=multi-user.target
After=multi-user.target
Requires=network-online.target
After=network-online.target
Before=firesim.target
Wants=firesim.target

[Service]
ExecStart=/etc/firesim/firesim.sh
StandardOutput=journal+console
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,38 @@
#
# Start the network....
#

# Debian ifupdown needs the /run/network lock directory
mkdir -p /run/network

resolvconf_file="/etc/resolv.conf"
rm -f $resolvconf_file
echo "nameserver 172.16.0.3" > $resolvconf_file

ifname=eth0
read _ addr _ _ <<< $(/sbin/ip link | /bin/grep -A 1 "$ifname" | /usr/bin/tail -1)
IFS=: read -r _ _ _ _ machigh maclow <<< $addr

case "$1" in
start)
printf "Starting network: "
/sbin/ifup -a
ifname=eth0
if test -r "/sys/class/net/${ifname}/address" ; then
/sbin/ip link set dev "$ifname" up &&
IFS=: read -r _ _ _ _ machigh maclow < "/sys/class/net/${ifname}/address" &&
/sbin/ip addr add "172.16.$((16#$machigh)).$((16#$maclow))/16" dev "$ifname"
fi
# /sbin/ifup eth0
[ $? = 0 ] && echo "OK" || echo "FAIL"
;;
stop)
printf "Stopping network: "
/sbin/ifdown -a
# /sbin/ifdown eth0
[ $? = 0 ] && echo "OK" || echo "FAIL"
;;
restart|reload)
"$0" stop
"$0" start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
start)
printf "Starting network: "
raghav-g13 marked this conversation as resolved.
Show resolved Hide resolved
/bin/sed -i -e "1,/^address/{s/^address.*/address 172.16.$((16#$machigh)).$((16#$maclow))/;}" /etc/network/interfaces
sbin/ifup -a
[ $? = 0 ] && echo "OK" || echo "FAIL"
;;
stop)
printf "Stopping network: "
/sbin/ifdown -a
/bin/sed -i -e "1,/^address/{s/^address.*/address firemarshal_ip_addr_uninitialized/;}" /etc/network/interfaces
raghav-g13 marked this conversation as resolved.
Show resolved Hide resolved
[ $? = 0 ] && echo "OK" || echo "FAIL"
;;
restart|reload)
"$0" stop
"$0" start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1

esac

exit $?

Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address firemarshal_ip_addr_uninitialized
netmask 255.255.0.0
gateway 172.16.0.2
dns-nameservers 172.16.0.3
raghav-g13 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ DEVICE=eth0
BOOTPROTO=static
ONBOOT=on
PREFIX=16
PEERDNS=yes
DNS1=172.16.0.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
NETWORKING=yes
NETWORKING_IPV6=no
GATEWAY=172.16.0.2
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ case "$macpref" in
maclow=$(echo $mac | cut -c 16-17 -)
cp /etc/firesim/ifcfg-static /etc/sysconfig/network-scripts/ifcfg-eth0
echo IPADDR=172.16.$((16#$machigh)).$((16#$maclow)) >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo default via 172.16.0.2 dev eth0 > /etc/sysconfig/network-scripts/route-eth0
cp /etc/firesim/network-static /etc/sysconfig/network
;;
"52:54:00")
echo "this looks like not FireSim. exiting"
Expand Down
5 changes: 4 additions & 1 deletion scripts/fullTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@
'qemu',
'run',
'simArgs',
'noDrivers'
'noDrivers',
'internet',
'network',
'fed-nw-internet'
],

# This tests both no-disk and spike. In theory, most (maybe all?) tests
Expand Down
27 changes: 27 additions & 0 deletions test/fed-nw-internet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name" : "fed-nw-internet",
"base" : "fedora-base.json",
"overlay": "overlay",
"testing" : {
"refDir" : "refOutput",
"strip" : true
},
"jobs" : [
{
"name" : "j0",
"command" : "timeout 75 /root/test-server.sh"
},
{
"name" : "j1",
"command" : "/root/test-client-1.sh"
},
{
"name" : "j2",
"command" : "/root/test-client-2.sh"
},
{
"name" : "j3",
"command" : 'yum install -y wget && wget fires.im && echo "Success : yum + wget"'
}
]
}
Binary file added test/fed-nw-internet/overlay/root/client
Binary file not shown.
Binary file added test/fed-nw-internet/overlay/root/server
Binary file not shown.
12 changes: 12 additions & 0 deletions test/fed-nw-internet/overlay/root/test-client-1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#/bin/bash
ip_read=`ip -f inet addr show eth0 | grep -Po 'inet \K[\d.]+'`
if [ "$ip_read" = "172.16.0.5" ]; then
/root/client 172.16.0.4
if [ "$?" -eq "0" ]; then
echo 'Success : ip + client'
else
echo 'Failed : client'
fi
else
echo 'Failed : ip'
raghav-g13 marked this conversation as resolved.
Show resolved Hide resolved
fi
15 changes: 15 additions & 0 deletions test/fed-nw-internet/overlay/root/test-client-2-copy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#/bin/bash
raghav-g13 marked this conversation as resolved.
Show resolved Hide resolved
ip_read=`ip -f inet addr show`
str="read ip"
echo $str
echo $ip_read
if [ "$ip_read" = "172.16.0.6" ]; then
/root/client 172.16.0.4
if [ "$?" -eq "0" ]; then
echo 'Success : ip + client'
else
echo 'Failed : client'
fi
else
echo 'Failed : ip'
fi
12 changes: 12 additions & 0 deletions test/fed-nw-internet/overlay/root/test-client-2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#/bin/bash
ip_read=`ip -f inet addr show eth0 | grep -Po 'inet \K[\d.]+'`
if [ "$ip_read" = "172.16.0.6" ]; then
/root/client 172.16.0.4
if [ "$?" -eq "0" ]; then
echo 'Success : ip + client'
else
echo 'Failed : client'
fi
else
echo 'Failed : ip'
fi
12 changes: 12 additions & 0 deletions test/fed-nw-internet/overlay/root/test-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#/bin/bash
ip_read=`ip -f inet addr show eth0 | grep -Po 'inet \K[\d.]+'`
if [ "$ip_read" = "172.16.0.4" ]; then
/root/server 2
if [ "$?" -eq "0" ]; then
echo 'Success : ip + server'
else
echo 'Failed : server'
fi
else
echo 'Failed : ip'
fi
1 change: 1 addition & 0 deletions test/fed-nw-internet/refOutput/fed-nw-internet-j0/uartlog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Success : ip + server
1 change: 1 addition & 0 deletions test/fed-nw-internet/refOutput/fed-nw-internet-j1/uartlog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Success : ip + client
1 change: 1 addition & 0 deletions test/fed-nw-internet/refOutput/fed-nw-internet-j2/uartlog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Success : ip + client
1 change: 1 addition & 0 deletions test/fed-nw-internet/refOutput/fed-nw-internet-j3/uartlog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Success : yum + wget
9 changes: 9 additions & 0 deletions test/internet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name" : "internet",
"base" : "br-base.json",
"command" : 'wget -S fires.im && echo "Success : wget"',
"testing" : {
"refDir" : "refOutput",
"strip" : true
}
}
1 change: 1 addition & 0 deletions test/internet/refOutput/internet/uartlog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Success : wget
23 changes: 23 additions & 0 deletions test/network.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name" : "network",
"base" : "br-base.json",
"overlay": "overlay",
"testing" : {
"refDir" : "refOutput",
"strip" : true
},
"jobs" : [
{
"name" : "j0",
"command" : "timeout 75 /root/test-server.sh"
},
{
"name" : "j1",
"command" : "/root/test-client-1.sh"
},
{
"name" : "j2",
"command" : "/root/test-client-2.sh"
}
]
}
Binary file added test/network/overlay/root/client
Binary file not shown.
Binary file added test/network/overlay/root/server
Binary file not shown.
12 changes: 12 additions & 0 deletions test/network/overlay/root/test-client-1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#/bin/bash
ip_read=`ifconfig eth0 | grep "inet " | awk -F'[: ]+' '{ print $4 }'`
if [ "$ip_read" = "172.16.0.5" ]; then
/root/client 172.16.0.4
if [ "$?" -eq "0" ]; then
echo 'Success : ip + client'
else
echo 'Failed : client'
fi
else
echo 'Failed : ip'
fi
12 changes: 12 additions & 0 deletions test/network/overlay/root/test-client-2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#/bin/bash
ip_read=`ifconfig eth0 | grep "inet " | awk -F'[: ]+' '{ print $4 }'`
if [ "$ip_read" = "172.16.0.6" ]; then
/root/client 172.16.0.4
if [ "$?" -eq "0" ]; then
echo 'Success : ip + client'
else
echo 'Failed : client'
fi
else
echo 'Failed : ip'
fi
12 changes: 12 additions & 0 deletions test/network/overlay/root/test-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#/bin/bash
ip_read=`ifconfig eth0 | grep "inet " | awk -F'[: ]+' '{ print $4 }'`
if [ "$ip_read" = "172.16.0.4" ]; then
/root/server 2
if [ "$?" -eq "0" ]; then
echo 'Success : ip + server'
else
echo 'Failed : server'
fi
else
echo 'Failed : ip'
fi
1 change: 1 addition & 0 deletions test/network/refOutput/network-j0/uartlog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Success : ip + server
1 change: 1 addition & 0 deletions test/network/refOutput/network-j1/uartlog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Success : ip + client
1 change: 1 addition & 0 deletions test/network/refOutput/network-j2/uartlog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Success : ip + client
3 changes: 1 addition & 2 deletions test/post-bin/create-file.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/bash

echo "From create-file.sh script:" >> ${1}.txt
echo $@ >> ${1}.txt
echo "From create-file.sh script: $@" >> ${1}.txt
3 changes: 1 addition & 2 deletions test/post-bin/refOutputBase/post-bin/uartlog
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
From create-file.sh script:
base
From create-file.sh script: base
3 changes: 1 addition & 2 deletions test/post-bin/refOutputJobs/post-bin-jobs-j0/uartlog
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
From create-file.sh script:
job0
From create-file.sh script: job0
3 changes: 1 addition & 2 deletions test/post-bin/refOutputJobs/post-bin-jobs-j1/uartlog
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
From create-file.sh script:
job1
From create-file.sh script: job1
2 changes: 1 addition & 1 deletion wlutil/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ def makeImage(config):
init_overlay = config['builder'].generateBootScriptOverlay(
str(config['guest-init'].path), config['guest-init'].args)
wlutil.applyOverlay(config['img'], init_overlay)
wlutil.run(wllaunch.getQemuCmd(config), shell=True, level=logging.DEBUG)
wllaunch.launchWorkload(config, jobs=None, spike=False, silent=True, captureOutput=False)

# Clear the init script
run_overlay = config['builder'].generateBootScriptOverlay(None, None)
Expand Down
Loading