Compare commits

...

22 Commits
v4.17 ... v4.19

Author SHA1 Message Date
Kroese
0c1c422758 feat: Mount block device
feat: Mount block device
2023-10-10 06:42:36 +02:00
Kroese
f56c523627 feat: Mount block device 2023-10-10 06:39:59 +02:00
Kroese
66879b5a6a feat: Mount block device 2023-10-10 06:29:03 +02:00
Kroese
b4eef6161b feat: Disk passthrough
feat: Disk passthrough
2023-10-10 05:32:22 +02:00
Kroese
cf38b1f237 fix: Intel GPU drivers 2023-10-10 05:29:50 +02:00
Kroese
2c09811365 feat: Disk passthrough 2023-10-10 05:26:37 +02:00
Kroese
761f5babfc docs: GPU passthrough
docs: GPU passthrough
2023-10-10 05:01:12 +02:00
Kroese
26be942a74 docs: GPU passthrough 2023-10-10 05:00:54 +02:00
Kroese
9c6aeca709 feat: Multiple disk support
feat: Multiple disk support
2023-10-09 19:47:05 +02:00
Kroese
81b0bba667 Shellcheck SC2153 2023-10-09 19:46:26 +02:00
Kroese
e2c00a2e44 docs: GPU passthrough support 2023-10-09 19:41:07 +02:00
Kroese
7bb33f26cd feat: GPU passthrough support 2023-10-09 19:34:49 +02:00
Kroese
63b2d703a4 build: Debian Bookworm 2023-10-09 19:30:57 +02:00
Kroese
a97dfbfdf2 feat: GPU passthrough support 2023-10-09 18:48:47 +02:00
Kroese
b255cb03e8 feat: GPU passthrough support 2023-10-09 18:45:39 +02:00
Kroese
7a79ff1d2d style: Indentations 2023-10-09 18:35:04 +02:00
Kroese
06fda133ed fix: Remove GPU drivers 2023-10-09 18:32:52 +02:00
Kroese
acedd1cdcf feat: Multiple disk support 2023-10-09 18:30:13 +02:00
Kroese
96083fddb3 build: Update to QEMU v8.1.1 (Debian 13) 2023-10-09 18:28:56 +02:00
Kroese
5d7604a205 feat: Multiple disk support 2023-10-09 14:10:31 +02:00
Kroese
24d44924fe docs: GPU support
docs: GPU support
2023-10-09 11:20:32 +02:00
Kroese
db840db76f docs: GPU support 2023-10-09 11:19:57 +02:00
8 changed files with 103 additions and 47 deletions

View File

@@ -11,4 +11,4 @@ jobs:
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
env:
SHELLCHECK_OPTS: -x -e SC2001 -e SC2002 -e SC2223 -e SC2034 -e SC2064 -e SC2317 -e SC2028
SHELLCHECK_OPTS: -x -e SC2001 -e SC2002 -e SC2223 -e SC2034 -e SC2064 -e SC2317 -e SC2028 -e SC2153

View File

@@ -16,6 +16,7 @@ RUN apt-get update && apt-get -y upgrade && \
apt-get --no-install-recommends -y install \
curl \
cpio \
tini \
wget \
fdisk \
unzip \
@@ -64,4 +65,4 @@ LABEL org.opencontainers.image.url=https://hub.docker.com/r/kroese/virtual-dsm/
HEALTHCHECK --interval=60s --retries=2 CMD /run/check.sh
ENTRYPOINT ["/run/run.sh"]
ENTRYPOINT ["/usr/bin/tini", "-s", "/run/run.sh"]

View File

@@ -16,9 +16,10 @@ Virtual DSM in a docker container.
- Multi-platform
- KVM acceleration
- GPU passthrough
- Graceful shutdown
- Upgrades supported
## Usage
Via `docker-compose.yml`
@@ -180,7 +181,7 @@ docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-ti
devices:
- /dev/dri
```
* ### What are the differences compared to the standard DSM?
There are only two minor differences: the Virtual Machine Manager package is not provided, and Surveillance Station doesn't include any free licenses.

View File

@@ -153,3 +153,46 @@ DISK_OPTS="\
-device virtio-scsi-pci,id=hw-userdata,bus=pcie.0,addr=0xc \
-drive file=${DATA},if=none,id=drive-userdata,format=raw,cache=${DISK_CACHE},aio=${DISK_IO},discard=${DISK_DISCARD},detect-zeroes=on \
-device scsi-hd,bus=hw-userdata.0,channel=0,scsi-id=0,lun=0,drive=drive-userdata,id=userdata0,rotation_rate=${DISK_ROTATION},bootindex=3"
EXTRA_DISK="/storage2/data.img"
if [ -f "${EXTRA_DISK}" ]; then
DISK_OPTS="${DISK_OPTS} \
-device virtio-scsi-pci,id=hw-userdata2,bus=pcie.0,addr=0xd \
-drive file=${EXTRA_DISK},if=none,id=drive-userdata2,format=raw,cache=${DISK_CACHE},aio=${DISK_IO},discard=${DISK_DISCARD},detect-zeroes=on \
-device scsi-hd,bus=hw-userdata2.0,channel=0,scsi-id=0,lun=0,drive=drive-userdata2,id=userdata2,rotation_rate=${DISK_ROTATION},bootindex=4"
else
[ -d "$(dirname "${EXTRA_DISK}")" ] && error "Disk image ${EXTRA_DISK} does not exist! Please supply an empty file of at least 6 GB." && exit 53
fi
EXTRA_DISK="/storage3/data.img"
if [ -f "${EXTRA_DISK}" ]; then
DISK_OPTS="${DISK_OPTS} \
-device virtio-scsi-pci,id=hw-userdata3,bus=pcie.0,addr=0xe \
-drive file=${EXTRA_DISK},if=none,id=drive-userdata3,format=raw,cache=${DISK_CACHE},aio=${DISK_IO},discard=${DISK_DISCARD},detect-zeroes=on \
-device scsi-hd,bus=hw-userdata3.0,channel=0,scsi-id=0,lun=0,drive=drive-userdata3,id=userdata3,rotation_rate=${DISK_ROTATION},bootindex=5"
else
[ -d "$(dirname "${EXTRA_DISK}")" ] && error "Disk image ${EXTRA_DISK} does not exist! Please supply an empty file of at least 6 GB." && exit 54
fi
: ${DEVICE:=''} # Docker variable to passthrough a block device, like /dev/vdc1.
if [ -n "${DEVICE}" ]; then
[ ! -b "${DEVICE}" ] && error "Device ${DEVICE} cannot be found! Please add it to the 'devices' section of your compose file." && exit 55
DISK_OPTS="${DISK_OPTS} \
-device virtio-scsi-pci,id=hw-userdata4,bus=pcie.0,addr=0xf \
-drive file=${DEVICE},if=none,id=drive-userdata4,format=raw,cache=${DISK_CACHE},aio=${DISK_IO},discard=${DISK_DISCARD},detect-zeroes=on \
-device scsi-hd,bus=hw-userdata4.0,channel=0,scsi-id=0,lun=0,drive=drive-userdata4,id=userdata4,rotation_rate=${DISK_ROTATION},bootindex=6"
fi

30
run/gpu.sh Normal file
View File

@@ -0,0 +1,30 @@
#!/bin/bash
set -Eeuo pipefail
[ ! -d /dev/dri ] && mkdir -m 755 /dev/dri
if [ ! -c /dev/dri/card0 ]; then
mknod /dev/dri/card0 c 226 0
fi
if [ ! -c /dev/dri/renderD128 ]; then
mknod /dev/dri/renderD128 c 226 128
fi
chmod 666 /dev/dri/card0
chmod 666 /dev/dri/renderD128
DEF_OPTS="-nodefaults -boot strict=on -display egl-headless,rendernode=/dev/dri/renderD128"
DEF_OPTS="${DEF_OPTS} -device virtio-vga,id=video0,max_outputs=1,bus=pcie.0,addr=0x1"
if ! apt-mark showinstall | grep -q "xserver-xorg-video-intel"; then
info "Installing Intel GPU drivers..."
export DEBCONF_NOWARNINGS="yes"
export DEBIAN_FRONTEND="noninteractive"
apt-get -qq update
apt-get -qq --no-install-recommends -y install xserver-xorg-video-intel > /dev/null
fi

View File

@@ -134,27 +134,18 @@ if { tar tf "$PAT"; } >/dev/null 2>&1; then
else
export DEBCONF_NOWARNINGS="yes"
export DEBIAN_FRONTEND="noninteractive"
if [ "$ARCH" != "amd64" ]; then
info "Install: Installing QEMU..."
apt-get -qq update && apt-get -qq -y upgrade
export DEBCONF_NOWARNINGS="yes"
export DEBIAN_FRONTEND="noninteractive"
apt-get -qq update
apt-get -qq --no-install-recommends -y install qemu-user > /dev/null
fi
if [[ "${GPU}" == [Yy1]* ]] && [[ "$ARCH" == "amd64" ]]; then
info "Install: Installing GPU drivers..."
apt-get -qq update && apt-get -qq -y upgrade
apt-get -qq --no-install-recommends -y install xserver-xorg-video-intel > /dev/null
fi
info "Install: Extracting downloaded image..."
export LD_LIBRARY_PATH="/run/extract"
@@ -213,14 +204,14 @@ SIZE=$(stat -c%s "${SYSTEM}")
PART="$TMP/partition.fdisk"
{ echo "label: dos"
echo "label-id: 0x6f9ee2e9"
echo "device: ${SYSTEM}"
echo "unit: sectors"
echo "sector-size: 512"
echo ""
echo "${SYSTEM}1 : start= 2048, size= 4980480, type=83"
echo "${SYSTEM}2 : start= 4982528, size= 4194304, type=82"
{ echo "label: dos"
echo "label-id: 0x6f9ee2e9"
echo "device: ${SYSTEM}"
echo "unit: sectors"
echo "sector-size: 512"
echo ""
echo "${SYSTEM}1 : start= 2048, size= 4980480, type=83"
echo "${SYSTEM}2 : start= 4982528, size= 4194304, type=82"
} > "$PART"
sfdisk -q "$SYSTEM" < "$PART"

View File

@@ -4,8 +4,8 @@ set -Eeuo pipefail
# Docker environment variables
: ${URL:=''} # URL of the PAT file
: ${GPU:='N'} # Enable GPU passthrough
: ${DEBUG:='N'} # Enable debug mode
: ${GPU:='N'} # Enable GPU passthrough
: ${DEBUG:='N'} # Enable debugging mode
: ${ALLOCATE:='Y'} # Preallocate diskspace
: ${ARGUMENTS:=''} # Extra QEMU parameters
: ${CPU_CORES:='1'} # Amount of CPU cores
@@ -42,17 +42,10 @@ if [[ ! -f "$STORAGE/$BASE.boot.img" ]] || [[ ! -f "$STORAGE/$BASE.system.img" ]
. /run/install.sh
fi
# Initialize disks
. /run/disk.sh
# Initialize network
. /run/network.sh
# Initialize serialport
. /run/serial.sh
# Configure shutdown
. /run/power.sh
. /run/disk.sh # Initialize disks
. /run/network.sh # Initialize network
. /run/serial.sh # Initialize serialport
. /run/power.sh # Configure shutdown
KVM_ERR=""
KVM_OPTS=""
@@ -82,10 +75,7 @@ EXTRA_OPTS="-device virtio-balloon-pci,id=balloon0,bus=pcie.0,addr=0x4"
EXTRA_OPTS="$EXTRA_OPTS -object rng-random,id=objrng0,filename=/dev/urandom"
EXTRA_OPTS="$EXTRA_OPTS -device virtio-rng-pci,rng=objrng0,id=rng0,bus=pcie.0,addr=0x1c"
if [[ "${GPU}" == [Yy1]* ]]; then
DEF_OPTS="-nodefaults -boot strict=on -display egl-headless,rendernode=/dev/dri/renderD128"
DEF_OPTS="${DEF_OPTS} -device virtio-vga,id=video0,max_outputs=1,bus=pcie.0,addr=0x1"
fi
[[ "${GPU}" == [Yy1]* ]] && [[ "$ARCH" == "amd64" ]] && . /run/gpu.sh
ARGS="${DEF_OPTS} ${CPU_OPTS} ${RAM_OPTS} ${MAC_OPTS} ${MON_OPTS} ${SERIAL_OPTS} ${NET_OPTS} ${DISK_OPTS} ${EXTRA_OPTS} ${ARGUMENTS}"
ARGS=$(echo "$ARGS" | sed 's/\t/ /g' | tr -s ' ')

View File

@@ -52,8 +52,8 @@ fi
SERIAL_OPTS="\
-serial mon:stdio \
-device virtio-serial-pci,id=virtio-serial0,bus=pcie.0,addr=0x3 \
-chardev pty,id=charserial0 \
-device isa-serial,chardev=charserial0,id=serial0 \
-chardev socket,id=charchannel0,host=127.0.0.1,port=12345,reconnect=10 \
-device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=vchannel"
-device virtio-serial-pci,id=virtio-serial0,bus=pcie.0,addr=0x3 \
-chardev pty,id=charserial0 \
-device isa-serial,chardev=charserial0,id=serial0 \
-chardev socket,id=charchannel0,host=127.0.0.1,port=12345,reconnect=10 \
-device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=vchannel"