Compare commits

..
9 Commits
9 changed files with 66 additions and 33 deletions
+7
View File
@@ -1,4 +1,5 @@
version: 2 version: 2
updates: updates:
- package-ecosystem: docker - package-ecosystem: docker
directory: / directory: /
@@ -6,9 +7,15 @@ updates:
interval: weekly interval: weekly
cooldown: cooldown:
default-days: 7 default-days: 7
- package-ecosystem: github-actions - package-ecosystem: github-actions
directory: / directory: /
schedule: schedule:
interval: weekly interval: weekly
cooldown: cooldown:
default-days: 7 default-days: 7
ignore:
- dependency-name: "*"
update-types:
- version-update:semver-minor
- version-update:semver-patch
+1
View File
@@ -39,6 +39,7 @@ An empty default means the variable is unset and its value is determined automat
| `DISK_DISCARD` | `unmap` | Discard/TRIM mode for the primary disk. | | `DISK_DISCARD` | `unmap` | Discard/TRIM mode for the primary disk. |
| `DISK_ROTATION` | `1` | Rotation rate reported to the guest. Use `1` to identify the disk as an SSD. | | `DISK_ROTATION` | `1` | Rotation rate reported to the guest. Use `1` to identify the disk as an SSD. |
| `DISK_FLAGS` | | Additional options used when creating `qcow2` disks. | | `DISK_FLAGS` | | Additional options used when creating `qcow2` disks. |
| `DISK_OPTIONS` | | Additional options appended to QEMU disk devices. |
| `ALLOCATE` | `N` | Preallocates space for the data disks. | | `ALLOCATE` | `N` | Preallocates space for the data disks. |
| `STORAGE` | `/storage` | Storage directory used for disks, settings, and downloads. | | `STORAGE` | `/storage` | Storage directory used for disks, settings, and downloads. |
+15 -5
View File
@@ -7,6 +7,7 @@ set -Eeuo pipefail
: "${DISK_FMT:="raw"}" # Disk file format, 'raw' by default for best performance : "${DISK_FMT:="raw"}" # Disk file format, 'raw' by default for best performance
: "${DISK_TYPE:=""}" # Device type to be used, "sata", "nvme", "blk" or "scsi" : "${DISK_TYPE:=""}" # Device type to be used, "sata", "nvme", "blk" or "scsi"
: "${DISK_FLAGS:=""}" # Specifies the options for use with the qcow2 disk format : "${DISK_FLAGS:=""}" # Specifies the options for use with the qcow2 disk format
: "${DISK_OPTIONS:=""}" # Specifies additional options for the QEMU disk device
: "${DISK_CACHE:="none"}" # Caching mode, can be set to 'writeback' for better performance : "${DISK_CACHE:="none"}" # Caching mode, can be set to 'writeback' for better performance
: "${DISK_DISCARD:="unmap"}" # Controls whether unmap (TRIM) commands are passed to the host. : "${DISK_DISCARD:="unmap"}" # Controls whether unmap (TRIM) commands are passed to the host.
: "${DISK_ROTATION:="1"}" # Rotation rate, set to 1 for SSD storage and increase for HDD : "${DISK_ROTATION:="1"}" # Rotation rate, set to 1 for SSD storage and increase for HDD
@@ -16,6 +17,7 @@ DISK_IO=$(strip "$DISK_IO")
DISK_FMT=$(strip "$DISK_FMT") DISK_FMT=$(strip "$DISK_FMT")
DISK_TYPE=$(strip "$DISK_TYPE") DISK_TYPE=$(strip "$DISK_TYPE")
DISK_FLAGS=$(strip "$DISK_FLAGS") DISK_FLAGS=$(strip "$DISK_FLAGS")
DISK_OPTIONS=$(strip "$DISK_OPTIONS")
DISK_CACHE=$(strip "$DISK_CACHE") DISK_CACHE=$(strip "$DISK_CACHE")
DISK_DISCARD=$(strip "$DISK_DISCARD") DISK_DISCARD=$(strip "$DISK_DISCARD")
DISK_ROTATION=$(strip "$DISK_ROTATION") DISK_ROTATION=$(strip "$DISK_ROTATION")
@@ -508,6 +510,9 @@ createDevice () {
[[ -z "${PCI_BUS:-}" && ( "${MACHINE,,}" == pc || "${MACHINE,,}" == pc-i440fx* ) ]] && bus="pci.0" [[ -z "${PCI_BUS:-}" && ( "${MACHINE,,}" == pc || "${MACHINE,,}" == pc-i440fx* ) ]] && bus="pci.0"
local options=""
[ -n "$DISK_OPTIONS" ] && options=",${DISK_OPTIONS#,}"
local bootIndex="" local bootIndex=""
local diskId="data$diskIndex" local diskId="data$diskIndex"
[ -n "$diskIndex" ] && bootIndex=",bootindex=$diskIndex" [ -n "$diskIndex" ] && bootIndex=",bootindex=$diskIndex"
@@ -520,29 +525,29 @@ createDevice () {
;; ;;
"usb" ) "usb" )
result+=",if=none \ result+=",if=none \
-device usb-storage,drive=${diskId}${bootIndex}${diskSerial}${diskSectors}" -device usb-storage,drive=${diskId}${bootIndex}${diskSerial}${diskSectors}${options}"
echo "$result" echo "$result"
;; ;;
"nvme" ) "nvme" )
result+=",if=none \ result+=",if=none \
-device nvme,drive=${diskId}${bootIndex},serial=deadbeaf${diskIndex}${diskSerial}${diskSectors}" -device nvme,drive=${diskId}${bootIndex},serial=deadbeaf${diskIndex}${diskSerial}${diskSectors}${options}"
echo "$result" echo "$result"
;; ;;
"ide" | "sata" ) "ide" | "sata" )
result+=",if=none \ result+=",if=none \
-device ich9-ahci,id=ahci${diskIndex},addr=$diskAddress \ -device ich9-ahci,id=ahci${diskIndex},addr=$diskAddress \
-device ide-hd,drive=${diskId},bus=ahci$diskIndex.0,rotation_rate=$DISK_ROTATION${bootIndex}${diskSerial}${diskSectors}" -device ide-hd,drive=${diskId},bus=ahci$diskIndex.0,rotation_rate=$DISK_ROTATION${bootIndex}${diskSerial}${diskSectors}${options}"
echo "$result" echo "$result"
;; ;;
"blk" | "virtio-blk" ) "blk" | "virtio-blk" )
result+=",if=none \ result+=",if=none \
-device virtio-blk-pci,drive=${diskId},bus=$bus,addr=$diskAddress,iothread=io2${bootIndex}${diskSerial}${diskSectors}" -device virtio-blk-pci,drive=${diskId},bus=$bus,addr=$diskAddress,iothread=io2${bootIndex}${diskSerial}${diskSectors}${options}"
echo "$result" echo "$result"
;; ;;
"scsi" | "virtio-scsi" ) "scsi" | "virtio-scsi" )
result+=",if=none \ result+=",if=none \
-device virtio-scsi-pci,id=${diskId}b,bus=$bus,addr=$diskAddress,iothread=io2,hotplug=off \ -device virtio-scsi-pci,id=${diskId}b,bus=$bus,addr=$diskAddress,iothread=io2,hotplug=off \
-device scsi-hd,drive=${diskId},bus=${diskId}b.0,channel=0,scsi-id=0,lun=0,rotation_rate=$DISK_ROTATION${bootIndex}${diskSerial}${diskSectors}" -device scsi-hd,drive=${diskId},bus=${diskId}b.0,channel=0,scsi-id=0,lun=0,rotation_rate=$DISK_ROTATION${bootIndex}${diskSerial}${diskSectors}${options}"
echo "$result" echo "$result"
;; ;;
esac esac
@@ -771,6 +776,11 @@ if [[ "$DISK_FLAGS" =~ [[:space:]] ]]; then
exit 78 exit 78
fi fi
if [[ "$DISK_OPTIONS" =~ [[:space:]] ]]; then
error "Invalid DISK_OPTIONS value '$DISK_OPTIONS', spaces are not allowed."
exit 78
fi
if [ -z "$ALLOCATE" ]; then if [ -z "$ALLOCATE" ]; then
ALLOCATE="N" ALLOCATE="N"
fi fi
+5 -1
View File
@@ -449,6 +449,7 @@ configureDNS() {
local gateway="$6" local gateway="$6"
local upstream="${7:-}" local upstream="${7:-}"
local arguments="$DNSMASQ_OPTS" local arguments="$DNSMASQ_OPTS"
local pid
if ! echo "$gateway" > /run/shm/qemu.gw; then if ! echo "$gateway" > /run/shm/qemu.gw; then
error "Failed to write gateway file." error "Failed to write gateway file."
@@ -458,7 +459,10 @@ configureDNS() {
enabled "${DNSMASQ_DISABLE:-}" && return 0 enabled "${DNSMASQ_DISABLE:-}" && return 0
enabled "$DEBUG" && echo "Starting dnsmasq daemon..." enabled "$DEBUG" && echo "Starting dnsmasq daemon..."
[ -s "$DNSMASQ_PID" ] && pKill "$(<"$DNSMASQ_PID")" if readPidFile pid "$DNSMASQ_PID"; then
pKill "$pid"
fi
rm -f "$DNSMASQ_PID" rm -f "$DNSMASQ_PID"
if isNAT; then if isNAT; then
+4 -14
View File
@@ -67,16 +67,8 @@ displayReason() {
readQemuPid() { readQemuPid() {
local -n _pid="$1" readPidFile "$1" "$QEMU_START_PID" && return 0
local file readPidFile "$1" "$QEMU_PID"
for file in "$QEMU_START_PID" "$QEMU_PID"; do
if [ -s "$file" ] && read -r _pid < "$file"; then
return 0
fi
done
return 1
} }
qemuPidFile() { qemuPidFile() {
@@ -100,16 +92,14 @@ waitQemuExit() {
waitQemuPid() { waitQemuPid() {
local -n _pid="$1" local cnt=0
local cnt=0 value
while ! readQemuPid value; do while ! readQemuPid "$1"; do
sleep 0.02 sleep 0.02
cnt=$((cnt + 1)) cnt=$((cnt + 1))
(( cnt >= 50 )) && return 1 (( cnt >= 50 )) && return 1
done done
_pid="$value"
return 0 return 0
} }
+2 -2
View File
@@ -73,7 +73,7 @@ startHostBinary() {
pid=$! pid=$!
fi fi
echo "$pid" > "$HOST_PID" printf '%s\n' "$pid" > "$HOST_PID"
return 0 return 0
} }
@@ -86,7 +86,7 @@ waitForSocket() {
while [ ! -S "$socket" ]; do while [ ! -S "$socket" ]; do
if ! read -r pid < "$HOST_PID" || ! isAlive "$pid"; then if ! readPidFile pid "$HOST_PID" || ! isAlive "$pid"; then
error "qemu-host exited unexpectedly!" error "qemu-host exited unexpectedly!"
exit "$exit_code" exit "$exit_code"
fi fi
+2 -2
View File
@@ -64,7 +64,7 @@ stopWebServer() {
local pid local pid
if [ -s "$WEB_PID" ] && read -r pid < "$WEB_PID" && [ -n "$pid" ]; then if readPidFile pid "$WEB_PID"; then
pKill "$pid" 2 pKill "$pid" 2
if isAlive "$pid"; then if isAlive "$pid"; then
@@ -88,7 +88,7 @@ stopWebsocketServer() {
local pid local pid
if [ -s "$WSD_PID" ] && read -r pid < "$WSD_PID" && [ -n "$pid" ]; then if readPidFile pid "$WSD_PID"; then
pKill "$pid" 2 pKill "$pid" 2
if isAlive "$pid"; then if isAlive "$pid"; then
+20 -6
View File
@@ -7,6 +7,24 @@ info () { printf "%b%s%b" "\E[1;34m \E[1;36m" "${1:-}" "\E[0m\n"; }
error () { printf "%b%s%b" "\E[1;31m " "ERROR: ${1:-}" "\E[0m\n" >&2; } error () { printf "%b%s%b" "\E[1;31m " "ERROR: ${1:-}" "\E[0m\n" >&2; }
warn () { printf "%b%s%b" "\E[1;31m " "Warning: ${1:-}" "\E[0m\n" >&2; } warn () { printf "%b%s%b" "\E[1;31m " "Warning: ${1:-}" "\E[0m\n" >&2; }
readPidFile() {
local -n _pid="$1"
_pid=""
if ! _pid=$(cat -- "$2" 2>/dev/null); then
_pid=""
return 1
fi
if [[ ! "$_pid" =~ ^[1-9][0-9]*$ ]]; then
_pid=""
return 1
fi
return 0
}
hasFlag() { hasFlag() {
# Match a whitespace-delimited token in /proc/cpuinfo # Match a whitespace-delimited token in /proc/cpuinfo
@@ -137,9 +155,7 @@ waitPidFile() {
local file="$1" local file="$1"
local timeout="${2:-10}" local timeout="${2:-10}"
[ ! -s "$file" ] && return 0 ! readPidFile pid "$file" && return 0
! read -r pid <"$file" && return 0
[ -z "$pid" ] && return 0
while [ -s "$file" ] && isAlive "$pid"; do while [ -s "$file" ] && isAlive "$pid"; do
sleep 0.2 sleep 0.2
@@ -203,9 +219,7 @@ sKill() {
local pid local pid
local file="$1" local file="$1"
[ ! -s "$file" ] && return 0 ! readPidFile pid "$file" && return 0
! read -r pid <"$file" && return 0
[ -z "$pid" ] && return 0
if isAlive "$pid"; then if isAlive "$pid"; then
{ kill -15 -- "$pid" || :; } 2>/dev/null { kill -15 -- "$pid" || :; } 2>/dev/null
+10 -3
View File
@@ -71,6 +71,13 @@ function processInfo() {
var response = request; var response = request;
request = null; request = null;
var status = response.status;
if (status == 502 || status == 503 || status == 504) {
schedule();
return true;
}
var msg = response.responseText; var msg = response.responseText;
if (msg == null || msg.length == 0) { if (msg == null || msg.length == 0) {
@@ -83,9 +90,9 @@ function processInfo() {
return false; return false;
} }
var notFound = (response.status == 404); var notFound = (status == 404);
if (response.status == 200) { if (status == 200) {
if (msg.toLowerCase().indexOf("<html>") !== -1) { if (msg.toLowerCase().indexOf("<html>") !== -1) {
notFound = true; notFound = true;
} else { } else {
@@ -103,7 +110,7 @@ function processInfo() {
return true; return true;
} }
setError("Error: Received statuscode " + response.status); setError("Error: Received statuscode " + status);
return false; return false;
} catch (e) { } catch (e) {