Add a way to set <os firmware="bios|efi"/> to the domain XML.
Signed-off-by: Fabiano FidĂȘncio <fidencio(a)redhat.com>
---
libvirt-gconfig/libvirt-gconfig-domain-os.c | 17 +++++++++++++++++
libvirt-gconfig/libvirt-gconfig-domain-os.h | 7 +++++++
libvirt-gconfig/libvirt-gconfig.sym | 2 ++
tests/test-gconfig.c | 1 +
tests/xml/gconfig-domain-os.xml | 2 +-
5 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-os.c
b/libvirt-gconfig/libvirt-gconfig-domain-os.c
index ecbf5b3..62c3441 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-os.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-os.c
@@ -328,3 +328,20 @@ void gvir_config_domain_os_set_machine(GVirConfigDomainOs *os, const
char *machi
xmlNewProp(os_type_node, (xmlChar*)"machine", (xmlChar*)machine);
}
+
+void gvir_config_domain_os_set_firmware(GVirConfigDomainOs *os,
GVirConfigDomainOsFirmware firmware)
+{
+ xmlNodePtr node;
+ const gchar *firmware_str;
+
+ g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_OS(os));
+
+ node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(os));
+ g_return_if_fail(node != NULL);
+
+ firmware_str = gvir_config_genum_get_nick(GVIR_CONFIG_TYPE_DOMAIN_OS_FIRMWARE,
+ firmware);
+ g_warn_if_fail(firmware_str != NULL);
+
+ xmlNewProp(node, (xmlChar*)"firmware", (xmlChar*)firmware_str);
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-os.h
b/libvirt-gconfig/libvirt-gconfig-domain-os.h
index fe17dd4..2a8fc13 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-os.h
+++ b/libvirt-gconfig/libvirt-gconfig-domain-os.h
@@ -77,6 +77,11 @@ typedef enum {
GVIR_CONFIG_DOMAIN_OS_BOOT_DEVICE_NETWORK
} GVirConfigDomainOsBootDevice;
+typedef enum {
+ GVIR_CONFIG_DOMAIN_OS_FIRMWARE_BIOS,
+ GVIR_CONFIG_DOMAIN_OS_FIRMWARE_EFI
+} GVirConfigDomainOsFirmware;
+
GType gvir_config_domain_os_get_type(void);
GVirConfigDomainOs *gvir_config_domain_os_new(void);
@@ -99,6 +104,8 @@ void gvir_config_domain_os_set_smbios_mode(GVirConfigDomainOs *os,
GVirConfigDomainOsSmBiosMode mode);
void gvir_config_domain_os_enable_boot_menu(GVirConfigDomainOs *os, gboolean enable);
void gvir_config_domain_os_bios_enable_serial(GVirConfigDomainOs *os, gboolean enable);
+void gvir_config_domain_os_set_firmware(GVirConfigDomainOs *os,
+ GVirConfigDomainOsFirmware firmware);
G_END_DECLS
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index 885e708..746fd1a 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -774,6 +774,8 @@ global:
LIBVIRT_GCONFIG_2.0.1 {
global:
+ gvir_config_domain_os_firmware_get_type;
+ gvir_config_domain_os_set_firmware;
gvir_config_storage_vol_target_features_get_type;
gvir_config_storage_vol_target_set_features;
} LIBVIRT_GCONFIG_2.0.0;
diff --git a/tests/test-gconfig.c b/tests/test-gconfig.c
index 3328297..fda4fcb 100644
--- a/tests/test-gconfig.c
+++ b/tests/test-gconfig.c
@@ -215,6 +215,7 @@ static void test_domain_os(void)
gvir_config_domain_os_set_os_type(os, GVIR_CONFIG_DOMAIN_OS_TYPE_HVM);
gvir_config_domain_os_set_arch(os, "x86_64");
gvir_config_domain_os_set_machine(os, "q35");
+ gvir_config_domain_os_set_firmware(os, GVIR_CONFIG_DOMAIN_OS_FIRMWARE_EFI);
g_assert_cmpint(gvir_config_domain_os_get_os_type(os), ==,
GVIR_CONFIG_DOMAIN_OS_TYPE_HVM);
g_assert_cmpstr(gvir_config_domain_os_get_arch(os), ==, "x86_64");
g_assert_cmpstr(gvir_config_domain_os_get_machine(os), ==, "q35");
diff --git a/tests/xml/gconfig-domain-os.xml b/tests/xml/gconfig-domain-os.xml
index 56af776..690024d 100644
--- a/tests/xml/gconfig-domain-os.xml
+++ b/tests/xml/gconfig-domain-os.xml
@@ -1,5 +1,5 @@
<domain>
- <os>
+ <os firmware="efi">
<type arch="x86_64" machine="q35">hvm</type>
<boot dev="cdrom"/>
<boot dev="network"/>
--
2.21.0