mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-11-10 03:53:42 +08:00
Compare commits
10 Commits
5fcd22b09f
...
v7.32
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c7acd6e71 | ||
|
|
ad26129375 | ||
|
|
4e7822fedd | ||
|
|
4dfcbe4ab1 | ||
|
|
8fb6f1f9ad | ||
|
|
11d4fafa6d | ||
|
|
be15557798 | ||
|
|
1e83757494 | ||
|
|
fad463a439 | ||
|
|
608563d029 |
6
.devcontainer.json
Normal file
6
.devcontainer.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"name": "dsm",
|
||||||
|
"service": "dsm",
|
||||||
|
"forwardPorts": [5000],
|
||||||
|
"dockerComposeFile": "compose.yml"
|
||||||
|
}
|
||||||
28
readme.md
28
readme.md
@@ -60,17 +60,6 @@ kubectl apply -f https://raw.githubusercontent.com/vdsm/virtual-dsm/refs/heads/m
|
|||||||
|
|
||||||
[`Click here to launch this container in the cloud!`](https://github.com/codespaces/new?skip_quickstart=true&machine=basicLinux32gb&repo=619260050&ref=master&devcontainer_path=.devcontainer.json)
|
[`Click here to launch this container in the cloud!`](https://github.com/codespaces/new?skip_quickstart=true&machine=basicLinux32gb&repo=619260050&ref=master&devcontainer_path=.devcontainer.json)
|
||||||
|
|
||||||
## Compatibility ⚙️
|
|
||||||
|
|
||||||
| **Product** | **Platform** | |
|
|
||||||
|---|---|---|
|
|
||||||
| Docker Engine | Linux | ✅ |
|
|
||||||
| Docker Desktop | Linux | ❌ |
|
|
||||||
| Docker Desktop | macOS | ❌ |
|
|
||||||
| Docker Desktop | Windows 11 | ✅ |
|
|
||||||
| Docker Desktop | Windows 10 | ❌ |
|
|
||||||
| Github Codespaces | Cloud | ✅ |
|
|
||||||
|
|
||||||
## FAQ 💬
|
## FAQ 💬
|
||||||
|
|
||||||
### How do I use it?
|
### How do I use it?
|
||||||
@@ -164,9 +153,16 @@ kubectl apply -f https://raw.githubusercontent.com/vdsm/virtual-dsm/refs/heads/m
|
|||||||
|
|
||||||
### How do I verify if my system supports KVM?
|
### How do I verify if my system supports KVM?
|
||||||
|
|
||||||
Only Linux and Windows 11 support KVM virtualization, macOS and Windows 10 do not unfortunately.
|
First check if your software is compatible using this chart:
|
||||||
|
|
||||||
You can run the following commands in Linux to check your system:
|
| **Product** | **Linux** | **Win11** | **Win10** | **macOS** |
|
||||||
|
|---|---|---|---|---|
|
||||||
|
| Docker CLI | ✅ | ✅ | ❌ | ❌ |
|
||||||
|
| Docker Desktop | ❌ | ✅ | ❌ | ❌ |
|
||||||
|
| Podman CLI | ✅ | ✅ | ❌ | ❌ |
|
||||||
|
| Podman Desktop | ✅ | ✅ | ❌ | ❌ |
|
||||||
|
|
||||||
|
After that you can run the following commands in Linux to check your system:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo apt install cpu-checker
|
sudo apt install cpu-checker
|
||||||
@@ -181,11 +177,7 @@ kubectl apply -f https://raw.githubusercontent.com/vdsm/virtual-dsm/refs/heads/m
|
|||||||
|
|
||||||
- you are not using a cloud provider, as most of them do not allow nested virtualization for their VPS's.
|
- you are not using a cloud provider, as most of them do not allow nested virtualization for their VPS's.
|
||||||
|
|
||||||
If you do not receive any error from `kvm-ok` but the container still complains about KVM, please check whether:
|
If you did not receive any error from `kvm-ok` but the container still complains about a missing KVM device, it could help to add `privileged: true` to your compose file (or `sudo` to your `docker` command) to rule out any permission issue.
|
||||||
|
|
||||||
- you are not using "Docker Desktop for Linux" as it does not support KVM, instead make use of Docker Engine directly.
|
|
||||||
|
|
||||||
- it could help to add `privileged: true` to your compose file (or `sudo` to your `docker run` command), to rule out any permission issue.
|
|
||||||
|
|
||||||
### How do I assign an individual IP address to the container?
|
### How do I assign an individual IP address to the container?
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ if [[ "$RAM_CHECK" != [Nn]* ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$DEBUG" == [Yy1]* ]]; then
|
if [[ "$DEBUG" == [Yy1]* ]]; then
|
||||||
printf "Arguments:\n\n%s" "${ARGS// -/$'\n-'}" && echo
|
printf "Arguments:\n\n%s\n\n" "${ARGS// -/$'\n-'}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ set -Eeuo pipefail
|
|||||||
|
|
||||||
if [ -f "$STORAGE/dsm.ver" ]; then
|
if [ -f "$STORAGE/dsm.ver" ]; then
|
||||||
BASE=$(<"$STORAGE/dsm.ver")
|
BASE=$(<"$STORAGE/dsm.ver")
|
||||||
|
BASE="${BASE//[![:print:]]/}"
|
||||||
[ -z "$BASE" ] && BASE="DSM_VirtualDSM_69057"
|
[ -z "$BASE" ] && BASE="DSM_VirtualDSM_69057"
|
||||||
else
|
else
|
||||||
# Fallback for old installs
|
# Fallback for old installs
|
||||||
|
|||||||
@@ -104,15 +104,21 @@ configureDHCP() {
|
|||||||
|
|
||||||
configureDNS() {
|
configureDNS() {
|
||||||
|
|
||||||
# dnsmasq configuration:
|
|
||||||
DNSMASQ_OPTS+=" --dhcp-range=$VM_NET_IP,$VM_NET_IP --dhcp-host=$VM_NET_MAC,,$VM_NET_IP,$VM_NET_HOST,infinite --dhcp-option=option:netmask,255.255.255.0"
|
|
||||||
|
|
||||||
# Create lease file for faster resolve
|
# Create lease file for faster resolve
|
||||||
echo "0 $VM_NET_MAC $VM_NET_IP $VM_NET_HOST 01:$VM_NET_MAC" > /var/lib/misc/dnsmasq.leases
|
echo "0 $VM_NET_MAC $VM_NET_IP $VM_NET_HOST 01:$VM_NET_MAC" > /var/lib/misc/dnsmasq.leases
|
||||||
chmod 644 /var/lib/misc/dnsmasq.leases
|
chmod 644 /var/lib/misc/dnsmasq.leases
|
||||||
|
|
||||||
|
# dnsmasq configuration:
|
||||||
|
DNSMASQ_OPTS+=" --dhcp-authoritative"
|
||||||
|
|
||||||
|
# Set DHCP range and host
|
||||||
|
DNSMASQ_OPTS+=" --dhcp-range=$VM_NET_IP,$VM_NET_IP"
|
||||||
|
DNSMASQ_OPTS+=" --dhcp-host=$VM_NET_MAC,,$VM_NET_IP,$VM_NET_HOST,infinite"
|
||||||
|
|
||||||
# Set DNS server and gateway
|
# Set DNS server and gateway
|
||||||
DNSMASQ_OPTS+=" --dhcp-option=option:dns-server,${VM_NET_IP%.*}.1 --dhcp-option=option:router,${VM_NET_IP%.*}.1"
|
DNSMASQ_OPTS+=" --dhcp-option=option:netmask,255.255.255.0"
|
||||||
|
DNSMASQ_OPTS+=" --dhcp-option=option:router,${VM_NET_IP%.*}.1"
|
||||||
|
DNSMASQ_OPTS+=" --dhcp-option=option:dns-server,${VM_NET_IP%.*}.1"
|
||||||
|
|
||||||
# Add DNS entry for container
|
# Add DNS entry for container
|
||||||
DNSMASQ_OPTS+=" --address=/host.lan/${VM_NET_IP%.*}.1"
|
DNSMASQ_OPTS+=" --address=/host.lan/${VM_NET_IP%.*}.1"
|
||||||
@@ -193,14 +199,16 @@ configureNAT() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -c /dev/net/tun ]; then
|
if [ ! -c /dev/net/tun ]; then
|
||||||
error "$tuntap" && return 1
|
[[ "$PODMAN" != [Yy1]* ]] && error "$tuntap"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check port forwarding flag
|
# Check port forwarding flag
|
||||||
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; rc=$?; } || :
|
{ sysctl -w net.ipv4.ip_forward=1 > /dev/null; 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
|
||||||
error "IP forwarding is disabled. $ADD_ERR --sysctl net.ipv4.ip_forward=1" && return 1
|
[[ "$PODMAN" != [Yy1]* ]] && error "IP forwarding is disabled. $ADD_ERR --sysctl net.ipv4.ip_forward=1"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -365,7 +373,13 @@ getInfo() {
|
|||||||
|
|
||||||
if [ ! -d "/sys/class/net/$VM_NET_DEV" ]; then
|
if [ ! -d "/sys/class/net/$VM_NET_DEV" ]; then
|
||||||
error "Network interface '$VM_NET_DEV' does not exist inside the container!"
|
error "Network interface '$VM_NET_DEV' does not exist inside the container!"
|
||||||
error "$ADD_ERR -e \"VM_NET_DEV=NAME\" to specify another interface name." && exit 27
|
error "$ADD_ERR -e \"VM_NET_DEV=NAME\" to specify another interface name." && exit 26
|
||||||
|
fi
|
||||||
|
|
||||||
|
BASE_IP="${VM_NET_IP%.*}."
|
||||||
|
|
||||||
|
if [ "${VM_NET_IP/$BASE_IP/}" -lt "3" ]; then
|
||||||
|
error "Invalid VM_NET_IP, must end in a higher number than .3" && exit 27
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$MTU" ]; then
|
if [ -z "$MTU" ]; then
|
||||||
@@ -385,6 +399,7 @@ getInfo() {
|
|||||||
if [ -z "$VM_NET_MAC" ]; then
|
if [ -z "$VM_NET_MAC" ]; then
|
||||||
local file="$STORAGE/dsm.mac"
|
local file="$STORAGE/dsm.mac"
|
||||||
[ -s "$file" ] && VM_NET_MAC=$(<"$file")
|
[ -s "$file" ] && VM_NET_MAC=$(<"$file")
|
||||||
|
VM_NET_MAC="${VM_NET_MAC//[![:print:]]/}"
|
||||||
if [ -z "$VM_NET_MAC" ]; then
|
if [ -z "$VM_NET_MAC" ]; then
|
||||||
# Generate MAC address based on Docker container ID in hostname
|
# Generate MAC address based on Docker container ID in hostname
|
||||||
VM_NET_MAC=$(echo "$HOST" | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:11:32:\3:\4:\5/')
|
VM_NET_MAC=$(echo "$HOST" | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:11:32:\3:\4:\5/')
|
||||||
@@ -414,6 +429,7 @@ getInfo() {
|
|||||||
[ -n "$IP6" ] && IP6=$(echo "$IP6" | sed -e's/^.*inet6 \([^ ]*\)\/.*$/\1/;t;d' | head -n 1)
|
[ -n "$IP6" ] && IP6=$(echo "$IP6" | sed -e's/^.*inet6 \([^ ]*\)\/.*$/\1/;t;d' | head -n 1)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
[ -f "/run/.containerenv" ] && PODMAN="Y" || PODMAN="N"
|
||||||
echo "$IP" > /run/shm/qemu.ip
|
echo "$IP" > /run/shm/qemu.ip
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@@ -436,7 +452,10 @@ 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)"
|
||||||
info "$line"
|
info "$line"
|
||||||
[ -f /etc/resolv.conf ] && grep '^nameserver*' /etc/resolv.conf
|
if [ -f /etc/resolv.conf ]; then
|
||||||
|
nameservers=$(grep '^nameserver*' /etc/resolv.conf | head -c -1 | sed 's/nameserver //g;' | sed -z 's/\n/, /g')
|
||||||
|
[ -n "$nameservers" ] && info "Nameservers: $nameservers"
|
||||||
|
fi
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -480,7 +499,14 @@ else
|
|||||||
|
|
||||||
closeBridge
|
closeBridge
|
||||||
NETWORK="user"
|
NETWORK="user"
|
||||||
warn "falling back to user-mode networking! Performance will be bad and port mapping will not work."
|
msg="falling back to user-mode networking!"
|
||||||
|
if [[ "$PODMAN" != [Yy1]* ]]; then
|
||||||
|
msg="an error occured, $msg"
|
||||||
|
else
|
||||||
|
msg="podman detected, $msg"
|
||||||
|
fi
|
||||||
|
warn "$msg"
|
||||||
|
[ -z "$USER_PORTS" ] && info "Notice: port mapping will not work without \"USER_PORTS\" now."
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -10,19 +10,20 @@ set -Eeuo pipefail
|
|||||||
: "${DEF_MODEL:="qemu64"}"
|
: "${DEF_MODEL:="qemu64"}"
|
||||||
|
|
||||||
CLOCKSOURCE="tsc"
|
CLOCKSOURCE="tsc"
|
||||||
[[ "${ARCH,,}" == "arm64" ]] && CLOCKSOURCE="arch_sys_counter"
|
[[ "${ARCH,,}" == "arm64" ]] && CLOCKSOURCE="arch_sys_counter"
|
||||||
CLOCK="/sys/devices/system/clocksource/clocksource0/current_clocksource"
|
CLOCK="/sys/devices/system/clocksource/clocksource0/current_clocksource"
|
||||||
|
|
||||||
if [ ! -f "$CLOCK" ]; then
|
if [ ! -f "$CLOCK" ]; then
|
||||||
warn "file \"$CLOCK\" cannot not found?"
|
warn "file \"$CLOCK\" cannot not found?"
|
||||||
else
|
else
|
||||||
result=$(<"$CLOCK")
|
result=$(<"$CLOCK")
|
||||||
|
result="${result//[![:print:]]/}"
|
||||||
case "${result,,}" in
|
case "${result,,}" in
|
||||||
"${CLOCKSOURCE,,}" ) ;;
|
"${CLOCKSOURCE,,}" ) ;;
|
||||||
"kvm-clock" ) info "Nested KVM virtualization detected.." ;;
|
"kvm-clock" ) info "Nested KVM virtualization detected.." ;;
|
||||||
"hyperv_clocksource_tsc_page" ) info "Nested Hyper-V virtualization detected.." ;;
|
"hyperv_clocksource_tsc_page" ) info "Nested Hyper-V virtualization detected.." ;;
|
||||||
"hpet" ) warn "unsupported clock source detected: '$result'. Please set host clock source to '$CLOCKSOURCE'" ;;
|
"hpet" ) warn "unsupported clock source detected: '$result'. Please set host clock source to '$CLOCKSOURCE'." ;;
|
||||||
*) warn "unexpected clock source detected: '$result'. Please set host clock source to '$CLOCKSOURCE'" ;;
|
*) warn "unexpected clock source detected: '$result'. Please set host clock source to '$CLOCKSOURCE'." ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user