mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-11-05 17:44:52 +08:00
Compare commits
2 Commits
8b145924b9
...
5e8bbc2868
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e8bbc2868 | ||
|
|
4e48920309 |
@ -31,7 +31,6 @@ if [ -n "$URL" ] && [ ! -s "$FILE" ] && [ ! -d "$DIR" ]; then
|
|||||||
BASE=$(basename "$URL" .pat)
|
BASE=$(basename "$URL" .pat)
|
||||||
if [ ! -s "$STORAGE/$BASE.system.img" ]; then
|
if [ ! -s "$STORAGE/$BASE.system.img" ]; then
|
||||||
BASE=$(basename "${URL%%\?*}" .pat)
|
BASE=$(basename "${URL%%\?*}" .pat)
|
||||||
BASE="${BASE//+/ }"
|
|
||||||
printf -v BASE '%b' "${BASE//%/\\x}"
|
printf -v BASE '%b' "${BASE//%/\\x}"
|
||||||
BASE="${BASE//[!A-Za-z0-9._-]/_}"
|
BASE="${BASE//[!A-Za-z0-9._-]/_}"
|
||||||
fi
|
fi
|
||||||
@ -66,7 +65,6 @@ fi
|
|||||||
|
|
||||||
if [ ! -s "$FILE" ]; then
|
if [ ! -s "$FILE" ]; then
|
||||||
BASE=$(basename "${URL%%\?*}" .pat)
|
BASE=$(basename "${URL%%\?*}" .pat)
|
||||||
BASE="${BASE//+/ }"
|
|
||||||
printf -v BASE '%b' "${BASE//%/\\x}"
|
printf -v BASE '%b' "${BASE//%/\\x}"
|
||||||
BASE="${BASE//[!A-Za-z0-9._-]/_}"
|
BASE="${BASE//[!A-Za-z0-9._-]/_}"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -403,7 +403,6 @@ configureNAT() {
|
|||||||
|
|
||||||
# Create the necessary file structure for /dev/net/tun
|
# Create the necessary file structure for /dev/net/tun
|
||||||
if [ ! -c /dev/net/tun ]; then
|
if [ ! -c /dev/net/tun ]; then
|
||||||
[[ "$PODMAN" == [Yy1]* ]] && return 1
|
|
||||||
[ ! -d /dev/net ] && mkdir -m 755 /dev/net
|
[ ! -d /dev/net ] && mkdir -m 755 /dev/net
|
||||||
if mknod /dev/net/tun c 10 200; then
|
if mknod /dev/net/tun c 10 200; then
|
||||||
chmod 666 /dev/net/tun
|
chmod 666 /dev/net/tun
|
||||||
@ -411,6 +410,7 @@ configureNAT() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -c /dev/net/tun ]; then
|
if [ ! -c /dev/net/tun ]; then
|
||||||
|
[[ "$PODMAN" == [Yy1]* ]] && return 1
|
||||||
warn "$tuntap" && return 1
|
warn "$tuntap" && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -418,6 +418,7 @@ configureNAT() {
|
|||||||
if [[ $(< /proc/sys/net/ipv4/ip_forward) -eq 0 ]]; then
|
if [[ $(< /proc/sys/net/ipv4/ip_forward) -eq 0 ]]; then
|
||||||
{ sysctl -w net.ipv4.ip_forward=1 > /dev/null 2>&1; rc=$?; } || :
|
{ sysctl -w net.ipv4.ip_forward=1 > /dev/null 2>&1; rc=$?; } || :
|
||||||
if (( rc != 0 )) || [[ $(< /proc/sys/net/ipv4/ip_forward) -eq 0 ]]; then
|
if (( rc != 0 )) || [[ $(< /proc/sys/net/ipv4/ip_forward) -eq 0 ]]; then
|
||||||
|
[[ "$PODMAN" == [Yy1]* ]] && return 1
|
||||||
warn "IP forwarding is disabled. $ADD_ERR --sysctl net.ipv4.ip_forward=1"
|
warn "IP forwarding is disabled. $ADD_ERR --sysctl net.ipv4.ip_forward=1"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -444,6 +445,7 @@ configureNAT() {
|
|||||||
{ ip link add dev "$VM_NET_BRIDGE" type bridge ; rc=$?; } || :
|
{ ip link add dev "$VM_NET_BRIDGE" type bridge ; rc=$?; } || :
|
||||||
|
|
||||||
if (( rc != 0 )); then
|
if (( rc != 0 )); then
|
||||||
|
[[ "$PODMAN" == [Yy1]* ]] && return 1
|
||||||
warn "failed to create bridge. $ADD_ERR --cap-add NET_ADMIN" && return 1
|
warn "failed to create bridge. $ADD_ERR --cap-add NET_ADMIN" && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -458,6 +460,7 @@ configureNAT() {
|
|||||||
|
|
||||||
# QEMU Works with taps, set tap to the bridge created
|
# QEMU Works with taps, set tap to the bridge created
|
||||||
if ! ip tuntap add dev "$VM_NET_TAP" mode tap; then
|
if ! ip tuntap add dev "$VM_NET_TAP" mode tap; then
|
||||||
|
[[ "$PODMAN" == [Yy1]* ]] && return 1
|
||||||
warn "$tuntap" && return 1
|
warn "$tuntap" && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -737,13 +740,6 @@ getInfo() {
|
|||||||
|
|
||||||
GATEWAY_MAC=$(echo "$VM_NET_MAC" | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/')
|
GATEWAY_MAC=$(echo "$VM_NET_MAC" | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/')
|
||||||
|
|
||||||
if [[ "$PODMAN" == [Yy1]* && "$DHCP" != [Yy1]* ]]; then
|
|
||||||
if [ -z "$NETWORK" ] || [[ "${NETWORK^^}" == "Y" ]]; then
|
|
||||||
# By default Podman has no permissions for NAT networking
|
|
||||||
NETWORK="user"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$DEBUG" == [Yy1]* ]]; then
|
if [[ "$DEBUG" == [Yy1]* ]]; then
|
||||||
line="Host: $HOST IP: $IP Gateway: $GATEWAY Interface: $VM_NET_DEV MAC: $VM_NET_MAC MTU: $mtu"
|
line="Host: $HOST IP: $IP Gateway: $GATEWAY Interface: $VM_NET_DEV MAC: $VM_NET_MAC MTU: $mtu"
|
||||||
[[ "$MTU" != "0" && "$MTU" != "$mtu" ]] && line+=" ($MTU)"
|
[[ "$MTU" != "0" && "$MTU" != "$mtu" ]] && line+=" ($MTU)"
|
||||||
@ -805,8 +801,12 @@ else
|
|||||||
|
|
||||||
closeBridge
|
closeBridge
|
||||||
NETWORK="user"
|
NETWORK="user"
|
||||||
msg="falling back to user-mode networking!"
|
|
||||||
msg="failed to setup NAT networking, $msg"
|
if [[ "$PODMAN" != [Yy1]* ]]; then
|
||||||
|
msg="falling back to user-mode networking!"
|
||||||
|
msg="failed to setup NAT networking, $msg"
|
||||||
|
warn "$msg"
|
||||||
|
fi
|
||||||
|
|
||||||
fi ;;
|
fi ;;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user