[virt-tools-list] [libosinfo 2/2] Add API to fetch paths to kernel and initrd images

Zeeshan Ali (Khattak) zeeshanak at gnome.org
Mon Oct 17 14:18:53 UTC 2011


From: "Zeeshan Ali (Khattak)" <zeeshanak at gnome.org>

---
 docs/reference/Libosinfo-sections.txt |    2 ++
 osinfo/libosinfo.syms                 |    2 ++
 osinfo/osinfo_loader.c                |    6 +++++-
 osinfo/osinfo_media.c                 |   32 ++++++++++++++++++++++++++++++++
 osinfo/osinfo_media.h                 |    4 ++++
 5 files changed, 45 insertions(+), 1 deletions(-)

diff --git a/docs/reference/Libosinfo-sections.txt b/docs/reference/Libosinfo-sections.txt
index 70423c9..ad08dd2 100644
--- a/docs/reference/Libosinfo-sections.txt
+++ b/docs/reference/Libosinfo-sections.txt
@@ -415,6 +415,8 @@ osinfo_media_get_url
 osinfo_media_get_volume_id
 osinfo_media_get_system_id
 osinfo_media_get_publisher_id
+osinfo_media_get_kernel_path
+osinfo_media_get_initrd_path
 <SUBSECTION Standard>
 OSINFO_MEDIA
 OSINFO_IS_MEDIA
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index dfed3ff..5b4113e 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -155,6 +155,8 @@ LIBOSINFO_0.0.1 {
 	osinfo_media_get_volume_id;
 	osinfo_media_get_system_id;
 	osinfo_media_get_publisher_id;
+        osinfo_media_get_kernel_path;
+        osinfo_media_get_initrd_path;
 	osinfo_medialist_get_type;
 	osinfo_medialist_new;
 	osinfo_medialist_new_copy;
diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
index 4c32a90..6031cde 100644
--- a/osinfo/osinfo_loader.c
+++ b/osinfo/osinfo_loader.c
@@ -510,7 +510,11 @@ static OsinfoMedia *osinfo_loader_media (OsinfoLoader *loader,
              strcmp((const gchar *)nodes[i]->name,
                     OSINFO_MEDIA_PROP_SYSTEM_ID) != 0 &&
              strcmp((const gchar *)nodes[i]->name,
-                    OSINFO_MEDIA_PROP_PUBLISHER_ID) != 0))
+                    OSINFO_MEDIA_PROP_PUBLISHER_ID) != 0 &&
+             strcmp((const gchar *)nodes[i]->name,
+                    OSINFO_MEDIA_PROP_KERNEL) != 0 &&
+             strcmp((const gchar *)nodes[i]->name,
+                    OSINFO_MEDIA_PROP_INITRD) != 0))
             continue;
 
         osinfo_entity_set_param(OSINFO_ENTITY(media),
diff --git a/osinfo/osinfo_media.c b/osinfo/osinfo_media.c
index a509a7b..6c98ba7 100644
--- a/osinfo/osinfo_media.c
+++ b/osinfo/osinfo_media.c
@@ -545,6 +545,38 @@ const gchar *osinfo_media_get_publisher_id(OsinfoMedia *media)
                                          OSINFO_MEDIA_PROP_PUBLISHER_ID);
 }
 
+/**
+ * osinfo_media_get_kernel_path:
+ * @media: a #OsinfoMedia instance
+ *
+ * Retrieves the path to the kernel image in the install tree.
+ *
+ * Note: This only applies to installer medias of 'Linux' OS family.
+ *
+ * Returns: (transfer none): the path to kernel image, or NULL
+ */
+const gchar *osinfo_media_get_kernel_path(OsinfoMedia *media)
+{
+    return osinfo_entity_get_param_value(OSINFO_ENTITY(media),
+                                         OSINFO_MEDIA_PROP_KERNEL);
+}
+
+/**
+ * osinfo_media_get_initrd_path:
+ * @media: a #OsinfoMedia instance
+ *
+ * Retrieves the path to the initrd image in the install tree.
+ *
+ * Note: This only applies to installer medias of 'Linux' OS family.
+ *
+ * Returns: (transfer none): the path to initrd image, or NULL
+ */
+const gchar *osinfo_media_get_initrd_path(OsinfoMedia *media)
+{
+    return osinfo_entity_get_param_value(OSINFO_ENTITY(media),
+                                         OSINFO_MEDIA_PROP_INITRD);
+}
+
 /*
  * Local variables:
  *  indent-tabs-mode: nil
diff --git a/osinfo/osinfo_media.h b/osinfo/osinfo_media.h
index 9ecf0b1..4a82025 100644
--- a/osinfo/osinfo_media.h
+++ b/osinfo/osinfo_media.h
@@ -75,6 +75,8 @@ typedef struct _OsinfoMediaPrivate OsinfoMediaPrivate;
 #define OSINFO_MEDIA_PROP_VOLUME_ID    "volume-id"
 #define OSINFO_MEDIA_PROP_SYSTEM_ID    "system-id"
 #define OSINFO_MEDIA_PROP_PUBLISHER_ID "publisher-id"
+#define OSINFO_MEDIA_PROP_KERNEL       "kernel"
+#define OSINFO_MEDIA_PROP_INITRD       "initrd"
 
 /* object */
 struct _OsinfoMedia
@@ -114,6 +116,8 @@ const gchar *osinfo_media_get_url(OsinfoMedia *media);
 const gchar *osinfo_media_get_volume_id(OsinfoMedia *media);
 const gchar *osinfo_media_get_system_id(OsinfoMedia *media);
 const gchar *osinfo_media_get_publisher_id(OsinfoMedia *media);
+const gchar *osinfo_media_get_kernel_path(OsinfoMedia *media);
+const gchar *osinfo_media_get_initrd_path(OsinfoMedia *media);
 
 #endif /* __OSINFO_MEDIA_H__ */
 /*
-- 
1.7.6.4




More information about the virt-tools-list mailing list