From c228d08149dead7db024d7aa84de6dfcb89164e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauri=20V=C3=B5sandi?= Date: Mon, 31 May 2021 18:20:56 +0000 Subject: [PATCH] Clean up TAP device name handling --- entrypoint.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 93dd32e..17963b9 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -9,14 +9,16 @@ ip link set macvtap0 up # No udev in Docker IFS=: read major minor < <(cat /sys/devices/virtual/net/macvtap0/tap*/dev) -mknod "/dev/tap$(cat /sys/class/net/macvtap0/ifindex)" c $major $minor +DEV=/dev/tap$(cat /sys/class/net/macvtap0/ifindex) +rm -fv $DEV +mknod $DEV c $major $minor # Launch QEMU instance /usr/bin/qemu-system-x86_64 \ -machine pc-i440fx-4.2,accel=kvm \ -m 8192 \ -device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x6 \ - -device virtio-net-pci,netdev=hostnet0,id=net0,mac=$(cat /sys/class/net/macvtap0/address) \ + -device virtio-net-pci,netdev=hostnet0,id=net0,mac=$MAC \ -device virtio-balloon-pci \ -drive if=none,id=hd,file=/data/image.bin,snapshot=on,format=raw \ -device scsi-hd,drive=hd \ @@ -24,4 +26,4 @@ mknod "/dev/tap$(cat /sys/class/net/macvtap0/ifindex)" c $major $minor -device usb-ehci,id=ehci \ -device usb-tablet,bus=usb-bus.0 \ -vnc :0 \ - -netdev tap,id=hostnet0,vhost=on,fd=9 9<>/dev/tap$(cat /sys/class/net/macvtap0/ifindex) + -netdev tap,id=hostnet0,vhost=on,fd=9 9<>$DEV