diff options
| author | Bruce Ashfield <bruce.ashfield@gmail.com> | 2026-01-08 18:44:03 +0000 |
|---|---|---|
| committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2026-02-09 03:32:52 +0000 |
| commit | f367e1c738b72fd6bd9a704a11f50db838f47702 (patch) | |
| tree | b19be993722f0d1fc58fc317eba0015090f73fa9 /recipes-containers | |
| parent | dd13b2b6df049df622838aa3e5303ddbe1446fde (diff) | |
| download | meta-virtualization-f367e1c738b72fd6bd9a704a11f50db838f47702.tar.gz | |
vrunner: update static port forwarding for bridge networking
Update the static port forwarding (used at QEMU startup) to match
the dynamic QMP port forwarding change. With bridge networking:
- QEMU forwards host:port -> VM:port
- Docker's iptables handles VM:port -> container:port
Previously the static port forward went directly to the container
port (host:8080 -> VM:80), which doesn't work with bridge networking
where Docker needs to handle the final hop.
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Diffstat (limited to 'recipes-containers')
| -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 |
