Fix macvtap issues and move to network_mode: host

Lauri Võsandi 2 years ago
parent c228d08149
commit 343b79a659
  1. 5
  2. 10
  3. 22

@ -1,4 +1,5 @@
FROM alpine
RUN apk add qemu-system-x86_64 qemu-modules bash
FROM ubuntu
# iproute2 in Alpine linux does not properly handle macvtap interfaces
RUN apt-get update && apt-get install -y qemu-kvm bash iproute2

@ -24,3 +24,13 @@ Insert Jenkins or your favourite CI/CD software SSH public keys into
`C:\ProgramData\ssh\administrators_authorized_keys` and adjust ACL-s as described
Use the resulting virtual machine disk image with this Docker image.
# Debugging
If you can't ping the VM from host, make sure bridge mode is used
on the macvlanX interface:
ip -d link show type macvtap

@ -2,14 +2,17 @@
set -x
set -e
# Create macvlan interface on Docker's eth0
ip link add link eth0 name macvtap0 type macvtap mode bridge
ip link set dev macvtap0 address ${MAC:?}
ip link set macvtap0 up
! ip link delete $MACVTAP
ip link add link $PARENT name $MACVTAP type macvtap mode bridge
ip link set dev $MACVTAP address ${MAC:?}
ip link set $MACVTAP up
# No udev in Docker
IFS=: read major minor < <(cat /sys/devices/virtual/net/macvtap0/tap*/dev)
DEV=/dev/tap$(cat /sys/class/net/macvtap0/ifindex)
IFS=: read major minor < <(cat /sys/devices/virtual/net/$MACVTAP/tap*/dev)
DEV=/dev/tap$(cat /sys/class/net/$MACVTAP/ifindex)
rm -fv $DEV
mknod $DEV c $major $minor
@ -23,7 +26,8 @@ mknod $DEV c $major $minor
-drive if=none,id=hd,file=/data/image.bin,snapshot=on,format=raw \
-device scsi-hd,drive=hd \
-usb \
-device usb-ehci,id=ehci \
-device usb-ehci,id=ehci \
-device usb-tablet,bus=usb-bus.0 \
-vnc :0 \
-netdev tap,id=hostnet0,vhost=on,fd=9 9<>$DEV
-netdev tap,id=hostnet0,fd=9 9<>$DEV \
-nographic -vga qxl
# -vnc :$OFFSET