On 5/10/19 9:12 PM, Fabiano FidĂȘncio wrote:
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);
I'd rather return an error here. If enum -> str conversion went wrong,
then we shouldn't proceed, even though looking at the current
implementation of xmlNewProp it's a NO-OP if attribute's value is NULL.
+
+ xmlNewProp(node, (xmlChar*)"firmware", (xmlChar*)firmware_str);
+}
Michal