qemu-boot.sh: Add support for booting RPi

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2017-03-25 15:10:42 +00:00
commit 94c9cbd77f

View file

@ -63,10 +63,12 @@ list_hostnames()
boot_net() boot_net()
{ {
local mac
[ "$hostname" ] && { [ "$hostname" ] && {
set -x set -x
macaddr=`ldap_search -LLL "(cn=$short_hostname) dhcpHWAddress" | mac=`ldap_search -LLL "(cn=$short_hostname) dhcpHWAddress" |
sed '/dhcpHWAddress:/ !d; s/dhcpHWAddress: ethernet *//'` sed '/dhcpHWAddress:/ !d; s/dhcpHWAddress: ethernet *//'`
macaddr=",macaddr=$mac"
} }
ps aux | grep -v grep | grep -q dhcpd || /etc/init.d/dhcpd start ps aux | grep -v grep | grep -q dhcpd || /etc/init.d/dhcpd start
@ -79,7 +81,7 @@ boot_net()
do_sudo -E /usr/bin/$qemu_exe \ do_sudo -E /usr/bin/$qemu_exe \
-boot n \ -boot n \
-net tap,ifname=tap0,vlan=0,script=$tmpdir/qemu-ifup,downscript=$tmpdir/qemu-ifdown \ -net tap,ifname=tap0,vlan=0,script=$tmpdir/qemu-ifup,downscript=$tmpdir/qemu-ifdown \
-net nic,vlan=0$nic_model,macaddr=$macaddr \ -net nic,vlan=0$nic_model$macaddr \
"$qemu_opts" "$qemu_opts"
# invalid param macaddr # invalid param macaddr
@ -102,13 +104,14 @@ boot_image()
test -r "$boot_image" || fatal "inaccessible boot image \"$boot_image\"" test -r "$boot_image" || fatal "inaccessible boot image \"$boot_image\""
#-net bridge,br=$bridge \ #-net bridge,br=$bridge \
#-net nic,vlan=1$nic_model,macaddr=00:02:36:22:13:6c \
#-net tap,ifname=tap1,vlan=1,script=$tmpdir/qemu-ifup,downscript=$tmpdir/qemu-ifdown \
set -x
do_sudo -E /usr/bin/$qemu_exe \ do_sudo -E /usr/bin/$qemu_exe \
-net nic,vlan=0$nic_model,macaddr=00:02:36:22:13:6b \ -net nic,vlan=0$nic_model$macaddr \
-net nic,vlan=1$nic_model,macaddr=00:02:36:22:13:6c \
-net tap,ifname=tap0,vlan=0,script=$tmpdir/qemu-ifup,downscript=$tmpdir/qemu-ifdown \ -net tap,ifname=tap0,vlan=0,script=$tmpdir/qemu-ifup,downscript=$tmpdir/qemu-ifdown \
-net tap,ifname=tap1,vlan=1,script=$tmpdir/qemu-ifup,downscript=$tmpdir/qemu-ifdown \
"$qemu_opts" \ "$qemu_opts" \
-drive format=raw,file=$boot_image -drive file=$boot_image
} }
boot() boot()
@ -120,7 +123,7 @@ boot()
ln -s $exe qemu-ifdown ln -s $exe qemu-ifdown
) )
do_sudo /sbin/modprobe kvm-intel #do_sudo /sbin/modprobe kvm-intel
xhost + xhost +
case $1 in case $1 in
@ -144,7 +147,7 @@ exe=`readlink -f $0`
dirname=`dirname $exe` dirname=`dirname $exe`
bridge=priv0 bridge=priv0
#bridge=in1 #bridge=in1
macaddr=00:0B:DC:9B:D6:DA macaddr=,macaddr=00:0B:DC:9B:D6:DA
base=dc=priv,dc=lcl base=dc=priv,dc=lcl
qemu_exe=qemu-kvm qemu_exe=qemu-kvm
qemu_opts="" qemu_opts=""
@ -156,7 +159,7 @@ tmpdir=""
trap goodbye INT QUIT EXIT KILL TERM PIPE trap goodbye INT QUIT EXIT KILL TERM PIPE
OPTIND=1 OPTIND=1
while getopts lhb:o:x:n:B: flag; do while getopts lhb:o:x:n:B:M: flag; do
case $flag in case $flag in
h) h)
usage 0;; usage 0;;
@ -177,6 +180,9 @@ while getopts lhb:o:x:n:B: flag; do
nic_model=",model=$OPTARG";; nic_model=",model=$OPTARG";;
B) B)
bridge=$OPTARG;; bridge=$OPTARG;;
M)
macaddr=",macaddr=$OPTARG";;
*) *)
usage 1;; usage 1;;
esac esac