1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-11 09:17:52 +03:00

qemu: Simplify handling of virTristateBool values

We explicitly check whether the value is YES or NO, which makes
it unnecessary to make sure it's not ABSENT beforehand.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Andrea Bolognani 2022-06-09 19:09:31 +02:00
parent 58805f3ace
commit 8c75efd4ef

View File

@ -1080,31 +1080,25 @@ qemuFirmwareMatchDomain(const virDomainDef *def,
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;
}
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 (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;
}
}