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(a)redhat.com>
---
src/bhyve/bhyve_driver.c | 3 +--
src/conf/domain_conf.c | 16 ++++++++++++++++
src/conf/domain_conf.h | 6 ++++++
src/libvirt_private.syms | 2 ++
src/libxl/libxl_conf.c | 3 +--
src/libxl/xen_xl.c | 8 +++-----
src/qemu/qemu_domain.c | 14 ++++----------
src/qemu/qemu_driver.c | 3 +--
8 files changed, 34 insertions(+), 21 deletions(-)
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index a764b4d4ed..5b8fba7467 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -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;
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ee33b7caf0..64d7af9e3c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -31510,6 +31510,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
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index e012975fca..e6b06a8eba 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -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);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 9185e49fda..ec1054cdc3 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -311,6 +311,8 @@ virDomainDefHasMdevHostdev;
virDomainDefHasMemballoon;
virDomainDefHasMemoryHotplug;
virDomainDefHasNVMeDisk;
+virDomainDefHasOldStyleROUEFI;
+virDomainDefHasOldStyleUEFI;
virDomainDefHasUSB;
virDomainDefHasVcpusOffline;
virDomainDefHasVFIOHostdev;
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 1be2a789d5..2488bb9d32 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -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) {
diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c
index ebcea41d1c..91b1825399 100644
--- a/src/libxl/xen_xl.c
+++ b/src/libxl/xen_xl.c
@@ -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)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 065c9e97a9..788caf864c 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -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()))
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ae54c00239..34d1374d87 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -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"));
--
2.24.1