mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-11-06 18:13:43 +08:00
Compare commits
5 Commits
ea49cb144b
...
6158372eaa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6158372eaa | ||
|
|
b1a778d7b2 | ||
|
|
bc0defd813 | ||
|
|
48e7a9fff0 | ||
|
|
c2fa58ef27 |
@@ -2,5 +2,5 @@
|
|||||||
"name": "dsm",
|
"name": "dsm",
|
||||||
"service": "dsm",
|
"service": "dsm",
|
||||||
"forwardPorts": [5000],
|
"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
|
||||||
@@ -124,7 +124,7 @@ kubectl apply -f https://raw.githubusercontent.com/vdsm/virtual-dsm/refs/heads/m
|
|||||||
|
|
||||||
### How do I change the amount of CPU or RAM?
|
### How do I change the amount of CPU or RAM?
|
||||||
|
|
||||||
By default, the container will be allowed to use a maximum of 2 CPU cores and 2 GB of RAM.
|
By default, Virtual DSM will be allowed to use 2 CPU cores and 2 GB of RAM.
|
||||||
|
|
||||||
If you want to adjust this, you can specify the desired amount using the following environment variables:
|
If you want to adjust this, you can specify the desired amount using the following environment variables:
|
||||||
|
|
||||||
|
|||||||
@@ -437,7 +437,7 @@ addDisk () {
|
|||||||
local SPARE=536870912
|
local SPARE=536870912
|
||||||
SPACE=$(df --output=avail -B 1 "$DIR" | tail -n 1)
|
SPACE=$(df --output=avail -B 1 "$DIR" | tail -n 1)
|
||||||
(( SPACE < SPARE )) && SPACE="$SPARE" || SPACE=$((SPACE-SPARE))
|
(( SPACE < SPARE )) && SPACE="$SPARE" || SPACE=$((SPACE-SPARE))
|
||||||
GB=$(( SPACE/1073741824 ))
|
GB=$(( SPACE/1073741825 ))
|
||||||
DISK_SPACE="${GB}G"
|
DISK_SPACE="${GB}G"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ configureDNS() {
|
|||||||
rm -f "$log"
|
rm -f "$log"
|
||||||
|
|
||||||
case "${NETWORK,,}" in
|
case "${NETWORK,,}" in
|
||||||
"nat" | "tap" | "tun" | "tuntap" | "y" )
|
"tap" | "tun" | "tuntap" | "y" )
|
||||||
|
|
||||||
# Create lease file for faster resolve
|
# Create lease file for faster resolve
|
||||||
echo "0 $mac $ip $host 01:$mac" > /var/lib/misc/dnsmasq.leases
|
echo "0 $mac $ip $host 01:$mac" > /var/lib/misc/dnsmasq.leases
|
||||||
@@ -185,14 +185,12 @@ configureDNS() {
|
|||||||
|
|
||||||
getHostPorts() {
|
getHostPorts() {
|
||||||
|
|
||||||
local list="${HOST_PORTS:-}"
|
local list=""
|
||||||
list=$(echo "${list// /}" | sed 's/,*$//g')
|
list+="$MON_PORT,"
|
||||||
list="${list//,,/,}"
|
list+="${HOST_PORTS// /},"
|
||||||
|
|
||||||
[ -z "$list" ] && list="$MON_PORT" || list+=",$MON_PORT"
|
|
||||||
|
|
||||||
# Remove duplicates
|
# Remove duplicates
|
||||||
list=$(echo "$list," | awk 'BEGIN{RS=ORS=","} !seen[$0]++' | sed 's/,*$//g')
|
list=$(echo "${list//,,/,}," | awk 'BEGIN{RS=ORS=","} !seen[$0]++' | sed 's/,*$//g')
|
||||||
|
|
||||||
echo "$list"
|
echo "$list"
|
||||||
return 0
|
return 0
|
||||||
@@ -200,33 +198,25 @@ getHostPorts() {
|
|||||||
|
|
||||||
getUserPorts() {
|
getUserPorts() {
|
||||||
|
|
||||||
local list="${USER_PORTS:-}"
|
|
||||||
list=$(echo "${list// /}" | sed 's/,*$//g')
|
|
||||||
|
|
||||||
local ssh="22"
|
local ssh="22"
|
||||||
local dsm="5000,5001"
|
local dsm="5000,5001"
|
||||||
[ -z "$list" ] && list="$ssh,$dsm" || list+=",$ssh,$dsm"
|
|
||||||
|
|
||||||
list="${list//,,/,}"
|
local list="$ssh,$dsm,"
|
||||||
list="${list//,/ }"
|
list+="${USER_PORTS// /},"
|
||||||
list="${list## }"
|
|
||||||
list="${list%% }"
|
|
||||||
|
|
||||||
local exclude
|
local exclude
|
||||||
exclude=$(getHostPorts)
|
exclude=$(getHostPorts)
|
||||||
exclude="${exclude//,/ }"
|
|
||||||
exclude="${exclude## }"
|
|
||||||
exclude="${exclude%% }"
|
|
||||||
|
|
||||||
local ports=""
|
local ports=""
|
||||||
|
local userport=""
|
||||||
|
local hostport=""
|
||||||
|
|
||||||
for userport in $list; do
|
for userport in ${list//,/ }; do
|
||||||
|
|
||||||
local num="${userport///tcp}"
|
local num="${userport///tcp}"
|
||||||
num="${num///udp}"
|
num="${num///udp}"
|
||||||
[ -z "$num" ] && continue
|
|
||||||
|
|
||||||
for hostport in $exclude; do
|
for hostport in ${exclude//,/ }; do
|
||||||
|
|
||||||
local val="${hostport///tcp}"
|
local val="${hostport///tcp}"
|
||||||
|
|
||||||
@@ -237,14 +227,12 @@ getUserPorts() {
|
|||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -n "$num" ]; then
|
[ -n "$num" ] && ports+="$userport,"
|
||||||
[ -z "$ports" ] && ports="$userport" || ports+=",$userport"
|
|
||||||
fi
|
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Remove duplicates
|
# Remove duplicates
|
||||||
ports=$(echo "$ports," | awk 'BEGIN{RS=ORS=","} !seen[$0]++' | sed 's/,*$//g')
|
ports=$(echo "${ports//,,/,}," | awk 'BEGIN{RS=ORS=","} !seen[$0]++' | sed 's/,*$//g')
|
||||||
|
|
||||||
echo "$ports"
|
echo "$ports"
|
||||||
return 0
|
return 0
|
||||||
@@ -256,14 +244,12 @@ getSlirp() {
|
|||||||
local list=""
|
local list=""
|
||||||
|
|
||||||
list=$(getUserPorts)
|
list=$(getUserPorts)
|
||||||
list="${list//,/ }"
|
|
||||||
list="${list## }"
|
|
||||||
list="${list%% }"
|
|
||||||
|
|
||||||
for port in $list; do
|
for port in ${list//,/ }; do
|
||||||
|
|
||||||
local proto="tcp"
|
local proto="tcp"
|
||||||
local num="${port%/tcp}"
|
local num="${port%/tcp}"
|
||||||
|
[ -z "$num" ] && continue
|
||||||
|
|
||||||
if [[ "$port" == *"/udp" ]]; then
|
if [[ "$port" == *"/udp" ]]; then
|
||||||
proto="udp"
|
proto="udp"
|
||||||
@@ -305,7 +291,7 @@ configureSlirp() {
|
|||||||
if [[ "${DNSMASQ_DISABLE:-}" == [Yy1]* ]]; then
|
if [[ "${DNSMASQ_DISABLE:-}" == [Yy1]* ]]; then
|
||||||
echo "$gateway" > /run/shm/qemu.gw
|
echo "$gateway" > /run/shm/qemu.gw
|
||||||
else
|
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
|
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
|
echo -e "nameserver 127.0.0.1\nsearch .\noptions ndots:0" >/etc/resolv.conf
|
||||||
fi
|
fi
|
||||||
@@ -360,7 +346,7 @@ configurePasst() {
|
|||||||
PASST_OPTS+=" -q"
|
PASST_OPTS+=" -q"
|
||||||
|
|
||||||
if [[ "${DNSMASQ_DISABLE:-}" != [Yy1]* ]]; then
|
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
|
echo -e "nameserver 127.0.0.1\nsearch .\noptions ndots:0" >/etc/resolv.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -375,8 +361,8 @@ configurePasst() {
|
|||||||
|
|
||||||
if (( rc != 0 )); then
|
if (( rc != 0 )); then
|
||||||
[ -f "$log" ] && cat "$log"
|
[ -f "$log" ] && cat "$log"
|
||||||
error "Failed to start passt, reason: $rc"
|
warn "failed to start passt ($rc), falling back to slirp networking!"
|
||||||
return 1
|
configureSlirp && return 0 || return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
@@ -800,7 +786,7 @@ else
|
|||||||
|
|
||||||
case "${NETWORK,,}" in
|
case "${NETWORK,,}" in
|
||||||
"user"* | "passt" | "slirp" ) ;;
|
"user"* | "passt" | "slirp" ) ;;
|
||||||
"nat" | "tap" | "tun" | "tuntap" | "y" )
|
"tap" | "tun" | "tuntap" | "y" )
|
||||||
|
|
||||||
# Configure tap interface
|
# Configure tap interface
|
||||||
if ! configureNAT; then
|
if ! configureNAT; then
|
||||||
@@ -817,7 +803,7 @@ else
|
|||||||
[[ "${NETWORK,,}" == "user"* ]] && NETWORK="passt"
|
[[ "${NETWORK,,}" == "user"* ]] && NETWORK="passt"
|
||||||
|
|
||||||
case "${NETWORK,,}" in
|
case "${NETWORK,,}" in
|
||||||
"nat" | "tap" | "tun" | "tuntap" | "y" ) ;;
|
"tap" | "tun" | "tuntap" | "y" ) ;;
|
||||||
"passt" )
|
"passt" )
|
||||||
|
|
||||||
# Configure for user-mode networking (passt)
|
# Configure for user-mode networking (passt)
|
||||||
|
|||||||
Reference in New Issue
Block a user