summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmodules.d/dnbd3-rootfs/hooks/s3-dnbd3root.sh40
1 files changed, 16 insertions, 24 deletions
diff --git a/modules.d/dnbd3-rootfs/hooks/s3-dnbd3root.sh b/modules.d/dnbd3-rootfs/hooks/s3-dnbd3root.sh
index 47217c29..6c62480a 100755
--- a/modules.d/dnbd3-rootfs/hooks/s3-dnbd3root.sh
+++ b/modules.d/dnbd3-rootfs/hooks/s3-dnbd3root.sh
@@ -11,26 +11,14 @@ declare -rg _dnbd3_dev="/dev/dnbd0"
# all outputs are redirected to stderr, since this functions should
# only echo the path to the unpacked container to stdout.
-container_unpack_xmount() {
+container_unpack_raw() {
local in_device="$1"
- local out_path="/mnt/xmount"
- mkdir -p "$out_path"
- # check tools first
- if ! hash xmount systemd-preserve-process-marker; then
- echo "Missing xmount deps, will try raw..." 1>&2
- elif ! systemd-preserve-process-marker xmount \
- --in qemu "$in_device" \
- --out raw "$out_path" &>/dev/null; then
- echo "xmount call failed, assuming raw image." 1>&2
- else
- in_device="${out_path}/${_dnbd3_dev##*/}.dd"
- fi
local out_device="$(losetup -f)"
if ! losetup "$out_device" "$in_device" --partscan; then
echo "Failed to attach '$in_device' to '$out_device'."
return 1
- fi
- udevadm settle
+ fi >&2
+ udevadm settle >&2
echo "$out_device"
}
@@ -41,12 +29,12 @@ container_unpack_xloop() {
if ! modprobe "${kmod}"; then
echo "Failed to load kernel module: $kmod"
fi
- done
+ done >&2
if ! xlosetup -r -t QCOW "$out_device" "$in_device" --partscan; then
echo "Failed to attach '$in_device' to '$out_device'."
- return
- fi
- udevadm settle
+ return 1
+ fi >&2
+ udevadm settle >&2
echo "$out_device"
}
# endregion
@@ -98,19 +86,23 @@ done
# endregion
# region unpack dnbd3 image
-if ! [[ $SLX_QCOW_HANDLER =~ ^(kernel|xloop|xmount)?$ ]]; then
- emergency_shell "Unsupported QCOW handler: $SLX_QCOW_HANDLER" \
- "Use either 'xmount' or 'xloop'."
+if [[ $SLX_QCOW_HANDLER = xmount ]]; then
+ emergency_shell "xmount support is unmaintained, broken, and has been removed. Consider using xloop"
+ exit 1
+fi
+if ! [[ $SLX_QCOW_HANDLER =~ ^(kernel|xloop|raw)?$ ]]; then
+ emergency_shell "Unsupported image handler: $SLX_QCOW_HANDLER" \
+ "Use either 'raw' or 'xloop'."
fi
if [ -z "$SLX_QCOW_HANDLER" ]; then
SLX_QCOW_HANDLER="xloop"
echo "SLX_QCOW_HANDLER='$SLX_QCOW_HANDLER'" >> /etc/openslx
fi
-if [[ $SLX_QCOW_HANDLER =~ ^kernel|xloop$ ]]; then
+if [[ $SLX_QCOW_HANDLER =~ ^(kernel|xloop)$ ]]; then
read_only_device="$(container_unpack_xloop "$_dnbd3_dev")"
fi
if [ -z "$read_only_device" ]; then
- read_only_device="$(container_unpack_xmount "$_dnbd3_dev")"
+ read_only_device="$(container_unpack_raw "$_dnbd3_dev")"
fi
# Fail fast if unpacking dnbd3 image failed.