mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 05:17:59 +03:00
qemu: implement support for firmware auto-selection feature filtering
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
cff524af6c
commit
c91fa27306
@ -930,6 +930,10 @@ qemuFirmwareMatchDomain(const virDomainDef *def,
|
||||
bool supportsS4 = false;
|
||||
bool requiresSMM = false;
|
||||
bool supportsSEV = false;
|
||||
bool supportsSecureBoot = false;
|
||||
bool hasEnrolledKeys = false;
|
||||
int reqSecureBoot;
|
||||
int reqEnrolledKeys;
|
||||
|
||||
want = qemuFirmwareOSInterfaceTypeFromOsDefFirmware(def->os.firmware);
|
||||
|
||||
@ -979,7 +983,13 @@ qemuFirmwareMatchDomain(const virDomainDef *def,
|
||||
break;
|
||||
|
||||
case QEMU_FIRMWARE_FEATURE_SECURE_BOOT:
|
||||
supportsSecureBoot = true;
|
||||
break;
|
||||
|
||||
case QEMU_FIRMWARE_FEATURE_ENROLLED_KEYS:
|
||||
hasEnrolledKeys = true;
|
||||
break;
|
||||
|
||||
case QEMU_FIRMWARE_FEATURE_VERBOSE_DYNAMIC:
|
||||
case QEMU_FIRMWARE_FEATURE_VERBOSE_STATIC:
|
||||
case QEMU_FIRMWARE_FEATURE_NONE:
|
||||
@ -1000,6 +1010,36 @@ qemuFirmwareMatchDomain(const virDomainDef *def,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (def->os.firmwareFeatures) {
|
||||
reqSecureBoot = def->os.firmwareFeatures[VIR_DOMAIN_OS_DEF_FIRMWARE_FEATURE_SECURE_BOOT];
|
||||
if (reqSecureBoot != VIR_TRISTATE_BOOL_ABSENT) {
|
||||
if (reqSecureBoot == VIR_TRISTATE_BOOL_YES && !supportsSecureBoot) {
|
||||
VIR_DEBUG("User requested Secure Boot, firmware '%s' doesn't support it",
|
||||
path);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (reqSecureBoot == VIR_TRISTATE_BOOL_NO && supportsSecureBoot) {
|
||||
VIR_DEBUG("User refused Secure Boot, firmware '%s' supports it", path);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
reqEnrolledKeys = def->os.firmwareFeatures[VIR_DOMAIN_OS_DEF_FIRMWARE_FEATURE_ENROLLED_KEYS];
|
||||
if (reqEnrolledKeys != VIR_TRISTATE_BOOL_ABSENT) {
|
||||
if (reqEnrolledKeys == VIR_TRISTATE_BOOL_YES && !hasEnrolledKeys) {
|
||||
VIR_DEBUG("User requested Enrolled keys, firmware '%s' doesn't have them",
|
||||
path);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (reqEnrolledKeys == VIR_TRISTATE_BOOL_NO && hasEnrolledKeys) {
|
||||
VIR_DEBUG("User refused Enrolled keys, firmware '%s' has them", path);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (def->os.loader &&
|
||||
def->os.loader->secure == VIR_TRISTATE_BOOL_YES &&
|
||||
!requiresSMM) {
|
||||
|
@ -0,0 +1,49 @@
|
||||
LC_ALL=C \
|
||||
PATH=/bin \
|
||||
HOME=/tmp/lib/domain--1-fedora \
|
||||
USER=test \
|
||||
LOGNAME=test \
|
||||
XDG_DATA_HOME=/tmp/lib/domain--1-fedora/.local/share \
|
||||
XDG_CACHE_HOME=/tmp/lib/domain--1-fedora/.cache \
|
||||
XDG_CONFIG_HOME=/tmp/lib/domain--1-fedora/.config \
|
||||
/usr/bin/qemu-system-x86_64 \
|
||||
-name guest=fedora,debug-threads=on \
|
||||
-S \
|
||||
-object secret,id=masterKey0,format=raw,\
|
||||
file=/tmp/lib/domain--1-fedora/master-key.aes \
|
||||
-blockdev '{"driver":"file","filename":"/usr/share/OVMF/OVMF_CODE.fd",\
|
||||
"node-name":"libvirt-pflash0-storage","auto-read-only":true,\
|
||||
"discard":"unmap"}' \
|
||||
-blockdev '{"node-name":"libvirt-pflash0-format","read-only":true,\
|
||||
"driver":"raw","file":"libvirt-pflash0-storage"}' \
|
||||
-blockdev '{"driver":"file",\
|
||||
"filename":"/var/lib/libvirt/qemu/nvram/fedora_VARS.fd",\
|
||||
"node-name":"libvirt-pflash1-storage","auto-read-only":true,\
|
||||
"discard":"unmap"}' \
|
||||
-blockdev '{"node-name":"libvirt-pflash1-format","read-only":false,\
|
||||
"driver":"raw","file":"libvirt-pflash1-storage"}' \
|
||||
-machine pc-q35-4.0,accel=kvm,usb=off,dump-guest-core=off,\
|
||||
pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-format,\
|
||||
memory-backend=pc.ram \
|
||||
-cpu qemu64 \
|
||||
-m 8 \
|
||||
-object memory-backend-ram,id=pc.ram,size=8388608 \
|
||||
-overcommit mem-lock=off \
|
||||
-smp 1,sockets=1,cores=1,threads=1 \
|
||||
-uuid 63840878-0deb-4095-97e6-fc444d9bc9fa \
|
||||
-display none \
|
||||
-no-user-config \
|
||||
-nodefaults \
|
||||
-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
|
||||
-mon chardev=charmonitor,id=monitor,mode=control \
|
||||
-rtc base=utc \
|
||||
-no-shutdown \
|
||||
-boot strict=on \
|
||||
-device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,\
|
||||
addr=0x1 \
|
||||
-device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \
|
||||
-device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \
|
||||
-audiodev id=audio1,driver=none \
|
||||
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
|
||||
resourcecontrol=deny \
|
||||
-msg timestamp=on
|
50
tests/qemuxml2argvdata/os-firmware-efi-no-enrolled-keys.xml
Normal file
50
tests/qemuxml2argvdata/os-firmware-efi-no-enrolled-keys.xml
Normal file
@ -0,0 +1,50 @@
|
||||
<domain type='kvm'>
|
||||
<name>fedora</name>
|
||||
<uuid>63840878-0deb-4095-97e6-fc444d9bc9fa</uuid>
|
||||
<memory unit='KiB'>8192</memory>
|
||||
<currentMemory unit='KiB'>8192</currentMemory>
|
||||
<vcpu placement='static'>1</vcpu>
|
||||
<os firmware='efi'>
|
||||
<type arch='x86_64' machine='pc-q35-4.0'>hvm</type>
|
||||
<firmware type='efi'>
|
||||
<feature enabled='no' name='enrolled-keys'/>
|
||||
</firmware>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<features>
|
||||
<acpi/>
|
||||
<apic/>
|
||||
<pae/>
|
||||
</features>
|
||||
<cpu mode='custom' match='exact' check='none'>
|
||||
<model fallback='forbid'>qemu64</model>
|
||||
</cpu>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-system-x86_64</emulator>
|
||||
<controller type='pci' index='0' model='pcie-root'/>
|
||||
<controller type='pci' index='1' model='pcie-root-port'>
|
||||
<model name='pcie-root-port'/>
|
||||
<target chassis='1' port='0x8'/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0' multifunction='on'/>
|
||||
</controller>
|
||||
<controller type='pci' index='2' model='pcie-root-port'>
|
||||
<model name='pcie-root-port'/>
|
||||
<target chassis='2' port='0x9'/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
|
||||
</controller>
|
||||
<controller type='usb' index='0' model='qemu-xhci'>
|
||||
<address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
|
||||
</controller>
|
||||
<controller type='sata' index='0'>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
|
||||
</controller>
|
||||
<input type='mouse' bus='ps2'/>
|
||||
<input type='keyboard' bus='ps2'/>
|
||||
<audio id='1' type='none'/>
|
||||
<memballoon model='none'/>
|
||||
</devices>
|
||||
</domain>
|
@ -3549,6 +3549,7 @@ mymain(void)
|
||||
DO_TEST_CAPS_LATEST("os-firmware-bios");
|
||||
DO_TEST_CAPS_LATEST("os-firmware-efi");
|
||||
DO_TEST_CAPS_LATEST("os-firmware-efi-secboot");
|
||||
DO_TEST_CAPS_LATEST("os-firmware-efi-no-enrolled-keys");
|
||||
DO_TEST_CAPS_LATEST_PARSE_ERROR("os-firmware-invalid-type");
|
||||
DO_TEST_CAPS_ARCH_LATEST("aarch64-os-firmware-efi", "aarch64");
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
../qemuxml2argvdata/os-firmware-efi-no-enrolled-keys.xml
|
@ -1123,6 +1123,7 @@ mymain(void)
|
||||
DO_TEST_CAPS_LATEST("os-firmware-bios");
|
||||
DO_TEST_CAPS_LATEST("os-firmware-efi");
|
||||
DO_TEST_CAPS_LATEST("os-firmware-efi-secboot");
|
||||
DO_TEST_CAPS_LATEST("os-firmware-efi-no-enrolled-keys");
|
||||
|
||||
DO_TEST("aarch64-aavmf-virtio-mmio",
|
||||
QEMU_CAPS_DEVICE_VIRTIO_MMIO,
|
||||
|
Loading…
Reference in New Issue
Block a user