mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-06-04 07:27:19 +08:00
feat: Add automatic device type (#749)
This commit is contained in:
parent
fb1751ff26
commit
c135c4cac3
@ -115,12 +115,11 @@ kubectl apply -f kubernetes.yml
|
||||
|
||||
* ### How do I pass-through a disk?
|
||||
|
||||
It is possible to pass-through disk devices directly by adding them to your compose file in this way:
|
||||
It is possible to pass-through a disk device directly, by adding it to your compose file in this way:
|
||||
|
||||
```yaml
|
||||
devices:
|
||||
- /dev/disk/by-uuid/12345-12345-12345-12345-12345:/disk2
|
||||
- /dev/disk/by-uuid/45678-45678-45678-45678-45678:/disk3
|
||||
```
|
||||
|
||||
Make sure to bind the disk via its UUID (obtainable via `lsblk -o name,uuid`) instead of its name (`/dev/sdc`), to prevent ever binding the wrong disk when the drive letters happen to change.
|
||||
@ -129,11 +128,11 @@ kubectl apply -f kubernetes.yml
|
||||
|
||||
Do NOT use this feature with the goal of sharing files from the host, they will all be lost without warning when DSM creates the volume.
|
||||
|
||||
* ### How do I increase the amount of CPU or RAM?
|
||||
* ### How do I change the amount of CPU or RAM?
|
||||
|
||||
By default, a single CPU core and 1 GB of RAM are allocated to the container.
|
||||
By default, the container will be allowed to use a maximum of 1 CPU core and 1 GB of RAM.
|
||||
|
||||
If there arises a need to increase this, add the following environment variables:
|
||||
If you want to adjust this, you can specify the desired amount using the following environment variables:
|
||||
|
||||
```yaml
|
||||
environment:
|
||||
|
@ -4,7 +4,7 @@ set -Eeuo pipefail
|
||||
DEF_OPTS="-nodefaults -boot strict=on"
|
||||
RAM_OPTS=$(echo "-m ${RAM_SIZE^^}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g')
|
||||
CPU_OPTS="-cpu $CPU_FLAGS -smp $CPU_CORES,sockets=1,dies=1,cores=$CPU_CORES,threads=1"
|
||||
MAC_OPTS="-machine type=q35,usb=off,vmport=off,dump-guest-core=off,hpet=off${KVM_OPTS}"
|
||||
MAC_OPTS="-machine type=q35,smm=off,usb=off,vmport=off,dump-guest-core=off,hpet=off${KVM_OPTS}"
|
||||
DEV_OPTS="-device virtio-balloon-pci,id=balloon0,bus=pcie.0,addr=0x4"
|
||||
DEV_OPTS="$DEV_OPTS -object rng-random,id=objrng0,filename=/dev/urandom"
|
||||
DEV_OPTS="$DEV_OPTS -device virtio-rng-pci,rng=objrng0,id=rng0,bus=pcie.0,addr=0x1c"
|
||||
|
15
src/disk.sh
15
src/disk.sh
@ -359,26 +359,29 @@ createDevice () {
|
||||
|
||||
local index=""
|
||||
[ -n "$DISK_INDEX" ] && index=",bootindex=$DISK_INDEX"
|
||||
local result="-drive file=$DISK_FILE,id=$DISK_ID,if=none,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
|
||||
"auto" )
|
||||
echo "$result"
|
||||
;;
|
||||
"usb" )
|
||||
result="$result \
|
||||
result="$result,if=none \
|
||||
-device usb-storage,drive=${DISK_ID}${index}"
|
||||
echo "$result"
|
||||
;;
|
||||
"ide" )
|
||||
result="$result \
|
||||
result="$result,if=none \
|
||||
-device ide-hd,drive=${DISK_ID},bus=ide.$DISK_INDEX,rotation_rate=$DISK_ROTATION${index}"
|
||||
echo "$result"
|
||||
;;
|
||||
"blk" | "virtio-blk" )
|
||||
result="$result \
|
||||
result="$result,if=none \
|
||||
-device virtio-blk-pci,drive=${DISK_ID},scsi=off,bus=pcie.0,addr=$DISK_ADDRESS,iothread=io2${index}"
|
||||
echo "$result"
|
||||
;;
|
||||
"scsi" | "virtio-scsi" )
|
||||
result="$result \
|
||||
result="$result,if=none \
|
||||
-device virtio-scsi-pci,id=${DISK_ID}b,bus=pcie.0,addr=$DISK_ADDRESS,iothread=io2 \
|
||||
-device scsi-hd,drive=${DISK_ID},bus=${DISK_ID}b.0,channel=0,scsi-id=0,lun=0,rotation_rate=$DISK_ROTATION${index}"
|
||||
echo "$result"
|
||||
@ -480,7 +483,7 @@ html "Initializing disks..."
|
||||
|
||||
case "${DISK_TYPE,,}" in
|
||||
"" ) DISK_TYPE="scsi" ;;
|
||||
"ide" | "usb" | "blk" | "scsi" ) ;;
|
||||
"auto" | "ide" | "usb" | "blk" | "scsi" ) ;;
|
||||
* ) error "Invalid DISK_TYPE, value \"$DISK_TYPE\" is unrecognized!" && exit 80 ;;
|
||||
esac
|
||||
|
||||
|
@ -32,4 +32,4 @@ tail -fn +0 "$QEMU_LOG" 2>/dev/null &
|
||||
cat "$QEMU_TERM" 2>/dev/null & wait $! || :
|
||||
|
||||
sleep 1 & wait $!
|
||||
finish 0
|
||||
[ ! -f "$QEMU_END" ] && finish 0
|
||||
|
@ -329,8 +329,8 @@ if [[ "$DHCP" == [Yy1]* ]]; then
|
||||
|
||||
! checkOS && [[ "$DEBUG" != [Yy1]* ]] && exit 19
|
||||
|
||||
if [[ "$GATEWAY" == "172."* ]]; then
|
||||
warn "your gateway IP starts with 172.* which is often a sign that you are not on a macvlan network (required for DHCP)!"
|
||||
if [[ "$IP" == "172."* ]]; then
|
||||
warn "container IP starts with 172.* which is often a sign that you are not on a macvlan network (required for DHCP)!"
|
||||
fi
|
||||
|
||||
# Configuration for DHCP IP
|
||||
@ -341,7 +341,7 @@ if [[ "$DHCP" == [Yy1]* ]]; then
|
||||
|
||||
else
|
||||
|
||||
if [[ "$GATEWAY" != "172."* ]] && [[ "$GATEWAY" != "10.8"* ]] && [[ "$GATEWAY" != "10.9"* ]]; then
|
||||
if [[ "$IP" != "172."* ]] && [[ "$IP" != "10.8"* ]] && [[ "$IP" != "10.9"* ]]; then
|
||||
! checkOS && [[ "$DEBUG" != [Yy1]* ]] && exit 19
|
||||
fi
|
||||
|
||||
|
@ -43,7 +43,8 @@ HOST=$(hostname -s)
|
||||
KERNEL=$(echo "$SYS" | cut -b 1)
|
||||
MINOR=$(echo "$SYS" | cut -d '.' -f2)
|
||||
ARCH=$(dpkg --print-architecture)
|
||||
CPU=$(lscpu | grep -m 1 'Model name' | cut -f 2 -d ":" | awk '{$1=$1}1' | sed 's# @.*##g' | sed s/"(R)"//g | sed 's/[^[:alnum:] ]\+/ /g' | sed 's/ */ /g')
|
||||
SOCKETS=$(lscpu | grep -m 1 -i 'socket(s)' | awk '{print $(2)}')
|
||||
CPU=$(lscpu | grep -m 1 -i 'model name' | cut -f 2 -d ":" | awk '{$1=$1}1' | sed 's# @.*##g' | sed s/"(R)"//g | sed 's/[^[:alnum:] ]\+/ /g' | sed 's/ */ /g')
|
||||
|
||||
# Check system
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user