Created
January 27, 2024 18:28
-
-
Save T-X/a47c1563d0ada581b93cb89ef13eb25e to your computer and use it in GitHub Desktop.
qemu wrapper script for Gluon/OpenWrt images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
iface="$1" | |
id="${iface##*-}" | |
echo "setting up $iface, id: $id, ret: $?" >> /tmp/error.log | |
if [ "${iface%-*}" = "vowrt-wan" ]; then | |
#if echo "$iface" | grep -q "wan"; then | |
brctl addif br0 "$iface" | |
ip link set "$iface" up | |
else | |
# lan | |
echo "setting up $iface (1), id: $id, ret: $?" >> /tmp/error.log | |
ip link set dev "$iface" netns vowrtnet-$id 2>> /tmp/error.log | |
echo "setting up $iface (2), id: $id, ret: $?" >> /tmp/error.log | |
ip netns exec "vowrtnet-$id" ip link set up dev "$iface" 2>> /tmp/error.log | |
echo "setting up $iface (3), id: $id, ret: $?" >> /tmp/error.log | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
[ $# -lt 1 ] && { | |
echo "Error: No image specified" >&2 | |
exit 1 | |
} | |
id="$2" | |
if [ -n "$id" ]; then | |
idx="$(printf "%02x" "$id")" | |
else | |
id=0 | |
idx="00" | |
fi | |
ip netns add "vowrtnet-$id" 2> /dev/null | |
#kvm -nodefaults -m 256M \ | |
#kvm | |
#qemu-system-x86_64 -enable-kvm \ | |
qemu-system-i386 \ | |
-m 1024M \ | |
-smp 4 \ | |
-hda "$1" \ | |
-device virtio-net,netdev=net0,mac=02:17:64:a4:31:$idx \ | |
-netdev tap,id=net0,ifname=vowrt-lan-$id,script=/home/linus/dev-priv/vm/setup-vowrt-iface.sh \ | |
-device virtio-net,netdev=net1,mac=02:17:64:a4:32:$idx \ | |
-netdev tap,id=net1,ifname=vowrt-wan-$id,script=/home/linus/dev-priv/vm/setup-vowrt-iface.sh \ | |
-nodefaults \ | |
-serial mon:stdio \ | |
-nographic | |
# -rtc base=localtime,clock=vm -icount shift=7,align=off,sleep=off | |
# For qemu monitor + qemu GUI: | |
# * remove: "-nodefaults", "-nographic", "-serial mon:stdio" | |
# Other useful network adapters: | |
# * e1000 or rtl8139, fastet: virtio-net |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment