[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [libvirt-glib 12/37] Add more GVirConfigOs setters



---
 libvirt-gconfig/libvirt-gconfig-os.c |   85 ++++++++++++++++++++++++++++++++++
 libvirt-gconfig/libvirt-gconfig-os.h |   19 ++++++++
 libvirt-gconfig/libvirt-gconfig.sym  |    8 +++
 3 files changed, 112 insertions(+), 0 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-os.c b/libvirt-gconfig/libvirt-gconfig-os.c
index d4a04ae..cfe827e 100644
--- a/libvirt-gconfig/libvirt-gconfig-os.c
+++ b/libvirt-gconfig/libvirt-gconfig-os.c
@@ -92,3 +92,88 @@ void gvir_config_os_set_os_type(GVirConfigOs *os, GVirConfigOsType type)
     if (type_str != NULL)
         xmlNodeSetContent(node, (xmlChar*)type_str);
 }
+
+void gvir_config_os_set_loader(GVirConfigOs *os, const char * loader)
+{
+    gvir_config_object_set_node_content(GVIR_CONFIG_OBJECT(os),
+                                        "loader", loader);
+}
+
+void gvir_config_os_enable_boot_menu(GVirConfigOs *os, gboolean enable)
+{
+    xmlNodePtr node;
+
+    node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(os), "bootmenu");
+    if (node == NULL)
+        return;
+    if (enable)
+        xmlNewProp(node, (xmlChar*)"enable", (xmlChar*)"yes");
+    else
+        xmlNewProp(node, (xmlChar*)"enable", (xmlChar*)"no");
+}
+
+void gvir_config_os_bios_enable_serial(GVirConfigOs *os, gboolean enable)
+{
+    xmlNodePtr node;
+
+    node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(os), "bios");
+    if (node == NULL)
+        return;
+    if (enable)
+        xmlNewProp(node, (xmlChar*)"useserial", (xmlChar*)"yes");
+    else
+        xmlNewProp(node, (xmlChar*)"useserial", (xmlChar*)"no");
+}
+
+void gvir_config_os_set_smbios_mode(GVirConfigOs *os,
+                                    GVirConfigOsSmBiosMode mode)
+{
+    xmlNodePtr node;
+    const char *mode_str;
+
+    node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(os), "smbios");
+    if (node == NULL)
+        return;
+    mode_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_OS_SM_BIOS_MODE,
+                                          mode);
+    if (mode_str != NULL)
+        xmlNewProp(node, (xmlChar*)"mode", (xmlChar*)mode_str);
+}
+
+/**
+ * gvir_config_os_set_boot_devices:
+ * @boot_devices: (in) (element-type LibvirtGConfig.OsBootDevice):
+ */
+void gvir_config_os_set_boot_devices(GVirConfigOs *os, GList *boot_devices)
+{
+    GList *it;
+    xmlNodePtr os_node;
+    xmlNodePtr node;
+
+    os_node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(os));
+    if (os_node == NULL)
+        return;
+
+    node = os_node->children;
+    while (node != NULL) {
+        xmlNodePtr next_node;
+        next_node = node->next;
+        if (strcmp("boot", (char *)node->name) == 0) {
+            xmlUnlinkNode(node);
+            xmlFreeNode(node);
+        }
+        node = next_node;
+    }
+
+    for (it = boot_devices; it != NULL; it = it->next) {
+        const char *dev;
+
+        dev = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_OS_BOOT_DEVICE,
+                                         GPOINTER_TO_INT(it->data));
+        if (dev != NULL) {
+            node = xmlNewDocNode(NULL, NULL, (xmlChar*)"boot", NULL);
+            xmlNewProp(node, (xmlChar*)"dev", (xmlChar*)dev);
+            xmlAddChild(os_node, node);
+        }
+    }
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-os.h b/libvirt-gconfig/libvirt-gconfig-os.h
index c6498ad..87027da 100644
--- a/libvirt-gconfig/libvirt-gconfig-os.h
+++ b/libvirt-gconfig/libvirt-gconfig-os.h
@@ -61,12 +61,31 @@ typedef enum {
     GVIR_CONFIG_OS_TYPE_LINUX
 } GVirConfigOsType;
 
+typedef enum {
+    GVIR_CONFIG_OS_SMBIOS_MODE_EMULATE,
+    GVIR_CONFIG_OS_SMBIOS_MODE_HOST,
+    GVIR_CONFIG_OS_SMBIOS_MODE_SYSINFO
+} GVirConfigOsSmBiosMode;
+
+typedef enum {
+    GVIR_CONFIG_OS_BOOT_DEVICE_FD,
+    GVIR_CONFIG_OS_BOOT_DEVICE_HD,
+    GVIR_CONFIG_OS_BOOT_DEVICE_CDROM,
+    GVIR_CONFIG_OS_BOOT_DEVICE_NETWORK
+} GVirConfigOsBootDevice;
+
 GType gvir_config_os_get_type(void);
 
 GVirConfigOs *gvir_config_os_new(void);
 GVirConfigOs *gvir_config_os_new_from_xml(const gchar *xml, GError **error);
 
 void gvir_config_os_set_os_type(GVirConfigOs *os, GVirConfigOsType type);
+void gvir_config_os_set_boot_devices(GVirConfigOs *os, GList *boot_devices);
+void gvir_config_os_set_loader(GVirConfigOs *os, const char * loader);
+void gvir_config_os_set_smbios_mode(GVirConfigOs *os,
+                                    GVirConfigOsSmBiosMode mode);
+void gvir_config_os_enable_boot_menu(GVirConfigOs *os, gboolean enable);
+void gvir_config_os_bios_enable_serial(GVirConfigOs *os, gboolean enable);
 
 G_END_DECLS
 
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index 176a2e2..3466129 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -52,9 +52,17 @@ LIBVIRT_GOBJECT_0.0.1 {
 	gvir_config_object_validate;
 
 	gvir_config_os_get_type;
+	gvir_config_os_boot_device_get_type;
+	gvir_config_os_sm_bios_mode_get_type;
 	gvir_config_os_type_get_type;
 	gvir_config_os_new;
 	gvir_config_os_new_from_xml;
+	gvir_config_os_set_os_type;
+	gvir_config_os_set_boot_devices;
+	gvir_config_os_set_loader;
+	gvir_config_os_set_smbios_mode;
+	gvir_config_os_enable_boot_menu;
+	gvir_config_os_bios_enable_serial;
 
 	gvir_config_secret_get_type;
 	gvir_config_secret_new;
-- 
1.7.7


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]