mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
src: Introduce and use virDomainDefHasOldStyleUEFI() and virDomainDefHasOldStyleROUEFI()
These functions are meant to replace verbose check for the old style of specifying UEFI with a simple function call. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
57f9067ca3
commit
7c5264d2be
@ -704,8 +704,7 @@ bhyveConnectDomainXMLToNative(virConnectPtr conn,
|
||||
if (def->os.bootloader == NULL &&
|
||||
def->os.loader) {
|
||||
|
||||
if ((def->os.loader->readonly != VIR_TRISTATE_BOOL_YES) ||
|
||||
(def->os.loader->type != VIR_DOMAIN_LOADER_TYPE_PFLASH)) {
|
||||
if (!virDomainDefHasOldStyleROUEFI(def)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("Only read-only pflash is supported."));
|
||||
goto cleanup;
|
||||
|
@ -31526,6 +31526,22 @@ virDomainDefHasMdevHostdev(const virDomainDef *def)
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
virDomainDefHasOldStyleUEFI(const virDomainDef *def)
|
||||
{
|
||||
return def->os.loader &&
|
||||
def->os.loader->type == VIR_DOMAIN_LOADER_TYPE_PFLASH;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
virDomainDefHasOldStyleROUEFI(const virDomainDef *def)
|
||||
{
|
||||
return virDomainDefHasOldStyleUEFI(def) &&
|
||||
def->os.loader->readonly == VIR_TRISTATE_BOOL_YES;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virDomainGraphicsDefHasOpenGL:
|
||||
* @def: domain definition
|
||||
|
@ -3673,6 +3673,12 @@ virDomainDefHasVFIOHostdev(const virDomainDef *def);
|
||||
bool
|
||||
virDomainDefHasMdevHostdev(const virDomainDef *def);
|
||||
|
||||
bool
|
||||
virDomainDefHasOldStyleUEFI(const virDomainDef *def);
|
||||
|
||||
bool
|
||||
virDomainDefHasOldStyleROUEFI(const virDomainDef *def);
|
||||
|
||||
bool
|
||||
virDomainGraphicsDefHasOpenGL(const virDomainDef *def);
|
||||
|
||||
|
@ -311,6 +311,8 @@ virDomainDefHasMdevHostdev;
|
||||
virDomainDefHasMemballoon;
|
||||
virDomainDefHasMemoryHotplug;
|
||||
virDomainDefHasNVMeDisk;
|
||||
virDomainDefHasOldStyleROUEFI;
|
||||
virDomainDefHasOldStyleUEFI;
|
||||
virDomainDefHasUSB;
|
||||
virDomainDefHasVcpusOffline;
|
||||
virDomainDefHasVFIOHostdev;
|
||||
|
@ -545,8 +545,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
|
||||
* future, Xen will support a user-specified firmware path. See
|
||||
* http://lists.xenproject.org/archives/html/xen-devel/2016-03/msg01628.html
|
||||
*/
|
||||
if (def->os.loader &&
|
||||
def->os.loader->type == VIR_DOMAIN_LOADER_TYPE_PFLASH)
|
||||
if (virDomainDefHasOldStyleUEFI(def))
|
||||
b_info->u.hvm.bios = LIBXL_BIOS_TYPE_OVMF;
|
||||
|
||||
if (def->emulator) {
|
||||
|
@ -1228,11 +1228,9 @@ xenFormatXLOS(virConfPtr conf, virDomainDefPtr def)
|
||||
if (xenConfigSetString(conf, "builder", "hvm") < 0)
|
||||
return -1;
|
||||
|
||||
if (def->os.loader &&
|
||||
def->os.loader->type == VIR_DOMAIN_LOADER_TYPE_PFLASH) {
|
||||
if (xenConfigSetString(conf, "bios", "ovmf") < 0)
|
||||
return -1;
|
||||
}
|
||||
if (virDomainDefHasOldStyleUEFI(def) &&
|
||||
xenConfigSetString(conf, "bios", "ovmf") < 0)
|
||||
return -1;
|
||||
|
||||
if (def->os.slic_table &&
|
||||
xenConfigSetString(conf, "acpi_firmware", def->os.slic_table) < 0)
|
||||
|
@ -5697,8 +5697,7 @@ qemuDomainDefValidate(const virDomainDef *def,
|
||||
|
||||
/* On x86, UEFI requires ACPI */
|
||||
if ((def->os.firmware == VIR_DOMAIN_OS_DEF_FIRMWARE_EFI ||
|
||||
(def->os.loader &&
|
||||
def->os.loader->type == VIR_DOMAIN_LOADER_TYPE_PFLASH)) &&
|
||||
virDomainDefHasOldStyleUEFI(def)) &&
|
||||
ARCH_IS_X86(def->os.arch) &&
|
||||
def->features[VIR_DOMAIN_FEATURE_ACPI] != VIR_TRISTATE_SWITCH_ON) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
@ -5710,8 +5709,7 @@ qemuDomainDefValidate(const virDomainDef *def,
|
||||
if (def->features[VIR_DOMAIN_FEATURE_ACPI] == VIR_TRISTATE_SWITCH_ON &&
|
||||
def->os.arch == VIR_ARCH_AARCH64 &&
|
||||
(def->os.firmware != VIR_DOMAIN_OS_DEF_FIRMWARE_EFI &&
|
||||
(!def->os.loader ||
|
||||
def->os.loader->type != VIR_DOMAIN_LOADER_TYPE_PFLASH))) {
|
||||
!virDomainDefHasOldStyleUEFI(def))) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("ACPI requires UEFI on this architecture"));
|
||||
goto cleanup;
|
||||
@ -16608,12 +16606,9 @@ void
|
||||
qemuDomainNVRAMPathGenerate(virQEMUDriverConfigPtr cfg,
|
||||
virDomainDefPtr def)
|
||||
{
|
||||
if (def->os.loader &&
|
||||
def->os.loader->type == VIR_DOMAIN_LOADER_TYPE_PFLASH &&
|
||||
def->os.loader->readonly == VIR_TRISTATE_BOOL_YES &&
|
||||
if (virDomainDefHasOldStyleROUEFI(def) &&
|
||||
!def->os.loader->nvram)
|
||||
qemuDomainNVRAMPathFormat(cfg, def, &def->os.loader->nvram);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -16740,8 +16735,7 @@ qemuDomainInitializePflashStorageSource(virDomainObjPtr vm)
|
||||
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV))
|
||||
return 0;
|
||||
|
||||
if (!def->os.loader ||
|
||||
def->os.loader->type != VIR_DOMAIN_LOADER_TYPE_PFLASH)
|
||||
if (!virDomainDefHasOldStyleUEFI(def))
|
||||
return 0;
|
||||
|
||||
if (!(pflash0 = virStorageSourceNew()))
|
||||
|
@ -15218,8 +15218,7 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
|
||||
* Avoid the issues by forbidding internal snapshot with pflash completely.
|
||||
*/
|
||||
if (found_internal &&
|
||||
vm->def->os.loader &&
|
||||
vm->def->os.loader->type == VIR_DOMAIN_LOADER_TYPE_PFLASH) {
|
||||
virDomainDefHasOldStyleUEFI(vm->def)) {
|
||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
||||
_("internal snapshots of a VM with pflash based "
|
||||
"firmware are not supported"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user