Fix macvtap issues and move to network_mode: host

This commit is contained in:
Lauri Võsandi 2021-06-11 07:44:26 +00:00
parent c228d08149
commit 343b79a659
3 changed files with 26 additions and 11 deletions

View File

@ -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
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT /entrypoint.sh

View File

@ -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
[here](https://www.concurrency.com/blog/may-2019/key-based-authentication-for-openssh-on-windows)
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
```

View File

@ -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
PARENT=bond0.1
MACVTAP=macvtap$OFFSET
! 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