Compare commits

...

46 Commits
v4.03 ... v4.12

Author SHA1 Message Date
Kroese
0ce14f6c2d fix: Disable pidwait
fix: Disable pidwait
2023-07-18 20:17:19 +02:00
Kroese
272e491281 fix: Disable pidwait 2023-07-18 20:16:47 +02:00
Kroese
0518e1100b Add ARGUMENTS variable
Add ARGUMENTS variable
2023-07-18 19:47:56 +02:00
Kroese
8aa797b557 feat: Add ARGUMENTS variable 2023-07-18 19:44:09 +02:00
Kroese
4356e5ebf9 Fix for issue https://github.com/kroese/virtual-dsm/issues/292
Fix for issue https://github.com/kroese/virtual-dsm/issues/292
2023-07-18 19:37:12 +02:00
Kroese
502c068d30 fix: Fix for issue https://github.com/kroese/virtual-dsm/issues/292 2023-07-18 19:35:56 +02:00
Kroese
d5e3ed8907 fix: Fix for issue https://github.com/kroese/virtual-dsm/issues/292 2023-07-18 19:34:49 +02:00
Kroese
f0e5a61e73 Delete network on shutdown
Delete network on shutdown
2023-07-04 18:56:18 +02:00
Kroese
b07577b60d style: Remove spaces 2023-07-04 18:46:16 +02:00
Kroese
4571fe9c4f feat: Close network on shutdown 2023-07-04 18:36:38 +02:00
Kroese
9f6fbc3f7c fix: Use pidwait only on recent kernels 2023-07-04 18:22:50 +02:00
Kroese
bbc033f032 feat: Close network on shutdown 2023-07-04 18:21:37 +02:00
Kroese
160e5a07be feat: Close network on shutdown 2023-07-04 18:20:03 +02:00
Kroese
0cca2a7079 fix: Wait for address 2023-07-04 12:52:49 +02:00
Kroese
64257d1a6f Fix issue #281 and #283
Fix issue #281 and #283
2023-07-03 12:02:33 +02:00
Kroese
d6dde093b2 docs: Resize info 2023-07-03 11:59:40 +02:00
Kroese
d1957f5eb7 fix: Fix issue #281 2023-07-03 11:38:11 +02:00
Kroese
f3f9a9f480 fix: Fix issue #281 2023-07-03 11:26:10 +02:00
Kroese
15d67203c9 fix: Fix issue #283 2023-07-03 11:11:47 +02:00
Kroese
c33c63114e Merge pull request #278 from lauwie007/master
Update to DSM 7.2 build 64570-1
2023-06-20 21:40:44 +02:00
lauwie007
80169e6b50 Update to DSM 7.2 build 64570-1
New dsm release (previous version returned  an error for me)
2023-06-20 21:36:08 +02:00
Kroese
61f733fe66 Line breaks
Line breaks
2023-06-09 09:58:31 +02:00
Kroese
03da1f38f4 fix: Line breaks 2023-06-09 09:57:55 +02:00
Kroese
8543ea5dad Update to DSM 7.2 build 64570
Update to DSM 7.2 build 64570
2023-06-09 09:48:21 +02:00
Kroese
36ebb950eb Update to DSM 7.2 build 64570 2023-06-09 09:47:44 +02:00
Kroese
76ad3ff502 Add host MAC address
Add host MAC address
2023-05-29 14:03:07 +02:00
Kroese
4673feb282 feat: Add host MAC address 2023-05-29 13:53:02 +02:00
Kroese
df6436bf6a Use dots as seperator
Use dots as seperator
2023-05-29 05:03:56 +02:00
Kroese
d904ebfc85 fix: Use dots as seperator 2023-05-29 04:54:21 +02:00
Kroese
b78342328f Add host model environment variable
Add host model environment variable
2023-05-29 02:57:42 +02:00
Kroese
36c89f0556 feat: Add host model 2023-05-29 02:56:47 +02:00
Kroese
1c62acd1a1 Add host MAC address as environment variable
Add host MAC address as environment variable
2023-05-29 02:22:55 +02:00
Kroese
0795fd1277 feat: Add host MAC address 2023-05-29 02:18:33 +02:00
Kroese
c509ef5ac4 feat: Add host MAC address 2023-05-29 02:10:10 +02:00
Kroese
46be2d583d fix: Decrease delay 2023-05-27 13:26:39 +02:00
Kroese
3441350087 fix: Don't redirect stdout 2023-05-27 07:13:43 +02:00
Kroese
d132b6afa9 Add device cgroup rules
Add device cgroup rules
2023-05-25 23:21:07 +02:00
Kroese
8d0efe7379 feat: Add device cgroup rules 2023-05-25 23:17:10 +02:00
Kroese
2ad9dcc24c Readme
Readme
2023-05-25 23:12:53 +02:00
Kroese
24ab417e9e docs: DHCP mode 2023-05-25 23:10:15 +02:00
Kroese
bc9d3ffc9b docs: DHCP mode 2023-05-25 23:08:20 +02:00
Kroese
4904109b9e Readme
Readme
2023-05-25 22:14:48 +02:00
Kroese
436eca45cc docs: DSM version 2023-05-25 22:09:21 +02:00
Kroese
daa91af2d5 docs: cgroup wildcard 2023-05-25 22:05:33 +02:00
Kroese
3416507ec5 Display QEMU version
Display QEMU version
2023-05-25 20:42:48 +02:00
Kroese
e9a5b50893 feat: Display QEMU version 2023-05-25 20:41:30 +02:00
9 changed files with 80 additions and 24 deletions

View File

@@ -124,7 +124,7 @@ else
fi
delay=5000
delay=500
elapsed=$((($(date +%s%N) - ts)/1000000))
if [[ delay -gt elapsed ]]; then
@@ -143,9 +143,11 @@ else
MSG="http://${IP}:5000"
fi
echo ""
info "--------------------------------------------------------"
info " You can now login to DSM at ${MSG}"
info "--------------------------------------------------------"
echo ""
# Wait for NMI interrupt as a shutdown signal

View File

@@ -10,6 +10,8 @@ services:
devices:
- /dev/kvm
- /dev/vhost-net
device_cgroup_rules:
- 'c *:* rwm'
cap_add:
- NET_ADMIN
ports:

View File

@@ -60,6 +60,8 @@ docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-ti
environment:
DISK_SIZE: "256G"
```
This can also be used to resize the existing disk to a larger capacity without data loss.
* ### How do I change the location of the virtual disk?
@@ -152,10 +154,10 @@ docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-ti
devices:
- /dev/vhost-net
device_cgroup_rules:
- 'c 511:* rwm'
- 'c *:* rwm'
```
Please note that the exact `cgroup` rule number may vary depending on your system, but the log output will indicate the correct number in the event of an error.
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.
* ### How do I install a specific version of vDSM?
@@ -163,7 +165,7 @@ docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-ti
```yaml
environment:
URL: "https://global.synologydownload.com/download/DSM/release/7.1.1/42962-1/DSM_VirtualDSM_42962.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.

View File

@@ -39,13 +39,15 @@ if [ -f "${DATA}" ]; then
if [[ "${ALLOCATE}" == [Nn]* ]]; then
# Resize file by changing its length
truncate -s "${DATA_SIZE}" "${DATA}";
if ! truncate -s "${DATA_SIZE}" "${DATA}"; then
error "Could not resize the file for the virtual disk." && exit 85
fi
else
REQ=$((DATA_SIZE-OLD_SIZE))
# Check free diskspace
# Check free diskspace
SPACE=$(df --output=avail -B 1 "${STORAGE}" | tail -n 1)
if (( REQ > SPACE )); then
@@ -55,7 +57,9 @@ if [ -f "${DATA}" ]; then
# Resize file by allocating more space
if ! fallocate -l "${DATA_SIZE}" "${DATA}"; then
error "Could not allocate a file for the virtual disk." && exit 85
if ! truncate -s "${DATA_SIZE}" "${DATA}"; then
error "Could not resize the file for the virtual disk." && exit 85
fi
fi
if [[ "${ALLOCATE}" == [Zz]* ]]; then
@@ -84,7 +88,10 @@ if [ ! -f "${DATA}" ]; then
if [[ "${ALLOCATE}" == [Nn]* ]]; then
# Create an empty file
truncate -s "${DATA_SIZE}" "${DATA}"
if ! truncate -s "${DATA_SIZE}" "${DATA}"; then
rm -f "${DATA}"
error "Could not create a file for the virtual disk." && exit 87
fi
else
@@ -98,8 +105,10 @@ if [ ! -f "${DATA}" ]; then
# Create an empty file
if ! fallocate -l "${DATA_SIZE}" "${DATA}"; then
rm -f "${DATA}"
error "Could not allocate a file for the virtual disk." && exit 87
if ! truncate -s "${DATA_SIZE}" "${DATA}"; then
rm -f "${DATA}"
error "Could not create a file for the virtual disk." && exit 87
fi
fi
if [[ "${ALLOCATE}" == [Zz]* ]]; then

View File

@@ -10,7 +10,7 @@ DL="https://global.synologydownload.com/download/DSM"
if [ -z "$URL" ]; then
if [ "$ARCH" == "amd64" ]; then
URL="$DL/release/7.2/64561/DSM_VirtualDSM_64561.pat"
URL="$DL/release/7.2/64570-1/DSM_VirtualDSM_64570.pat"
else
URL="$DL/release/7.0.1/42218/DSM_VirtualDSM_42218.pat"
fi
@@ -179,7 +179,9 @@ SPACE=$(df --output=avail -B 1 "$TMP" | tail -n 1)
(( SYSTEM_SIZE > SPACE )) && error "Not enough free space to create a 4 GB system disk." && exit 87
if ! fallocate -l "${SYSTEM_SIZE}" "${SYSTEM}"; then
rm -f "${SYSTEM}" && error "Could not allocate a file for the system disk." && exit 88
if ! truncate -s "${SYSTEM_SIZE}" "${SYSTEM}"; then
rm -f "${SYSTEM}" && error "Could not allocate a file for the system disk." && exit 88
fi
fi
if [[ "${ALLOCATE}" == [Zz]* ]]; then

View File

@@ -31,7 +31,10 @@ configureDHCP() {
error "and that the NET_ADMIN capability has been added to the container config: --cap-add NET_ADMIN" && exit 16
fi
ip link set "${VM_NET_TAP}" up
while ! ip link set "${VM_NET_TAP}" up; do
info "Waiting for address to become available..."
sleep 2
done
TAP_NR=$(</sys/class/net/"${VM_NET_TAP}"/ifindex)
TAP_PATH="/dev/tap${TAP_NR}"
@@ -127,11 +130,20 @@ configureNAT () {
fi
ip address add ${VM_NET_IP%.*}.1/24 broadcast ${VM_NET_IP%.*}.255 dev dockerbridge
ip link set dockerbridge up
while ! ip link set dockerbridge up; do
info "Waiting for address to become available..."
sleep 2
done
# QEMU Works with taps, set tap to the bridge created
ip tuntap add dev "${VM_NET_TAP}" mode tap
ip link set "${VM_NET_TAP}" up promisc on
while ! ip link set "${VM_NET_TAP}" up promisc on; do
info "Waiting for tap to become available..."
sleep 2
done
ip link set dev "${VM_NET_TAP}" master dockerbridge
# Add internet connection to the VM
@@ -165,6 +177,24 @@ configureNAT () {
return 0
}
closeNetwork () {
if [[ "${DHCP}" == [Yy1]* ]]; then
ip link set "${VM_NET_TAP}" down || true
ip link delete "${VM_NET_TAP}" || true
else
ip link set "${VM_NET_TAP}" down promisc off || true
ip link delete "${VM_NET_TAP}" || true
ip link set dockerbridge down || true
ip link delete dockerbridge || true
fi
}
# ######################################
# Configure Network
# ######################################

View File

@@ -81,6 +81,8 @@ _graceful_shutdown() {
echo && echo " Quitting..."
echo 'quit' | nc -q 1 -w 1 localhost "${QEMU_MONPORT}" >/dev/null 2>&1 || true
closeNetwork
return
}

View File

@@ -6,6 +6,7 @@ set -Eeuo pipefail
: ${URL:=''} # URL of the PAT file
: ${DEBUG:='N'} # Enable debug mode
: ${ALLOCATE:='Y'} # Preallocate diskspace
: ${ARGUMENTS:=''} # Extra QEMU parameters
: ${CPU_CORES:='1'} # Amount of CPU cores
: ${DISK_SIZE:='16G'} # Initial data disk size
: ${RAM_SIZE:='512M'} # Maximum RAM amount
@@ -21,7 +22,9 @@ trap 'error "Status $? while: ${BASH_COMMAND} (line $LINENO/$BASH_LINENO)"' ERR
STORAGE="/storage"
KERNEL=$(uname -r | cut -b 1)
MINOR=$(uname -r | cut -d '.' -f2)
ARCH=$(dpkg --print-architecture)
VERS=$(qemu-system-x86_64 --version | head -n 1 | cut -d '(' -f 1)
[ ! -d "$STORAGE" ] && error "Storage folder (${STORAGE}) not found!" && exit 13
@@ -78,21 +81,21 @@ 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"
ARGS="${DEF_OPTS} ${CPU_OPTS} ${RAM_OPTS} ${MAC_OPTS} ${MON_OPTS} ${SERIAL_OPTS} ${NET_OPTS} ${DISK_OPTS} ${EXTRA_OPTS}"
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 ' ')
trap - ERR
set -m
(
[[ "${DEBUG}" == [Yy1]* ]] && set -x
[[ "${DEBUG}" == [Yy1]* ]] && info "$VERS" && set -x
qemu-system-x86_64 ${ARGS:+ $ARGS} & echo $! > "${_QEMU_PID}"
{ set +x; } 2>/dev/null
)
set +m
if (( KERNEL > 4 )); then
pidwait -F "${_QEMU_PID}" & wait $!
else
tail --pid "$(cat "${_QEMU_PID}")" --follow /dev/null & wait $!
fi
#if (( KERNEL > 5 )) || ( (( KERNEL == 5 )) && (( MINOR > 2 )) ); then
# pidwait -F "${_QEMU_PID}" & wait $!
#else
tail --pid "$(cat "${_QEMU_PID}")" --follow /dev/null & wait $!

View File

@@ -4,10 +4,12 @@ set -Eeuo pipefail
# Docker environment variables
: ${HOST_CPU:=''}
: ${HOST_MAC:=''}
: ${HOST_BUILD:=''}
: ${HOST_DEBUG:=''}
: ${HOST_SERIAL:=''}
: ${GUEST_SERIAL:=''}
: ${HOST_MODEL:=''}
: ${HOST_VERSION:=''}
: ${HOST_TIMESTAMP:=''}
@@ -26,10 +28,12 @@ else
fi
HOST_ARGS=()
HOST_ARGS+=("-cpu=${CPU_CORES}")
HOST_ARGS+=("-cpu_arch=${HOST_CPU}")
[ -n "$CPU_CORES" ] && HOST_ARGS+=("-cpu=${CPU_CORES}")
[ -n "$HOST_MAC" ] && HOST_ARGS+=("-mac=${HOST_MAC}")
[ -n "$HOST_BUILD" ] && HOST_ARGS+=("-build=${HOST_BUILD}")
[ -n "$HOST_MODEL" ] && HOST_ARGS+=("-model=${HOST_MODEL}")
[ -n "$HOST_SERIAL" ] && HOST_ARGS+=("-hostsn=${HOST_SERIAL}")
[ -n "$GUEST_SERIAL" ] && HOST_ARGS+=("-guestsn=${GUEST_SERIAL}")
[ -n "$HOST_VERSION" ] && HOST_ARGS+=("-version=${HOST_VERSION}")
@@ -41,7 +45,7 @@ if [[ "${HOST_DEBUG}" == [Yy1]* ]]; then
{ set +x; } 2>/dev/null
echo
else
./run/host.bin "${HOST_ARGS[@]}" > /dev/null 2>&1 &
./run/host.bin "${HOST_ARGS[@]}" 2> /dev/null &
fi
# Configure serial ports