On Tue, Jan 07, 2020 at 02:43:23PM +0100, Michal Privoznik wrote:
This simplifies condition when matching FW interface by having a
single line condition instead of multiline one. Also, it prepares
the code for future expansion.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_firmware.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c
index b9bb1df179..a3305d5554 100644
--- a/src/qemu/qemu_firmware.c
+++ b/src/qemu/qemu_firmware.c
@@ -928,22 +928,39 @@ qemuFirmwareMatchesMachineArch(const qemuFirmware *fw,
}
+static qemuFirmwareOSInterface
+qemuFirmwareOSInterfaceTypeFromOsDefFirmware(virDomainOsDefFirmware fw)
+{
+ switch (fw) {
+ case VIR_DOMAIN_OS_DEF_FIRMWARE_BIOS:
+ return QEMU_FIRMWARE_OS_INTERFACE_BIOS;
+ case VIR_DOMAIN_OS_DEF_FIRMWARE_EFI:
+ return QEMU_FIRMWARE_OS_INTERFACE_UEFI;
+ case VIR_DOMAIN_OS_DEF_FIRMWARE_NONE:
+ case VIR_DOMAIN_OS_DEF_FIRMWARE_LAST:
+ break;
+ }
+
+ return QEMU_FIRMWARE_OS_INTERFACE_NONE;
+}
+
+
static bool
qemuFirmwareMatchDomain(const virDomainDef *def,
const qemuFirmware *fw,
const char *path)
{
size_t i;
+ qemuFirmwareOSInterface want;
bool supportsS3 = false;
bool supportsS4 = false;
bool requiresSMM = false;
bool supportsSEV = false;
+ want = qemuFirmwareOSInterfaceTypeFromOsDefFirmware(def->os.firmware);
clang isn't happy with this as its passing the wrong enum
../../src/qemu/qemu_firmware.c:964:77: error: implicit conversion from enumeration type
'virDomainLoader' to different enumeration type 'virDomainOsDefFirmware'
[-Werror,-Wenum-conversion]
want = qemuFirmwareOSInterfaceTypeFromOsDefFirmware(def->os.loader->type);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~^~~~
Regards,
Daniel
--
|:
https://berrange.com -o-
https://www.flickr.com/photos/dberrange :|
|:
https://libvirt.org -o-
https://fstop138.berrange.com :|
|:
https://entangle-photo.org -o-
https://www.instagram.com/dberrange :|