mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06: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 &&
|
if (def->os.bootloader == NULL &&
|
||||||
def->os.loader) {
|
def->os.loader) {
|
||||||
|
|
||||||
if ((def->os.loader->readonly != VIR_TRISTATE_BOOL_YES) ||
|
if (!virDomainDefHasOldStyleROUEFI(def)) {
|
||||||
(def->os.loader->type != VIR_DOMAIN_LOADER_TYPE_PFLASH)) {
|
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("Only read-only pflash is supported."));
|
_("Only read-only pflash is supported."));
|
||||||
goto cleanup;
|
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:
|
* virDomainGraphicsDefHasOpenGL:
|
||||||
* @def: domain definition
|
* @def: domain definition
|
||||||
|
@ -3673,6 +3673,12 @@ virDomainDefHasVFIOHostdev(const virDomainDef *def);
|
|||||||
bool
|
bool
|
||||||
virDomainDefHasMdevHostdev(const virDomainDef *def);
|
virDomainDefHasMdevHostdev(const virDomainDef *def);
|
||||||
|
|
||||||
|
bool
|
||||||
|
virDomainDefHasOldStyleUEFI(const virDomainDef *def);
|
||||||
|
|
||||||
|
bool
|
||||||
|
virDomainDefHasOldStyleROUEFI(const virDomainDef *def);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
virDomainGraphicsDefHasOpenGL(const virDomainDef *def);
|
virDomainGraphicsDefHasOpenGL(const virDomainDef *def);
|
||||||
|
|
||||||
|
@ -311,6 +311,8 @@ virDomainDefHasMdevHostdev;
|
|||||||
virDomainDefHasMemballoon;
|
virDomainDefHasMemballoon;
|
||||||
virDomainDefHasMemoryHotplug;
|
virDomainDefHasMemoryHotplug;
|
||||||
virDomainDefHasNVMeDisk;
|
virDomainDefHasNVMeDisk;
|
||||||
|
virDomainDefHasOldStyleROUEFI;
|
||||||
|
virDomainDefHasOldStyleUEFI;
|
||||||
virDomainDefHasUSB;
|
virDomainDefHasUSB;
|
||||||
virDomainDefHasVcpusOffline;
|
virDomainDefHasVcpusOffline;
|
||||||
virDomainDefHasVFIOHostdev;
|
virDomainDefHasVFIOHostdev;
|
||||||
|
@ -545,8 +545,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
|
|||||||
* future, Xen will support a user-specified firmware path. See
|
* future, Xen will support a user-specified firmware path. See
|
||||||
* http://lists.xenproject.org/archives/html/xen-devel/2016-03/msg01628.html
|
* http://lists.xenproject.org/archives/html/xen-devel/2016-03/msg01628.html
|
||||||
*/
|
*/
|
||||||
if (def->os.loader &&
|
if (virDomainDefHasOldStyleUEFI(def))
|
||||||
def->os.loader->type == VIR_DOMAIN_LOADER_TYPE_PFLASH)
|
|
||||||
b_info->u.hvm.bios = LIBXL_BIOS_TYPE_OVMF;
|
b_info->u.hvm.bios = LIBXL_BIOS_TYPE_OVMF;
|
||||||
|
|
||||||
if (def->emulator) {
|
if (def->emulator) {
|
||||||
|
@ -1228,11 +1228,9 @@ xenFormatXLOS(virConfPtr conf, virDomainDefPtr def)
|
|||||||
if (xenConfigSetString(conf, "builder", "hvm") < 0)
|
if (xenConfigSetString(conf, "builder", "hvm") < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (def->os.loader &&
|
if (virDomainDefHasOldStyleUEFI(def) &&
|
||||||
def->os.loader->type == VIR_DOMAIN_LOADER_TYPE_PFLASH) {
|
xenConfigSetString(conf, "bios", "ovmf") < 0)
|
||||||
if (xenConfigSetString(conf, "bios", "ovmf") < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
if (def->os.slic_table &&
|
if (def->os.slic_table &&
|
||||||
xenConfigSetString(conf, "acpi_firmware", def->os.slic_table) < 0)
|
xenConfigSetString(conf, "acpi_firmware", def->os.slic_table) < 0)
|
||||||
|
@ -5697,8 +5697,7 @@ qemuDomainDefValidate(const virDomainDef *def,
|
|||||||
|
|
||||||
/* On x86, UEFI requires ACPI */
|
/* On x86, UEFI requires ACPI */
|
||||||
if ((def->os.firmware == VIR_DOMAIN_OS_DEF_FIRMWARE_EFI ||
|
if ((def->os.firmware == VIR_DOMAIN_OS_DEF_FIRMWARE_EFI ||
|
||||||
(def->os.loader &&
|
virDomainDefHasOldStyleUEFI(def)) &&
|
||||||
def->os.loader->type == VIR_DOMAIN_LOADER_TYPE_PFLASH)) &&
|
|
||||||
ARCH_IS_X86(def->os.arch) &&
|
ARCH_IS_X86(def->os.arch) &&
|
||||||
def->features[VIR_DOMAIN_FEATURE_ACPI] != VIR_TRISTATE_SWITCH_ON) {
|
def->features[VIR_DOMAIN_FEATURE_ACPI] != VIR_TRISTATE_SWITCH_ON) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
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 &&
|
if (def->features[VIR_DOMAIN_FEATURE_ACPI] == VIR_TRISTATE_SWITCH_ON &&
|
||||||
def->os.arch == VIR_ARCH_AARCH64 &&
|
def->os.arch == VIR_ARCH_AARCH64 &&
|
||||||
(def->os.firmware != VIR_DOMAIN_OS_DEF_FIRMWARE_EFI &&
|
(def->os.firmware != VIR_DOMAIN_OS_DEF_FIRMWARE_EFI &&
|
||||||
(!def->os.loader ||
|
!virDomainDefHasOldStyleUEFI(def))) {
|
||||||
def->os.loader->type != VIR_DOMAIN_LOADER_TYPE_PFLASH))) {
|
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("ACPI requires UEFI on this architecture"));
|
_("ACPI requires UEFI on this architecture"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -16608,12 +16606,9 @@ void
|
|||||||
qemuDomainNVRAMPathGenerate(virQEMUDriverConfigPtr cfg,
|
qemuDomainNVRAMPathGenerate(virQEMUDriverConfigPtr cfg,
|
||||||
virDomainDefPtr def)
|
virDomainDefPtr def)
|
||||||
{
|
{
|
||||||
if (def->os.loader &&
|
if (virDomainDefHasOldStyleROUEFI(def) &&
|
||||||
def->os.loader->type == VIR_DOMAIN_LOADER_TYPE_PFLASH &&
|
|
||||||
def->os.loader->readonly == VIR_TRISTATE_BOOL_YES &&
|
|
||||||
!def->os.loader->nvram)
|
!def->os.loader->nvram)
|
||||||
qemuDomainNVRAMPathFormat(cfg, 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))
|
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!def->os.loader ||
|
if (!virDomainDefHasOldStyleUEFI(def))
|
||||||
def->os.loader->type != VIR_DOMAIN_LOADER_TYPE_PFLASH)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!(pflash0 = virStorageSourceNew()))
|
if (!(pflash0 = virStorageSourceNew()))
|
||||||
|
@ -15218,8 +15218,7 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
|
|||||||
* Avoid the issues by forbidding internal snapshot with pflash completely.
|
* Avoid the issues by forbidding internal snapshot with pflash completely.
|
||||||
*/
|
*/
|
||||||
if (found_internal &&
|
if (found_internal &&
|
||||||
vm->def->os.loader &&
|
virDomainDefHasOldStyleUEFI(vm->def)) {
|
||||||
vm->def->os.loader->type == VIR_DOMAIN_LOADER_TYPE_PFLASH) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
||||||
_("internal snapshots of a VM with pflash based "
|
_("internal snapshots of a VM with pflash based "
|
||||||
"firmware are not supported"));
|
"firmware are not supported"));
|
||||||
|
Loading…
Reference in New Issue
Block a user