feat: Add NVME device (#141)
This commit is contained in:
parent
40e583f1b4
commit
a7a6d0a7ee
2 changed files with 26 additions and 16 deletions
26
src/disk.sh
26
src/disk.sh
|
@ -3,7 +3,7 @@ set -Eeuo pipefail
|
||||||
|
|
||||||
# Docker environment variables
|
# Docker environment variables
|
||||||
|
|
||||||
: "${DISK_IO:="native"}" # I/O Mode, can be set to 'native', 'threads' or 'io_turing'
|
: "${DISK_IO:="native"}" # I/O Mode, can be set to 'native', 'threads' or 'io_uring'
|
||||||
: "${DISK_FMT:=""}" # Disk file format, can be set to "raw" (default) or "qcow2"
|
: "${DISK_FMT:=""}" # Disk file format, can be set to "raw" (default) or "qcow2"
|
||||||
: "${DISK_TYPE:=""}" # Device type to be used, choose "ide", "usb", "blk" or "scsi"
|
: "${DISK_TYPE:=""}" # Device type to be used, choose "ide", "usb", "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
|
||||||
|
@ -363,6 +363,7 @@ createDevice () {
|
||||||
local result=" -drive file=$DISK_FILE,id=$DISK_ID,format=$DISK_FMT,cache=$DISK_CACHE,aio=$DISK_IO,discard=$DISK_DISCARD,detect-zeroes=on"
|
local result=" -drive file=$DISK_FILE,id=$DISK_ID,format=$DISK_FMT,cache=$DISK_CACHE,aio=$DISK_IO,discard=$DISK_DISCARD,detect-zeroes=on"
|
||||||
|
|
||||||
case "${DISK_TYPE,,}" in
|
case "${DISK_TYPE,,}" in
|
||||||
|
"none" ) ;;
|
||||||
"auto" )
|
"auto" )
|
||||||
echo "$result"
|
echo "$result"
|
||||||
;;
|
;;
|
||||||
|
@ -371,7 +372,12 @@ createDevice () {
|
||||||
-device usb-storage,drive=${DISK_ID}${index}"
|
-device usb-storage,drive=${DISK_ID}${index}"
|
||||||
echo "$result"
|
echo "$result"
|
||||||
;;
|
;;
|
||||||
"ide" )
|
"nvme" )
|
||||||
|
result+=",if=none \
|
||||||
|
-device nvme,drive=${DISK_ID}${index},serial=deadbeaf${DISK_INDEX}"
|
||||||
|
echo "$result"
|
||||||
|
;;
|
||||||
|
"ide" | "sata" )
|
||||||
result+=",if=none \
|
result+=",if=none \
|
||||||
-device ich9-ahci,id=ahci${DISK_INDEX},addr=$DISK_ADDRESS \
|
-device ich9-ahci,id=ahci${DISK_INDEX},addr=$DISK_ADDRESS \
|
||||||
-device ide-hd,drive=${DISK_ID},bus=ahci$DISK_INDEX.0,rotation_rate=$DISK_ROTATION${index}"
|
-device ide-hd,drive=${DISK_ID},bus=ahci$DISK_INDEX.0,rotation_rate=$DISK_ROTATION${index}"
|
||||||
|
@ -406,6 +412,7 @@ addMedia () {
|
||||||
local result=" -drive file=$DISK_FILE,id=$DISK_ID,format=raw,cache=unsafe,readonly=on,media=cdrom"
|
local result=" -drive file=$DISK_FILE,id=$DISK_ID,format=raw,cache=unsafe,readonly=on,media=cdrom"
|
||||||
|
|
||||||
case "${DISK_TYPE,,}" in
|
case "${DISK_TYPE,,}" in
|
||||||
|
"none" ) ;;
|
||||||
"auto" )
|
"auto" )
|
||||||
echo "$result"
|
echo "$result"
|
||||||
;;
|
;;
|
||||||
|
@ -414,7 +421,12 @@ addMedia () {
|
||||||
-device usb-storage,drive=${DISK_ID}${index},removable=on"
|
-device usb-storage,drive=${DISK_ID}${index},removable=on"
|
||||||
echo "$result"
|
echo "$result"
|
||||||
;;
|
;;
|
||||||
"ide" )
|
"nvme" )
|
||||||
|
result+=",if=none \
|
||||||
|
-device nvme,drive=${DISK_ID}${index},serial=deadbeaf${DISK_INDEX}"
|
||||||
|
echo "$result"
|
||||||
|
;;
|
||||||
|
"ide" | "sata" )
|
||||||
result+=",if=none \
|
result+=",if=none \
|
||||||
-device ich9-ahci,id=ahci${DISK_INDEX},addr=$DISK_ADDRESS \
|
-device ich9-ahci,id=ahci${DISK_INDEX},addr=$DISK_ADDRESS \
|
||||||
-device ide-cd,drive=${DISK_ID},bus=ahci${DISK_INDEX}.0${index}"
|
-device ide-cd,drive=${DISK_ID},bus=ahci${DISK_INDEX}.0${index}"
|
||||||
|
@ -532,7 +544,7 @@ html "Initializing disks..."
|
||||||
[ -z "${DISK_NAME:-}" ] && DISK_NAME="data"
|
[ -z "${DISK_NAME:-}" ] && DISK_NAME="data"
|
||||||
|
|
||||||
case "${DISK_TYPE,,}" in
|
case "${DISK_TYPE,,}" in
|
||||||
"ide" | "usb" | "scsi" | "blk" | "auto" ) ;;
|
"ide" | "sata" | "usb" | "scsi" | "blk" | "auto" ) ;;
|
||||||
* ) error "Invalid DISK_TYPE specified, value \"$DISK_TYPE\" is not recognized!" && exit 80 ;;
|
* ) error "Invalid DISK_TYPE specified, value \"$DISK_TYPE\" is not recognized!" && exit 80 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -546,15 +558,19 @@ case "${MACHINE,,}" in
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ -z "${MEDIA_TYPE:-}" ]; then
|
if [ -z "${MEDIA_TYPE:-}" ]; then
|
||||||
|
if [[ "${BOOT_MODE:-}" != "windows"* ]]; then
|
||||||
if [[ "${DISK_TYPE,,}" == "blk" ]]; then
|
if [[ "${DISK_TYPE,,}" == "blk" ]]; then
|
||||||
MEDIA_TYPE="$FALLBACK"
|
MEDIA_TYPE="$FALLBACK"
|
||||||
else
|
else
|
||||||
MEDIA_TYPE="$DISK_TYPE"
|
MEDIA_TYPE="$DISK_TYPE"
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
MEDIA_TYPE="$FALLBACK"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "${MEDIA_TYPE,,}" in
|
case "${MEDIA_TYPE,,}" in
|
||||||
"ide" | "usb" | "scsi" | "blk" | "auto" ) ;;
|
"ide" | "sata" | "usb" | "scsi" | "blk" | "auto" ) ;;
|
||||||
* ) error "Invalid MEDIA_TYPE specified, value \"$MEDIA_TYPE\" is not recognized!" && exit 80 ;;
|
* ) error "Invalid MEDIA_TYPE specified, value \"$MEDIA_TYPE\" is not recognized!" && exit 80 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
|
@ -3,15 +3,9 @@ set -Eeuo pipefail
|
||||||
|
|
||||||
# Docker environment variables
|
# Docker environment variables
|
||||||
|
|
||||||
: "${VGA:=""}" # VGA adaptor
|
: "${VGA:="ramfb"}" # VGA adaptor
|
||||||
: "${DISPLAY:="web"}" # Display type
|
: "${DISPLAY:="web"}" # Display type
|
||||||
|
|
||||||
if [[ "${BOOT_MODE:-}" == "windows"* ]]; then
|
|
||||||
[ -z "$VGA" ] && VGA="ramfb"
|
|
||||||
else
|
|
||||||
[ -z "$VGA" ] && VGA="virtio-gpu"
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "${DISPLAY,,}" in
|
case "${DISPLAY,,}" in
|
||||||
vnc)
|
vnc)
|
||||||
DISPLAY_OPTS="-display vnc=:0 -device $VGA"
|
DISPLAY_OPTS="-display vnc=:0 -device $VGA"
|
||||||
|
|
Loading…
Reference in a new issue