mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-06-06 00:19:06 +08:00
fix: Network shutdown (#912)
This commit is contained in:
parent
a1e9936572
commit
bfc8d7a9c6
@ -199,7 +199,6 @@ configureNAT() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Create a bridge with a static IP for the VM guest
|
# Create a bridge with a static IP for the VM guest
|
||||||
|
|
||||||
{ ip link add dev dockerbridge type bridge ; rc=$?; } || :
|
{ ip link add dev dockerbridge type bridge ; rc=$?; } || :
|
||||||
|
|
||||||
if (( rc != 0 )); then
|
if (( rc != 0 )); then
|
||||||
@ -279,6 +278,22 @@ configureNAT() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closeBridge() {
|
||||||
|
|
||||||
|
local pid="/var/run/dnsmasq.pid"
|
||||||
|
[ -s "$pid" ] && pKill "$(<"$pid")"
|
||||||
|
|
||||||
|
[[ "${NETWORK,,}" == "user"* ]] && return 0
|
||||||
|
|
||||||
|
ip link set "$VM_NET_TAP" down promisc off &> null || true
|
||||||
|
ip link delete "$VM_NET_TAP" &> null || true
|
||||||
|
|
||||||
|
ip link set dockerbridge down &> null || true
|
||||||
|
ip link delete dockerbridge &> null || true
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
closeNetwork() {
|
closeNetwork() {
|
||||||
|
|
||||||
if [[ "$DHCP" == [Yy1]* ]]; then
|
if [[ "$DHCP" == [Yy1]* ]]; then
|
||||||
@ -294,26 +309,16 @@ closeNetwork() {
|
|||||||
exec 30<&- || true
|
exec 30<&- || true
|
||||||
exec 40<&- || true
|
exec 40<&- || true
|
||||||
|
|
||||||
if [[ "$DHCP" == [Yy1]* ]]; then
|
if [[ "$DHCP" != [Yy1]* ]]; then
|
||||||
|
|
||||||
ip link set "$VM_NET_TAP" down || true
|
closeBridge
|
||||||
ip link delete "$VM_NET_TAP" || true
|
return 0
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
local pid="/var/run/dnsmasq.pid"
|
|
||||||
[ -s "$pid" ] && pKill "$(<"$pid")"
|
|
||||||
|
|
||||||
[[ "${NETWORK,,}" == "user"* ]] && return 0
|
|
||||||
|
|
||||||
ip link set "$VM_NET_TAP" down promisc off || true
|
|
||||||
ip link delete "$VM_NET_TAP" || true
|
|
||||||
|
|
||||||
ip link set dockerbridge down || true
|
|
||||||
ip link delete dockerbridge || true
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ip link set "$VM_NET_TAP" down || true
|
||||||
|
ip link delete "$VM_NET_TAP" || true
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -459,15 +464,10 @@ else
|
|||||||
# Configure for tap interface
|
# Configure for tap interface
|
||||||
if ! configureNAT; then
|
if ! configureNAT; then
|
||||||
|
|
||||||
|
closeBridge
|
||||||
NETWORK="user"
|
NETWORK="user"
|
||||||
warn "falling back to usermode networking! Performance will be bad and port mapping will not work."
|
warn "falling back to usermode networking! Performance will be bad and port mapping will not work."
|
||||||
|
|
||||||
ip link set "$VM_NET_TAP" down promisc off &> null || true
|
|
||||||
ip link delete "$VM_NET_TAP" &> null || true
|
|
||||||
|
|
||||||
ip link set dockerbridge down &> null || true
|
|
||||||
ip link delete dockerbridge &> null || true
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user