Compare commits

...

21 Commits
v4.19 ... v4.20

Author SHA1 Message Date
Kroese
44d3e23545 feat: Update to QEMU 8.1
feat: Update to QEMU 8.1
2023-10-17 19:44:54 +02:00
Kroese
d340361320 fix: Skip gateway check in debug mode 2023-10-17 19:37:39 +02:00
Kroese
f8f8c16200 fix: Don't store agent version 2023-10-17 19:32:34 +02:00
Kroese
47fd7931eb style: Shutdown counter 2023-10-17 19:28:37 +02:00
Kroese
7ac9c242da fix: Remove agent check 2023-10-17 19:24:42 +02:00
Kroese
78d330055f fix: Remove agent check 2023-10-17 19:12:06 +02:00
Kroese
06cf0a4edc build: Update to QEMU 8.1 (Debian 13) 2023-10-17 19:05:22 +02:00
Kroese
e26c208cc7 feat: OpenGL module 2023-10-17 19:01:08 +02:00
Kroese
c2f4823d8b build: Dockerfile
build: Dockerfile
2023-10-17 01:40:00 +02:00
Kroese
ca01bf8cb9 build: Dockerfile 2023-10-17 01:39:44 +02:00
Kroese
a5b2b655dd build: Dockerfile
build: Dockerfile
2023-10-16 17:44:51 +02:00
Kroese
0f2f3b2ea8 build: Dockerfile 2023-10-16 17:44:36 +02:00
Kroese
0705c1c21b build: Dockerfile
build: Dockerfile
2023-10-16 16:51:55 +02:00
Kroese
e4de05ce88 build: Dockerfile 2023-10-16 16:51:23 +02:00
Kroese
a24b62ae67 docs: Readme
docs: Readme
2023-10-16 01:10:41 +02:00
Kroese
b5a9361b68 docs: Readme 2023-10-16 01:10:23 +02:00
Kroese
0e35e4a6d9 docs: Readme
docs: Readme
2023-10-16 00:41:53 +02:00
Kroese
208a6e6636 docs: Readme 2023-10-16 00:41:14 +02:00
Kroese
3fec9bf5ef docs: Readme
docs: Readme
2023-10-10 07:35:32 +02:00
Kroese
8d8efeb341 docs: Readme 2023-10-10 07:34:44 +02:00
Kroese
e9f27899a6 fix: Shutdown counter 2023-10-10 07:00:43 +02:00
7 changed files with 68 additions and 70 deletions

View File

@@ -7,16 +7,16 @@ FROM qemux/qemu-host as builder
# RUN go mod download # RUN go mod download
# RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o /qemu-host.bin . # RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o /qemu-host.bin .
FROM debian:bookworm-slim FROM debian:trixie-slim
ARG DEBCONF_NOWARNINGS="yes" ARG DEBCONF_NOWARNINGS="yes"
ARG DEBIAN_FRONTEND noninteractive ARG DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get -y upgrade && \ RUN apt-get update && apt-get -y upgrade && \
apt-get --no-install-recommends -y install \ apt-get --no-install-recommends -y install \
tini \
curl \ curl \
cpio \ cpio \
tini \
wget \ wget \
fdisk \ fdisk \
unzip \ unzip \
@@ -57,11 +57,14 @@ ARG BUILD_ARG=0
ARG VERSION_ARG="0.0" ARG VERSION_ARG="0.0"
ENV VERSION=$VERSION_ARG ENV VERSION=$VERSION_ARG
LABEL org.opencontainers.image.licenses="MIT"
LABEL org.opencontainers.image.title="Virtual DSM"
LABEL org.opencontainers.image.created=${DATE_ARG} LABEL org.opencontainers.image.created=${DATE_ARG}
LABEL org.opencontainers.image.revision=${BUILD_ARG} LABEL org.opencontainers.image.revision=${BUILD_ARG}
LABEL org.opencontainers.image.version=${VERSION_ARG} LABEL org.opencontainers.image.version=${VERSION_ARG}
LABEL org.opencontainers.image.source=https://github.com/kroese/virtual-dsm/ LABEL org.opencontainers.image.source="https://github.com/kroese/virtual-dsm/"
LABEL org.opencontainers.image.url=https://hub.docker.com/r/kroese/virtual-dsm/ LABEL org.opencontainers.image.url="https://hub.docker.com/r/kroese/virtual-dsm/"
LABEL org.opencontainers.image.description="Virtual DSM in a docker container"
HEALTHCHECK --interval=60s --retries=2 CMD /run/check.sh HEALTHCHECK --interval=60s --retries=2 CMD /run/check.sh

View File

@@ -17,7 +17,7 @@ Virtual DSM in a docker container.
- Multi-platform - Multi-platform
- KVM acceleration - KVM acceleration
- GPU passthrough - GPU passthrough
- Graceful shutdown - Graceful shutdowns
- Upgrades supported - Upgrades supported
## Usage ## Usage
@@ -27,22 +27,22 @@ Via `docker-compose.yml`
```yaml ```yaml
version: "3" version: "3"
services: services:
dsm: dsm:
container_name: dsm container_name: dsm
image: kroese/virtual-dsm:latest image: kroese/virtual-dsm:latest
environment: environment:
DISK_SIZE: "16G" DISK_SIZE: "16G"
devices: devices:
- /dev/kvm - /dev/kvm
- /dev/vhost-net - /dev/vhost-net
cap_add: cap_add:
- NET_ADMIN - NET_ADMIN
ports: ports:
- 5000:5000 - 5000:5000
volumes: volumes:
- /opt/dsm:/storage - /opt/dsm:/storage
restart: on-failure restart: on-failure
stop_grace_period: 1m stop_grace_period: 1m
``` ```
Via `docker run` Via `docker run`
@@ -59,7 +59,7 @@ docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-ti
```yaml ```yaml
environment: environment:
DISK_SIZE: "256G" DISK_SIZE: "256G"
``` ```
This can also be used to resize the existing disk to a larger capacity without data loss. This can also be used to resize the existing disk to a larger capacity without data loss.
@@ -70,7 +70,7 @@ docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-ti
```yaml ```yaml
volumes: volumes:
- /home/user/data:/storage - /home/user/data:/storage
``` ```
Replace the example path `/home/user/data` with the desired storage folder. Replace the example path `/home/user/data` with the desired storage folder.
@@ -81,7 +81,7 @@ docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-ti
```yaml ```yaml
environment: environment:
ALLOCATE: "N" ALLOCATE: "N"
``` ```
Keep in mind that this will not affect any of your existing disks, it only applies to newly created disks. Keep in mind that this will not affect any of your existing disks, it only applies to newly created disks.
@@ -92,8 +92,8 @@ docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-ti
```yaml ```yaml
environment: environment:
CPU_CORES: "4" CPU_CORES: "4"
RAM_SIZE: "2048M" RAM_SIZE: "2048M"
``` ```
* ### How do I verify if my system supports KVM? * ### How do I verify if my system supports KVM?
@@ -127,16 +127,16 @@ docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-ti
```yaml ```yaml
services: services:
dsm: dsm:
container_name: dsm container_name: dsm
..<snip>.. ..<snip>..
networks: networks:
vdsm: vdsm:
ipv4_address: 192.168.0.100 ipv4_address: 192.168.0.100
networks: networks:
vdsm: vdsm:
external: true external: true
``` ```
An added benefit of this approach is that you won't have to perform any port mapping anymore since all ports will be exposed by default. An added benefit of this approach is that you won't have to perform any port mapping anymore since all ports will be exposed by default.
@@ -151,11 +151,11 @@ docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-ti
```yaml ```yaml
environment: environment:
DHCP: "Y" DHCP: "Y"
devices: devices:
- /dev/vhost-net - /dev/vhost-net
device_cgroup_rules: device_cgroup_rules:
- 'c *:* rwm' - 'c *:* rwm'
``` ```
Please note that even if you don't need DHCP, it's still recommended to enable this feature as it prevents NAT issues and increases performance by using a `macvtap` interface. Please note that even if you don't need DHCP, it's still recommended to enable this feature as it prevents NAT issues and increases performance by using a `macvtap` interface.
@@ -166,21 +166,23 @@ docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-ti
```yaml ```yaml
environment: environment:
URL: "https://global.synologydownload.com/download/DSM/release/7.0.1/42218/DSM_VirtualDSM_42218.pat" URL: "https://global.synologydownload.com/download/DSM/release/7.0.1/42218/DSM_VirtualDSM_42218.pat"
``` ```
With this method, you are able to switch between different versions while keeping your file data. With this method, you are able to switch between different versions while keeping your file data.
* ### How do I passthrough my GPU? * ### How do I passthrough my GPU?
To enable this feature, add the following lines to your compose file: To passthrough your GPU, add the following lines to your compose file:
```yaml ```yaml
environment: environment:
GPU: "Y" GPU: "Y"
devices: devices:
- /dev/dri - /dev/dri
``` ```
This can be used to enable facial recognition in Synology Photos for example.
* ### What are the differences compared to the standard DSM? * ### What are the differences compared to the standard DSM?

View File

@@ -136,13 +136,6 @@ if [[ SIZE -ne DATA_SIZE ]]; then
error "Virtual disk has the wrong size: ${SIZE}" && exit 89 error "Virtual disk has the wrong size: ${SIZE}" && exit 89
fi fi
AGENT="${STORAGE}/${BASE}.agent"
[ -f "$AGENT" ] && AGENT_VERSION=$(cat "${AGENT}") || AGENT_VERSION=1
if ((AGENT_VERSION < 5)); then
info "The installed VirtualDSM Agent v${AGENT_VERSION} is an outdated version, please upgrade it."
fi
DISK_OPTS="\ DISK_OPTS="\
-device virtio-scsi-pci,id=hw-synoboot,bus=pcie.0,addr=0xa \ -device virtio-scsi-pci,id=hw-synoboot,bus=pcie.0,addr=0xa \
-drive file=${BOOT},if=none,id=drive-synoboot,format=raw,cache=${DISK_CACHE},aio=${DISK_IO},discard=${DISK_DISCARD},detect-zeroes=on \ -drive file=${BOOT},if=none,id=drive-synoboot,format=raw,cache=${DISK_CACHE},aio=${DISK_IO},discard=${DISK_DISCARD},detect-zeroes=on \

View File

@@ -28,3 +28,15 @@ if ! apt-mark showinstall | grep -q "xserver-xorg-video-intel"; then
apt-get -qq --no-install-recommends -y install xserver-xorg-video-intel > /dev/null apt-get -qq --no-install-recommends -y install xserver-xorg-video-intel > /dev/null
fi fi
if ! apt-mark showinstall | grep -q "qemu-system-modules-opengl"; then
info "Installing OpenGL module..."
export DEBCONF_NOWARNINGS="yes"
export DEBIAN_FRONTEND="noninteractive"
apt-get -qq update
apt-get -qq --no-install-recommends -y install qemu-system-modules-opengl > /dev/null
fi

View File

@@ -242,9 +242,6 @@ mkdir -p "$LOC"
cp /agent/service.sh "$LOC/agent.sh" cp /agent/service.sh "$LOC/agent.sh"
chmod 755 "$LOC/agent.sh" chmod 755 "$LOC/agent.sh"
# Store agent version
echo "7" > "$STORAGE"/"$BASE".agent
info "Install: Installing system partition..." info "Install: Installing system partition..."
LABEL="1.44.1-42218" LABEL="1.44.1-42218"

View File

@@ -234,7 +234,11 @@ fi
if [[ "${DHCP}" == [Yy1]* ]]; then if [[ "${DHCP}" == [Yy1]* ]]; then
if [[ "$GATEWAY" == "172."* ]]; then if [[ "$GATEWAY" == "172."* ]]; then
error "You can only enable DHCP while the container is on a macvlan network!" && exit 86 if [[ "${DEBUG}" == [Yy1]* ]]; then
info "Warning: Are you sure the container is on a macvlan network?"
else
error "You can only enable DHCP while the container is on a macvlan network!" && exit 86
fi
fi fi
# Configuration for DHCP IP # Configuration for DHCP IP

View File

@@ -39,28 +39,14 @@ _graceful_shutdown() {
echo && error "Could not send shutdown command to the guest ($RESPONSE)" echo && error "Could not send shutdown command to the guest ($RESPONSE)"
# If we cannot shutdown the usual way, fallback to the NMI method # Send a NMI interrupt which will be detected by the agent script
if ! echo 'nmi' | nc -q 1 -w 1 localhost "${QEMU_MONPORT}" > /dev/null ; then
AGENT="${STORAGE}/${BASE}.agent"
[ -f "$AGENT" ] && AGENT_VERSION=$(cat "${AGENT}") || AGENT_VERSION=1
if ((AGENT_VERSION > 1)); then
# Send a NMI interrupt which will be detected by the kernel
if ! echo 'nmi' | nc -q 1 -w 1 localhost "${QEMU_MONPORT}" > /dev/null ; then
AGENT_VERSION=0
fi
fi
if ((AGENT_VERSION < 2)); then
echo && info "Please update the VirtualDSM Agent to allow for gracefull shutdowns..."
kill -15 "$(cat "${_QEMU_PID}")" kill -15 "$(cat "${_QEMU_PID}")"
pkill -f qemu-system-x86_64 || true pkill -f qemu-system-x86_64 || true
fi fi
fi fi
while [ "$(cat ${_QEMU_SHUTDOWN_COUNTER})" -lt "${QEMU_POWERDOWN_TIMEOUT}" ]; do while [ "$(cat ${_QEMU_SHUTDOWN_COUNTER})" -lt "${QEMU_POWERDOWN_TIMEOUT}" ]; do
@@ -72,7 +58,8 @@ _graceful_shutdown() {
if echo 'info version'| nc -q 1 -w 1 localhost "${QEMU_MONPORT}" >/dev/null 2>&1 ; then if echo 'info version'| nc -q 1 -w 1 localhost "${QEMU_MONPORT}" >/dev/null 2>&1 ; then
sleep 1 sleep 1
#info "Shutting down, waiting... ($(cat ${_QEMU_SHUTDOWN_COUNTER})/${QEMU_POWERDOWN_TIMEOUT})" CNT="$(cat ${_QEMU_SHUTDOWN_COUNTER})/${QEMU_POWERDOWN_TIMEOUT}"
[[ "${DEBUG}" == [Yy1]* ]] && info "Shutting down, waiting... (${CNT})"
fi fi