diff options
| -rwxr-xr-x | recipes-containers/vcontainer/files/vrunner.sh | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/recipes-containers/vcontainer/files/vrunner.sh b/recipes-containers/vcontainer/files/vrunner.sh index a2f7a216..cf6aafd4 100755 --- a/recipes-containers/vcontainer/files/vrunner.sh +++ b/recipes-containers/vcontainer/files/vrunner.sh | |||
| @@ -1012,7 +1012,8 @@ if [ "$NETWORK" = "true" ]; then | |||
| 1012 | # Guest gets 10.0.2.15, gateway is 10.0.2.2, DNS is 10.0.2.3 | 1012 | # Guest gets 10.0.2.15, gateway is 10.0.2.2, DNS is 10.0.2.3 |
| 1013 | NETDEV_OPTS="user,id=net0" | 1013 | NETDEV_OPTS="user,id=net0" |
| 1014 | 1014 | ||
| 1015 | # Add port forwards (hostfwd=tcp::host_port-:container_port) | 1015 | # Add port forwards - QEMU forwards host:port -> VM:port |
| 1016 | # Docker's iptables handles VM:port -> container:port | ||
| 1016 | for pf in "${PORT_FORWARDS[@]}"; do | 1017 | for pf in "${PORT_FORWARDS[@]}"; do |
| 1017 | # Parse host_port:container_port or host_port:container_port/protocol | 1018 | # Parse host_port:container_port or host_port:container_port/protocol |
| 1018 | HOST_PORT="${pf%%:*}" | 1019 | HOST_PORT="${pf%%:*}" |
| @@ -1026,8 +1027,9 @@ if [ "$NETWORK" = "true" ]; then | |||
| 1026 | PROTOCOL="tcp" | 1027 | PROTOCOL="tcp" |
| 1027 | fi | 1028 | fi |
| 1028 | 1029 | ||
| 1029 | NETDEV_OPTS="$NETDEV_OPTS,hostfwd=$PROTOCOL::$HOST_PORT-:$CONTAINER_PORT" | 1030 | # Forward to HOST_PORT on VM; Docker -p handles container port mapping |
| 1030 | log "INFO" "Port forward: $HOST_PORT -> $CONTAINER_PORT ($PROTOCOL)" | 1031 | NETDEV_OPTS="$NETDEV_OPTS,hostfwd=$PROTOCOL::$HOST_PORT-:$HOST_PORT" |
| 1032 | log "INFO" "Port forward: host:$HOST_PORT -> VM:$HOST_PORT (Docker maps to container:$CONTAINER_PORT)" | ||
| 1031 | done | 1033 | done |
| 1032 | 1034 | ||
| 1033 | QEMU_OPTS="$QEMU_OPTS -netdev $NETDEV_OPTS -device virtio-net-pci,netdev=net0" | 1035 | QEMU_OPTS="$QEMU_OPTS -netdev $NETDEV_OPTS -device virtio-net-pci,netdev=net0" |
| @@ -1097,8 +1099,9 @@ if [ "$DAEMON_MODE" = "start" ]; then | |||
| 1097 | else | 1099 | else |
| 1098 | PROTOCOL="tcp" | 1100 | PROTOCOL="tcp" |
| 1099 | fi | 1101 | fi |
| 1100 | DAEMON_NETDEV="$DAEMON_NETDEV,hostfwd=$PROTOCOL::$HOST_PORT-:$CONTAINER_PORT" | 1102 | # Forward to HOST_PORT on VM; Docker -p handles container port mapping |
| 1101 | log "INFO" "Port forward: $HOST_PORT -> $CONTAINER_PORT ($PROTOCOL)" | 1103 | DAEMON_NETDEV="$DAEMON_NETDEV,hostfwd=$PROTOCOL::$HOST_PORT-:$HOST_PORT" |
| 1104 | log "INFO" "Port forward: host:$HOST_PORT -> VM:$HOST_PORT (Docker maps to container:$CONTAINER_PORT)" | ||
| 1102 | done | 1105 | done |
| 1103 | QEMU_OPTS="$QEMU_OPTS -netdev $DAEMON_NETDEV -device virtio-net-pci,netdev=net0" | 1106 | QEMU_OPTS="$QEMU_OPTS -netdev $DAEMON_NETDEV -device virtio-net-pci,netdev=net0" |
| 1104 | else | 1107 | else |
