mirror of https://gitee.com/openkylin/libvirt.git
qemu: split handling of distinct firmware enum conversions
The qemuFirmwareOSInterfaceTypeFromOsDefFirmware method was added to convert from virDomainOsDefFirmware to the qemuFirmwareOSInterface enum. It was later also used to convert from virDomainLoader to qemuFirmwareOSInterface in: commit8e1804f9f6
Author: Michal Prívozník <mprivozn@redhat.com> Date: Tue Dec 17 17:45:50 2019 +0100 qemu_firmware: Try to autofill for old style UEFI specification This caused compile errors with clang due to passing a mis-matched enum type. These were later silenced by stripping the enum types: commit8fcee47807
Author: Michal Prívozník <mprivozn@redhat.com> Date: Wed Jan 8 09:42:47 2020 +0100 qemu_firmware: Accept int in qemuFirmwareOSInterfaceTypeFromOsDefFirmware() This is still rather confusing to humans reading the code. It is clearer to just define a separate helper method for the virDomainLoader type conversion. Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
4bb150ed3a
commit
c723a98618
|
@ -2298,8 +2298,8 @@ struct _virDomainOSEnv {
|
|||
|
||||
typedef enum {
|
||||
VIR_DOMAIN_OS_DEF_FIRMWARE_NONE = 0,
|
||||
VIR_DOMAIN_OS_DEF_FIRMWARE_BIOS = VIR_DOMAIN_LOADER_TYPE_ROM,
|
||||
VIR_DOMAIN_OS_DEF_FIRMWARE_EFI = VIR_DOMAIN_LOADER_TYPE_PFLASH,
|
||||
VIR_DOMAIN_OS_DEF_FIRMWARE_BIOS,
|
||||
VIR_DOMAIN_OS_DEF_FIRMWARE_EFI,
|
||||
|
||||
VIR_DOMAIN_OS_DEF_FIRMWARE_LAST
|
||||
} virDomainOsDefFirmware;
|
||||
|
|
|
@ -899,7 +899,7 @@ qemuFirmwareMatchesMachineArch(const qemuFirmware *fw,
|
|||
|
||||
|
||||
static qemuFirmwareOSInterface
|
||||
qemuFirmwareOSInterfaceTypeFromOsDefFirmware(int fw)
|
||||
qemuFirmwareOSInterfaceTypeFromOsDefFirmware(virDomainOsDefFirmware fw)
|
||||
{
|
||||
switch (fw) {
|
||||
case VIR_DOMAIN_OS_DEF_FIRMWARE_BIOS:
|
||||
|
@ -915,6 +915,23 @@ qemuFirmwareOSInterfaceTypeFromOsDefFirmware(int fw)
|
|||
}
|
||||
|
||||
|
||||
static qemuFirmwareOSInterface
|
||||
qemuFirmwareOSInterfaceTypeFromOsDefLoaderType(virDomainLoader type)
|
||||
{
|
||||
switch (type) {
|
||||
case VIR_DOMAIN_LOADER_TYPE_ROM:
|
||||
return QEMU_FIRMWARE_OS_INTERFACE_BIOS;
|
||||
case VIR_DOMAIN_LOADER_TYPE_PFLASH:
|
||||
return QEMU_FIRMWARE_OS_INTERFACE_UEFI;
|
||||
case VIR_DOMAIN_LOADER_TYPE_NONE:
|
||||
case VIR_DOMAIN_LOADER_TYPE_LAST:
|
||||
break;
|
||||
}
|
||||
|
||||
return QEMU_FIRMWARE_OS_INTERFACE_NONE;
|
||||
}
|
||||
|
||||
|
||||
#define VIR_QEMU_FIRMWARE_AMD_SEV_ES_POLICY (1 << 2)
|
||||
|
||||
|
||||
|
@ -939,7 +956,7 @@ qemuFirmwareMatchDomain(const virDomainDef *def,
|
|||
|
||||
if (want == QEMU_FIRMWARE_OS_INTERFACE_NONE &&
|
||||
def->os.loader) {
|
||||
want = qemuFirmwareOSInterfaceTypeFromOsDefFirmware(def->os.loader->type);
|
||||
want = qemuFirmwareOSInterfaceTypeFromOsDefLoaderType(def->os.loader->type);
|
||||
|
||||
if (fw->mapping.device != QEMU_FIRMWARE_DEVICE_FLASH ||
|
||||
STRNEQ(def->os.loader->path, fw->mapping.data.flash.executable.filename)) {
|
||||
|
|
Loading…
Reference in New Issue