]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Simplify handling of virTristateBool values
authorAndrea Bolognani <abologna@redhat.com>
Thu, 9 Jun 2022 17:09:31 +0000 (19:09 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Thu, 16 Jun 2022 13:27:16 +0000 (15:27 +0200)
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>
src/qemu/qemu_firmware.c

index f2a1bc81ac9eecda4cb852b35e18eb8ec2394bac..1dd5c096364da6f2f67ff0dd14179d357b84f2b4 100644 (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;
         }
     }