[libvirt-glib 4/4] Add gvir_config_domain_os_get_boot_devices()

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

 



From: "Zeeshan Ali (Khattak)" <zeeshanak@xxxxxxxxx>

---
 libvirt-gconfig/libvirt-gconfig-domain-os.c |   44 +++++++++++++++++++++++++++
 libvirt-gconfig/libvirt-gconfig-domain-os.h |    1 +
 libvirt-gconfig/libvirt-gconfig.sym         |    1 +
 3 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-domain-os.c b/libvirt-gconfig/libvirt-gconfig-domain-os.c
index 74cdd4d..f1a75dd 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-os.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-os.c
@@ -221,6 +221,50 @@ void gvir_config_domain_os_set_boot_devices(GVirConfigDomainOs *os, GList *boot_
     }
 }
 
+static gboolean add_boot_device(xmlNodePtr node, gpointer opaque)
+{
+    GList **devices = (GList **)opaque;
+    GVirConfigDomainOsBootDevice device;
+    const gchar *value;
+
+    if (g_strcmp0((const gchar *)node->name, "boot") != 0)
+        return TRUE;
+
+    value = gvir_config_xml_get_attribute_content(node, "dev");
+    if (value != NULL) {
+        device = gvir_config_genum_get_value
+                        (GVIR_CONFIG_TYPE_DOMAIN_OS_BOOT_DEVICE,
+                         value,
+                         GVIR_CONFIG_DOMAIN_OS_BOOT_DEVICE_HD);
+        *devices = g_list_append(*devices, GINT_TO_POINTER(device));
+    } else
+        g_debug("Failed to parse attribute 'dev' of node 'boot'");
+
+    return TRUE;
+}
+
+/**
+ * gvir_config_domain_os_get_boot_devices:
+ *
+ * Gets the list of devices attached to @os
+ *
+ * Returns: (element-type LibvirtGConfig.DomainOsBootDevice) (transfer full):
+ * a newly allocated #GList of #GVirConfigDomainOsBootDevice.
+ */
+GList *gvir_config_domain_os_get_boot_devices(GVirConfigDomainOs *os)
+{
+    GList *devices = NULL;
+
+    g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_OS(os), NULL);
+
+    gvir_config_object_foreach_child(GVIR_CONFIG_OBJECT(os),
+                                     "devices",
+                                     add_boot_device,
+                                     &devices);
+
+    return devices;
+}
+
 void gvir_config_domain_os_set_arch(GVirConfigDomainOs *os, const char *arch)
 {
     xmlNodePtr os_node;
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-os.h b/libvirt-gconfig/libvirt-gconfig-domain-os.h
index 55a162b..44b8bdd 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-os.h
+++ b/libvirt-gconfig/libvirt-gconfig-domain-os.h
@@ -82,6 +82,7 @@ GVirConfigDomainOs *gvir_config_domain_os_new_from_xml(const gchar *xml, GError
 
 void gvir_config_domain_os_set_os_type(GVirConfigDomainOs *os, GVirConfigDomainOsType type);
 void gvir_config_domain_os_set_arch(GVirConfigDomainOs *os, const char *arch);
+GList *gvir_config_domain_os_get_boot_devices(GVirConfigDomainOs *os);
 void gvir_config_domain_os_set_boot_devices(GVirConfigDomainOs *os, GList *boot_devices);
 void gvir_config_domain_os_set_kernel(GVirConfigDomainOs *os, const char *kernel);
 void gvir_config_domain_os_set_ramdisk(GVirConfigDomainOs *os, const char *ramdisk);
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index 67e9c3f..7bc9e2d 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -377,6 +377,7 @@ LIBVIRT_GCONFIG_0.0.8 {
 LIBVIRT_GCONFIG_0.0.9 {
   global:
 	gvir_config_domain_get_os;
+	gvir_config_domain_os_get_boot_devices;
 } LIBVIRT_GCONFIG_0.0.8;
 
 # .... define new API here using predicted next version number ....
-- 
1.7.7.6

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]