feat: Validate BIOS serial (#230)

This commit is contained in:
Kroese 2025-03-27 01:08:17 +01:00 committed by GitHub
parent be36019608
commit cd018a0cca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 1 deletions

View file

@ -29,7 +29,6 @@ RUN set -eu && \
xz-utils \
net-tools \
e2fsprogs \
dmidecode \
qemu-utils \
iputils-ping \
genisoimage \

View file

@ -99,4 +99,17 @@ else
esac
fi
SM_BIOS=""
if [ -s "/sys/class/dmi/id/product_serial" ]; then
BIOS_SERIAL=$(</sys/class/dmi/id/product_serial)
BIOS_SERIAL="${BIOS_SERIAL//[![:alnum:]]/}"
if [ -n "$BIOS_SERIAL" ]; then
SM_BIOS="-smbios type=1,serial=$BIOS_SERIAL"
fi
fi
return 0

View file

@ -14,7 +14,10 @@ RAM_OPTS=$(echo "-m ${RAM_SIZE^^}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g')
MON_OPTS="-monitor $MONITOR -name $PROCESS,process=$PROCESS,debug-threads=on"
[ -n "$USB" ] && [[ "${USB,,}" != "no"* ]] && USB_OPTS="-device $USB -device usb-kbd -device usb-tablet"
MAC_OPTS="-machine type=${MACHINE},secure=${SECURE},dump-guest-core=off${KVM_OPTS}"
[ -n "$UUID" ] && MAC_OPTS+=" -uuid $UUID"
[ -n "$SM_BIOS" ] && MAC_OPTS+=" $SM_BIOS"
DEV_OPTS="-object rng-random,id=objrng0,filename=/dev/urandom"
DEV_OPTS+=" -device virtio-rng-pci,rng=objrng0,id=rng0,bus=pcie.0"