Clean up TAP device name handling

This commit is contained in:
Lauri Võsandi 2021-05-31 18:20:56 +00:00
parent 1be0db7470
commit c228d08149

View File

@ -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