mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-06-08 01:18:32 +08:00
fix: Set qcow2 flags
This commit is contained in:
parent
e7cdbb1db5
commit
72085d3711
11
src/disk.sh
11
src/disk.sh
@ -8,6 +8,7 @@ set -Eeuo pipefail
|
|||||||
: ${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:='on'} # Controls whether unmap (TRIM) commands are passed to the host.
|
: ${DISK_DISCARD:='on'} # 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
|
||||||
|
: ${DISK_FLAGS:='nocow=on'} # Specify the options for use with the qcow2 format
|
||||||
|
|
||||||
BOOT="$STORAGE/$BASE.boot.img"
|
BOOT="$STORAGE/$BASE.boot.img"
|
||||||
SYSTEM="$STORAGE/$BASE.system.img"
|
SYSTEM="$STORAGE/$BASE.system.img"
|
||||||
@ -23,8 +24,6 @@ DISK_OPTS="\
|
|||||||
-drive file=$SYSTEM,if=none,id=drive-synosys,format=raw,cache=$DISK_CACHE,aio=$DISK_IO,discard=$DISK_DISCARD,detect-zeroes=on \
|
-drive file=$SYSTEM,if=none,id=drive-synosys,format=raw,cache=$DISK_CACHE,aio=$DISK_IO,discard=$DISK_DISCARD,detect-zeroes=on \
|
||||||
-device scsi-hd,bus=hw-synosys.0,channel=0,scsi-id=0,lun=0,drive=drive-synosys,id=synosys0,rotation_rate=$DISK_ROTATION,bootindex=2"
|
-device scsi-hd,bus=hw-synosys.0,channel=0,scsi-id=0,lun=0,drive=drive-synosys,id=synosys0,rotation_rate=$DISK_ROTATION,bootindex=2"
|
||||||
|
|
||||||
: ${QCOW_FLAGS:='nocow=on,preallocation=metadata,lazy_refcounts=on'}
|
|
||||||
|
|
||||||
fmt2ext() {
|
fmt2ext() {
|
||||||
local DISK_FMT=$1
|
local DISK_FMT=$1
|
||||||
|
|
||||||
@ -123,7 +122,7 @@ resizeDisk() {
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
qcow2)
|
qcow2)
|
||||||
if ! qemu-img resize -f "$DISK_FMT" "$DISK_FILE" "$DISK_SPACE" ; then
|
if ! qemu-img resize -f "$DISK_FMT" -o "$DISK_FLAGS" "$DISK_FILE" "$DISK_SPACE" ; then
|
||||||
error "$FAIL" && exit 72
|
error "$FAIL" && exit 72
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
@ -139,12 +138,12 @@ convertDisk() {
|
|||||||
|
|
||||||
case "$DST_FMT" in
|
case "$DST_FMT" in
|
||||||
qcow2)
|
qcow2)
|
||||||
CONV_FLAGS="$CONV_FLAGS -c -o $QCOW_FLAGS"
|
CONV_FLAGS="$CONV_FLAGS -c -o $DISK_FLAGS"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
qemu-img convert $CONV_FLAGS -f "$SOURCE_FMT" -O "$DST_FMT" -- "$SOURCE_FILE" "$DST_FILE"
|
qemu-img convert -f "$SOURCE_FMT" $CONV_FLAGS -O "$DST_FMT" -- "$SOURCE_FILE" "$DST_FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
createDisk() {
|
createDisk() {
|
||||||
@ -188,7 +187,7 @@ createDisk() {
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
qcow2)
|
qcow2)
|
||||||
if ! qemu-img create -f "$DISK_FMT" -o "$QCOW_FLAGS" -- "$DISK_FILE" "$DISK_SPACE" ; then
|
if ! qemu-img create -f "$DISK_FMT" -o "$DISK_FLAGS" -- "$DISK_FILE" "$DISK_SPACE" ; then
|
||||||
rm -f "$DISK_FILE"
|
rm -f "$DISK_FILE"
|
||||||
error "$FAIL" && exit 70
|
error "$FAIL" && exit 70
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user