Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
dcb3c952
Commit
dcb3c952
authored
Jun 19, 2020
by
Antoine Kaufmann
Browse files
scripts for running simple qemu pair experiments
parent
e5d21a24
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
192 additions
and
0 deletions
+192
-0
.gitignore
.gitignore
+3
-0
experiments/Makefile
experiments/Makefile
+44
-0
experiments/common-functions.sh
experiments/common-functions.sh
+102
-0
experiments/experiments/qemu-corundum-bm-pair.sh
experiments/experiments/qemu-corundum-bm-pair.sh
+14
-0
experiments/experiments/qemu-corundum-verilator-pair.sh
experiments/experiments/qemu-corundum-verilator-pair.sh
+14
-0
experiments/guests/qemu-pair-client/run.sh
experiments/guests/qemu-pair-client/run.sh
+8
-0
experiments/guests/qemu-pair-server/run.sh
experiments/guests/qemu-pair-server/run.sh
+7
-0
No files found.
.gitignore
View file @
dcb3c952
...
@@ -17,3 +17,6 @@ images/output-ubuntu1804
...
@@ -17,3 +17,6 @@ images/output-ubuntu1804
images/packer
images/packer
images/packer_cache
images/packer_cache
images/kernel/linux-*/
images/kernel/linux-*/
experiments/build
experiments/out
experiments/local-config.sh
experiments/Makefile
0 → 100644
View file @
dcb3c952
MQNICMOD
:=
$(
abspath
../images/mqnic/mqnic.ko
)
GUESTS
:=
\
qemu-pair-client
\
qemu-pair-server
\
EXPERIMENTS
:=
\
qemu-corundum-bm-pair
\
qemu-corundum-verilator-pair
\
BUILDDIR
:=
build
OUTDIR
:=
out
GUESTS_TARS
:=
$(
addprefix
$(BUILDDIR)
/,
$(
addsuffix
.tar,
$(GUESTS)
))
EXPERIMENTS_OUTPUTS
:=
$(
addprefix
$(OUTDIR)
/,
$(EXPERIMENTS)
)
all
:
$(GUESTS_TARS) $(EXPERIMENTS_OUTPUTS)
clean
:
rm
-rf
$(BUILDDIR)
$(OUTDIR)
#######################################
# Running experiments
run
:
$(EXPERIMENTS)
$(OUTDIR)/%
:
experiments/%.sh $(GUESTS_TARS)
bash
$<
#######################################
# Guest Tars
define
build_guest
$(1)_OBJS
:=
$(
wildcard
guests/
$(1)
/
*
)
$(BUILDDIR)/$(1).tar
:
$$($(1)_OBJS)
rm
-rf
$(BUILDDIR)
/
$(1)
mkdir
-p
$(BUILDDIR)
/
$(1)
/guest
cp
$(MQNICMOD)
$(BUILDDIR)
/
$(1)
/guest/
cp
$$
(
$(1)
_OBJS
)
$(BUILDDIR)
/
$(1)
/guest/
cd
$(BUILDDIR)
/
$(1)
&&
tar
cf
$
$(
abspath
$$
@
)
guest/
rm
-rf
$(BUILDDIR)
/
$(1)
endef
$(foreach
guest,$(GUESTS),
$(eval
$(call
build_guest,$(guest))))
experiments/common-functions.sh
0 → 100644
View file @
dcb3c952
#!/bin/bash
if
[
!
-f
local-config.sh
]
;
then
echo
"local-config.sh does not exist"
exit
1
fi
source
local-config.sh
if
[
-z
"
$EHSIM_BASE
"
]
;
then
echo
"
\$
EHSIM_BASE should be set to the absolute path of the root"
\
"of this repo (local-config.sh)"
exit
1
fi
if
[
-z
"
$QEMU_CMD
"
]
;
then
echo
"
\$
QEMU_CMD should be set to the absolute path to a QEMU instance"
\
"with cosim support (local-config.sh)"
exit
1
fi
QEMU_BASE_IMAGE
=
$EHSIM_BASE
/images/output-ubuntu1804/ubuntu1804
QEMU_KERNEL
=
$EHSIM_BASE
/images/bzImage
# Args:
# - experiment name
init_out
()
{
export
OUTDIR
=
./out/
$1
rm
-rf
$OUTDIR
mkdir
-p
$OUTDIR
}
# Args:
# - Instance name
# - Cosim instance
# - secondary hard drive
run_qemu
()
{
img_a
=
"
$OUTDIR
/qemu.hd.a.
$1
"
img_b
=
"
$OUTDIR
/qemu.hd.b.
$1
"
pcisock
=
"
$OUTDIR
/pci.
$2
"
rm
-f
$img_a
$img_b
echo
Creating disk
for
qemu
$1
qemu-img create
-f
qcow2
-o
backing_file
=
$QEMU_BASE_IMAGE
$img_a
cp
$3
$img_b
echo
Starting qemu
$1
$QEMU_CMD
-machine
q35
-cpu
host
\
-drive
file
=
$img_a
,if
=
ide,index
=
0
\
-drive
file
=
$img_b
,if
=
ide,index
=
1,driver
=
raw
\
-kernel
$QEMU_KERNEL
\
-append
"earlyprintk=ttyS0 console=ttyS0 root=/dev/sda1 init=/home/ubuntu/guestinit.sh rw"
\
-serial
mon:stdio
-m
$((
4
*
1024
))
-smp
1
-display
none
-enable-kvm
\
-nic
none
\
-chardev
socket,path
=
$pcisock
,id
=
cosimcd
\
-device
cosim-pci,chardev
=
cosimcd &>
$OUTDIR
/qemu.
$1
.log &
pid
=
$!
ALL_PIDS
=
"
$ALL_PIDS
$pid
"
return
$pid
}
# Args:
# - Instance name
run_corundum_verilator
()
{
echo
Starting corundum_verilator
$1
$EHSIM_BASE
/corundum/corundum_verilator
\
$OUTDIR
/pci.
$1
$OUTDIR
/eth.
$1
$OUTDIR
/shm.
$1
\
&>
$OUTDIR
/corundum_verilator.
$1
.log &
pid
=
$!
ALL_PIDS
=
"
$ALL_PIDS
$pid
"
return
$pid
}
# Args:
# - Instance name
run_corundum_bm
()
{
echo
Starting corundum_bm
$1
$EHSIM_BASE
/corundum_bm/corundum_bm
\
$OUTDIR
/pci.
$1
$OUTDIR
/eth.
$1
$OUTDIR
/shm.
$1
\
&>
$OUTDIR
/corundum_bm.
$1
.log &
pid
=
$!
ALL_PIDS
=
"
$ALL_PIDS
$pid
"
return
$pid
}
# Args:
# - Instance name
# - sim instance 1
# - sim instance 2
run_wire
()
{
echo
Starting wire
$1
$EHSIM_BASE
/net_wire/net_wire
\
$OUTDIR
/eth.
$2
$OUTDIR
/eth.
$3
&>
$OUTDIR
/wire.
$1
.log &
pid
=
$!
ALL_PIDS
=
"
$ALL_PIDS
$pid
"
return
$pid
}
cleanup
()
{
echo
Cleaning up
for
p
in
$ALL_PIDS
;
do
kill
-KILL
$p
&>/dev/null
done
rm
-f
$OUTDIR
/
{
qemu.hd.
*
,shm.
*
,pci.
*
,eth.
*
}
}
experiments/experiments/qemu-corundum-bm-pair.sh
0 → 100644
View file @
dcb3c952
#!/bin/bash
source
common-functions.sh
init_out qemu-corundum-bm-pair
run_corundum_bm a
run_corundum_bm b
sleep
0.5
run_wire ab a b
run_qemu a a build/qemu-pair-server.tar
run_qemu b b build/qemu-pair-client.tar
client_pid
=
$!
wait
$client_pid
cleanup
experiments/experiments/qemu-corundum-verilator-pair.sh
0 → 100644
View file @
dcb3c952
#!/bin/bash
source
common-functions.sh
init_out qemu-corundum-verilator-pair
run_corundum_verilator a
run_corundum_verilator b
sleep
0.5
run_wire ab a b
run_qemu a a build/qemu-pair-server.tar
run_qemu b b build/qemu-pair-client.tar
client_pid
=
$!
wait
$client_pid
cleanup
experiments/guests/qemu-pair-client/run.sh
0 → 100755
View file @
dcb3c952
#!/bin/bash
insmod mqnic.ko
#ifconfig eth0 192.168.64.2
ip
link set
dev eth0 up
ip addr add 192.168.64.2/24 dev eth0
sleep
2
iperf
-c
192.168.64.1
poweroff
-f
experiments/guests/qemu-pair-server/run.sh
0 → 100755
View file @
dcb3c952
#!/bin/bash
insmod mqnic.ko
ip
link set
dev eth0 up
ip addr add 192.168.64.1/24 dev eth0
iperf
-s
#shutdown -h 0
poweroff
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment