mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-06-07 00:48:23 +08:00
Compare commits
3 Commits
52fe712b6f
...
3675a50129
Author | SHA1 | Date | |
---|---|---|---|
|
3675a50129 | ||
|
91229152bd | ||
|
a1993e590a |
@ -37,6 +37,7 @@ RUN set -eu && extra="" && \
|
||||
net-tools \
|
||||
e2fsprogs \
|
||||
qemu-utils \
|
||||
iputils-ping \
|
||||
ca-certificates \
|
||||
netcat-openbsd \
|
||||
qemu-system-x86 \
|
||||
|
@ -4,6 +4,7 @@ set -Eeuo pipefail
|
||||
# Docker environment variables
|
||||
|
||||
: "${MAC:=""}"
|
||||
: "${MTU:=""}"
|
||||
: "${DHCP:="N"}"
|
||||
: "${NETWORK:="Y"}"
|
||||
: "${USER_PORTS:=""}"
|
||||
@ -58,6 +59,10 @@ configureDHCP() {
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
if ! ip link set dev "$VM_NET_TAP" mtu "$MTU"; then
|
||||
warn "Failed to set MTU size.."
|
||||
fi
|
||||
|
||||
while ! ip link set "$VM_NET_TAP" up; do
|
||||
info "Waiting for MAC address $VM_NET_MAC to become available..."
|
||||
sleep 2
|
||||
@ -213,8 +218,11 @@ configureNAT() {
|
||||
error "$tuntap" && return 1
|
||||
fi
|
||||
|
||||
GATEWAY_MAC=$(echo "$VM_NET_MAC" | rev)
|
||||
GATEWAY_MAC="02:${GATEWAY_MAC:0:14}"
|
||||
if ! ip link set dev "$VM_NET_TAP" mtu "$MTU"; then
|
||||
warn "Failed to set MTU size.."
|
||||
fi
|
||||
|
||||
GATEWAY_MAC=$(echo "$VM_NET_MAC" | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/')
|
||||
|
||||
if ! ip link set dev "$VM_NET_TAP" address "$GATEWAY_MAC"; then
|
||||
warn "Failed to set gateway MAC address.."
|
||||
@ -345,6 +353,10 @@ getInfo() {
|
||||
error "$ADD_ERR -e \"VM_NET_DEV=NAME\" to specify another interface name." && exit 27
|
||||
fi
|
||||
|
||||
if [ -z "$MTU" ]; then
|
||||
MTU=$(cat "/sys/class/net/$VM_NET_DEV/mtu")
|
||||
fi
|
||||
|
||||
if [ -z "$VM_NET_MAC" ]; then
|
||||
local file="$STORAGE/dsm.mac"
|
||||
[ -s "$file" ] && VM_NET_MAC=$(<"$file")
|
||||
@ -387,7 +399,7 @@ getInfo
|
||||
html "Initializing network..."
|
||||
|
||||
if [[ "$DEBUG" == [Yy1]* ]]; then
|
||||
info "Host: $HOST IP: $IP Gateway: $GATEWAY Interface: $VM_NET_DEV MAC: $VM_NET_MAC"
|
||||
info "Host: $HOST IP: $IP Gateway: $GATEWAY Interface: $VM_NET_DEV MAC: $VM_NET_MAC MTU: $MTU"
|
||||
[ -f /etc/resolv.conf ] && grep '^nameserver*' /etc/resolv.conf
|
||||
echo
|
||||
fi
|
||||
@ -452,6 +464,6 @@ else
|
||||
|
||||
fi
|
||||
|
||||
NET_OPTS+=" -device $ADAPTER,romfile=,netdev=hostnet0,mac=$VM_NET_MAC,id=net0"
|
||||
NET_OPTS+=" -device $ADAPTER,romfile=,netdev=hostnet0,mac=$VM_NET_MAC,host_mtu=$MTU,id=net0"
|
||||
|
||||
return 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user