mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-11-07 02:23:42 +08:00
Compare commits
7 Commits
1ffc5c55b2
...
v7.45
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc0defd813 | ||
|
|
48e7a9fff0 | ||
|
|
c2fa58ef27 | ||
|
|
ea49cb144b | ||
|
|
b8e778a79d | ||
|
|
c70e12f0a2 | ||
|
|
6281205912 |
@@ -2,5 +2,5 @@
|
||||
"name": "dsm",
|
||||
"service": "dsm",
|
||||
"forwardPorts": [5000],
|
||||
"dockerComposeFile": "compose.yml"
|
||||
"dockerComposeFile": ".github/codespaces.yml"
|
||||
}
|
||||
|
||||
19
.github/codespaces.yml
vendored
Normal file
19
.github/codespaces.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
services:
|
||||
dsm:
|
||||
container_name: dsm
|
||||
image: vdsm/virtual-dsm
|
||||
environment:
|
||||
RAM_SIZE: "max"
|
||||
DISK_SIZE: "max"
|
||||
CPU_CORES: "max"
|
||||
devices:
|
||||
- /dev/kvm
|
||||
- /dev/net/tun
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
ports:
|
||||
- 5000:5000
|
||||
volumes:
|
||||
- ./dsm:/storage
|
||||
restart: on-failure
|
||||
stop_grace_period: 2m
|
||||
16
src/disk.sh
16
src/disk.sh
@@ -98,10 +98,10 @@ createDisk() {
|
||||
local FS=$5
|
||||
local DATA_SIZE DIR SPACE GB FA
|
||||
|
||||
DATA_SIZE=$(numfmt --from=iec "$DISK_SPACE")
|
||||
|
||||
rm -f "$DISK_FILE"
|
||||
|
||||
DATA_SIZE=$(numfmt --from=iec "$DISK_SPACE")
|
||||
|
||||
if [[ "$ALLOCATE" != [Nn]* ]]; then
|
||||
|
||||
# Check free diskspace
|
||||
@@ -424,7 +424,7 @@ addDisk () {
|
||||
local DISK_FMT=$7
|
||||
local DISK_IO=$8
|
||||
local DISK_CACHE=$9
|
||||
local DISK_EXT DIR SPACE DATA_SIZE FS PREV_FMT PREV_EXT CUR_SIZE
|
||||
local DISK_EXT DIR SPACE GB DATA_SIZE FS PREV_FMT PREV_EXT CUR_SIZE
|
||||
|
||||
DISK_EXT=$(fmt2ext "$DISK_FMT")
|
||||
local DISK_FILE="$DISK_BASE.$DISK_EXT"
|
||||
@@ -432,6 +432,16 @@ addDisk () {
|
||||
DIR=$(dirname "$DISK_FILE")
|
||||
[ ! -d "$DIR" ] && return 0
|
||||
|
||||
if [[ "${DISK_SPACE,,}" == "max" ]]; then
|
||||
|
||||
local SPARE=536870912
|
||||
SPACE=$(df --output=avail -B 1 "$DIR" | tail -n 1)
|
||||
(( SPACE < SPARE )) && SPACE="$SPARE" || SPACE=$((SPACE-SPARE))
|
||||
GB=$(( SPACE/1073741825 ))
|
||||
DISK_SPACE="${GB}G"
|
||||
|
||||
fi
|
||||
|
||||
SPACE="${DISK_SPACE// /}"
|
||||
[ -z "$SPACE" ] && SPACE="16G"
|
||||
[ -z "${SPACE//[0-9. ]}" ] && SPACE="${SPACE}G"
|
||||
|
||||
@@ -185,10 +185,12 @@ configureDNS() {
|
||||
|
||||
getHostPorts() {
|
||||
|
||||
local list="$1"
|
||||
list=$(echo "${list// /}" | sed 's/,*$//g')
|
||||
local list=""
|
||||
list+="$MON_PORT,"
|
||||
list+="${HOST_PORTS// /},"
|
||||
|
||||
[ -z "$list" ] && list="$MON_PORT" || list+=",$MON_PORT"
|
||||
# Remove duplicates
|
||||
list=$(echo "${list//,,/,}," | awk 'BEGIN{RS=ORS=","} !seen[$0]++' | sed 's/,*$//g')
|
||||
|
||||
echo "$list"
|
||||
return 0
|
||||
@@ -196,15 +198,43 @@ getHostPorts() {
|
||||
|
||||
getUserPorts() {
|
||||
|
||||
local args=""
|
||||
local list=$1
|
||||
list=$(echo "${list// /}" | sed 's/,*$//g')
|
||||
|
||||
local ssh="22"
|
||||
local dsm="5000"
|
||||
[ -z "$list" ] && list="$ssh,$dsm" || list+=",$ssh,$dsm"
|
||||
local dsm="5000,5001"
|
||||
|
||||
echo "$list"
|
||||
local list="$ssh,$dsm,"
|
||||
list+="${USER_PORTS// /},"
|
||||
|
||||
local exclude
|
||||
exclude=$(getHostPorts)
|
||||
|
||||
local ports=""
|
||||
local userport=""
|
||||
local hostport=""
|
||||
|
||||
for userport in ${list//,/ }; do
|
||||
|
||||
local num="${userport///tcp}"
|
||||
num="${num///udp}"
|
||||
|
||||
for hostport in ${exclude//,/ }; do
|
||||
|
||||
local val="${hostport///tcp}"
|
||||
|
||||
if [[ "$num" == "${val///udp}" ]]; then
|
||||
num=""
|
||||
warn "Could not assign port ${val///udp} to \"USER_PORTS\" because it is already in \"HOST_PORTS\"!"
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
[ -n "$num" ] && ports+="$userport,"
|
||||
|
||||
done
|
||||
|
||||
# Remove duplicates
|
||||
ports=$(echo "${ports//,,/,}," | awk 'BEGIN{RS=ORS=","} !seen[$0]++' | sed 's/,*$//g')
|
||||
|
||||
echo "$ports"
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -214,14 +244,12 @@ getSlirp() {
|
||||
local list=""
|
||||
|
||||
list=$(getUserPorts)
|
||||
list="${list//,/ }"
|
||||
list="${list## }"
|
||||
list="${list%% }"
|
||||
|
||||
for port in $list; do
|
||||
for port in ${list//,/ }; do
|
||||
|
||||
proto="tcp"
|
||||
num="${port%/tcp}"
|
||||
local proto="tcp"
|
||||
local num="${port%/tcp}"
|
||||
[ -z "$num" ] && continue
|
||||
|
||||
if [[ "$port" == *"/udp" ]]; then
|
||||
proto="udp"
|
||||
@@ -235,6 +263,8 @@ getSlirp() {
|
||||
args+="hostfwd=$proto::$num-$VM_NET_IP:$num,"
|
||||
done
|
||||
|
||||
args=$(echo "$args" | sed 's/,*$//g')
|
||||
|
||||
echo "${args%?}"
|
||||
return 0
|
||||
}
|
||||
@@ -255,13 +285,13 @@ configureSlirp() {
|
||||
NET_OPTS="-netdev user,id=hostnet0,ipv4=on,host=$gateway,net=${gateway%.*}.0/24,dhcpstart=$ip,${ipv6}hostname=$VM_NET_HOST"
|
||||
|
||||
local forward=""
|
||||
forward=$(getUserPorts "${USER_PORTS:-}")
|
||||
forward=$(getSlirp)
|
||||
[ -n "$forward" ] && NET_OPTS+=",$forward"
|
||||
|
||||
if [[ "${DNSMASQ_DISABLE:-}" == [Yy1]* ]]; then
|
||||
echo "$gateway" > /run/shm/qemu.gw
|
||||
else
|
||||
cp /etc/resolv.conf /etc/resolv.dnsmasq
|
||||
[ ! -f /etc/resolv.dnsmasq ] && cp /etc/resolv.conf /etc/resolv.dnsmasq
|
||||
configureDNS "lo" "$ip" "$VM_NET_MAC" "$VM_NET_HOST" "$VM_NET_MASK" "$gateway" || return 1
|
||||
echo -e "nameserver 127.0.0.1\nsearch .\noptions ndots:0" >/etc/resolv.conf
|
||||
fi
|
||||
@@ -299,7 +329,7 @@ configurePasst() {
|
||||
[ -n "$PASST_MTU" ] && PASST_OPTS+=" -m $PASST_MTU"
|
||||
|
||||
local forward=""
|
||||
forward=$(getUserPorts "${USER_PORTS:-}")
|
||||
forward=$(getUserPorts)
|
||||
forward="${forward///tcp}"
|
||||
forward="${forward///udp}"
|
||||
|
||||
@@ -316,7 +346,7 @@ configurePasst() {
|
||||
PASST_OPTS+=" -q"
|
||||
|
||||
if [[ "${DNSMASQ_DISABLE:-}" != [Yy1]* ]]; then
|
||||
cp /etc/resolv.conf /etc/resolv.dnsmasq
|
||||
[ ! -f /etc/resolv.dnsmasq ] && cp /etc/resolv.conf /etc/resolv.dnsmasq
|
||||
echo -e "nameserver 127.0.0.1\nsearch .\noptions ndots:0" >/etc/resolv.conf
|
||||
fi
|
||||
|
||||
@@ -331,8 +361,8 @@ configurePasst() {
|
||||
|
||||
if (( rc != 0 )); then
|
||||
[ -f "$log" ] && cat "$log"
|
||||
error "Failed to start passt, reason: $rc"
|
||||
return 1
|
||||
warn "failed to start passt ($rc), falling back to slirp networking!"
|
||||
configureSlirp && return 0 || return 1
|
||||
fi
|
||||
|
||||
fi
|
||||
@@ -447,7 +477,7 @@ configureNAT() {
|
||||
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy > /dev/null
|
||||
fi
|
||||
|
||||
exclude=$(getHostPorts "$HOST_PORTS")
|
||||
exclude=$(getHostPorts)
|
||||
|
||||
if [ -n "$exclude" ]; then
|
||||
if [[ "$exclude" != *","* ]]; then
|
||||
|
||||
Reference in New Issue
Block a user