[virt-tools-list] [PATCH libosinfo] Add a 'distro' property for OS objects
Daniel P. Berrange
berrange at redhat.com
Mon Mar 12 12:04:27 UTC 2012
From: "Daniel P. Berrange" <berrange at redhat.com>
The OS 'family' property is used to refer to the kernel type of
the OS. The new 'distro' property refers to the grouping of OS
by a particular vendor. For example all Linux distros have a
family of 'Linux', but their own distinct 'distro' value (Fedora,
Ubuntu, etc). Debian is even more fun having alternate releases
which use a Hurd of FreeBSD kernel, these variants will each have
the 'hurd' or 'freebsd' family, with a common 'debian' distro.
---
data/oses/bsd.xml | 40 --------------------------------------
data/oses/freebsd.xml | 40 ++++++++++++++++++++++++++++++++++++++
osinfo/libosinfo.syms | 1 +
osinfo/osinfo_loader.c | 1 +
osinfo/osinfo_os.c | 50 +++++++++++++++++++++++++++++++++++++++++++----
osinfo/osinfo_os.h | 2 +
6 files changed, 89 insertions(+), 45 deletions(-)
delete mode 100644 data/oses/bsd.xml
create mode 100644 data/oses/freebsd.xml
diff --git a/data/oses/bsd.xml b/data/oses/bsd.xml
deleted file mode 100644
index 5a82689..0000000
--- a/data/oses/bsd.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<libosinfo version="0.0.1">
-
- <!-- FIXME: We really should put all these in 'BSD' family but we will need
- to tweak python-virtinst before that or at the same time.
- -->
- <os id="http://freebsd.org/freebsd6">
- <short-id>freebsd6</short-id>
- <name>FreeBSD 6</name>
- <version>6.4</version>
- <vendor>FreeBSD Project</vendor>
- <family>UNIX</family>
-
- <devices>
- <device id="http://pciids.sourceforge.net/v2.2/pci.ids/10ec/8029"/>
- </devices>
- </os>
-
- <os id="http://freebsd.org/freebsd7">
- <short-id>freebsd7</short-id>
- <name>FreeBSD 7</name>
- <version>7.4</version>
- <vendor>FreeBSD Project</vendor>
- <family>UNIX</family>
- <upgrades id="http://freebsd.org/freebsd6"/>
- </os>
-
- <os id="http://freebsd.org/freebsd8">
- <short-id>freebsd8</short-id>
- <name>FreeBSD 8</name>
- <version>8.2</version>
- <vendor>FreeBSD Project</vendor>
- <family>UNIX</family>
- <upgrades id="http://freebsd.org/freebsd7"/>
-
- <devices>
- <device id="http://pciids.sourceforge.net/v2.2/pci.ids/8086/100e"/>
- </devices>
- </os>
-
-</libosinfo>
diff --git a/data/oses/freebsd.xml b/data/oses/freebsd.xml
new file mode 100644
index 0000000..5a82689
--- /dev/null
+++ b/data/oses/freebsd.xml
@@ -0,0 +1,40 @@
+<libosinfo version="0.0.1">
+
+ <!-- FIXME: We really should put all these in 'BSD' family but we will need
+ to tweak python-virtinst before that or at the same time.
+ -->
+ <os id="http://freebsd.org/freebsd6">
+ <short-id>freebsd6</short-id>
+ <name>FreeBSD 6</name>
+ <version>6.4</version>
+ <vendor>FreeBSD Project</vendor>
+ <family>UNIX</family>
+
+ <devices>
+ <device id="http://pciids.sourceforge.net/v2.2/pci.ids/10ec/8029"/>
+ </devices>
+ </os>
+
+ <os id="http://freebsd.org/freebsd7">
+ <short-id>freebsd7</short-id>
+ <name>FreeBSD 7</name>
+ <version>7.4</version>
+ <vendor>FreeBSD Project</vendor>
+ <family>UNIX</family>
+ <upgrades id="http://freebsd.org/freebsd6"/>
+ </os>
+
+ <os id="http://freebsd.org/freebsd8">
+ <short-id>freebsd8</short-id>
+ <name>FreeBSD 8</name>
+ <version>8.2</version>
+ <vendor>FreeBSD Project</vendor>
+ <family>UNIX</family>
+ <upgrades id="http://freebsd.org/freebsd7"/>
+
+ <devices>
+ <device id="http://pciids.sourceforge.net/v2.2/pci.ids/8086/100e"/>
+ </devices>
+ </os>
+
+</libosinfo>
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index 1f1a161..eef796a 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -114,6 +114,7 @@ LIBOSINFO_0.0.1 {
osinfo_os_get_device_links;
osinfo_os_add_device;
osinfo_os_get_family;
+ osinfo_os_get_distro;
osinfo_os_get_media_list;
osinfo_os_add_media;
osinfo_os_get_tree_list;
diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
index 6d57e6e..e440a15 100644
--- a/osinfo/osinfo_loader.c
+++ b/osinfo/osinfo_loader.c
@@ -692,6 +692,7 @@ static void osinfo_loader_os(OsinfoLoader *loader,
gchar *id = (gchar *)xmlGetProp(root, BAD_CAST "id");
const gchar *const keys[] = {
OSINFO_OS_PROP_FAMILY,
+ OSINFO_OS_PROP_DISTRO,
NULL
};
if (!id) {
diff --git a/osinfo/osinfo_os.c b/osinfo/osinfo_os.c
index 4b91142..d7a5515 100644
--- a/osinfo/osinfo_os.c
+++ b/osinfo/osinfo_os.c
@@ -62,6 +62,7 @@ enum {
PROP_0,
PROP_FAMILY,
+ PROP_DISTRO,
};
static void osinfo_os_finalize (GObject *object);
@@ -86,6 +87,11 @@ osinfo_os_get_property (GObject *object,
osinfo_entity_get_param_value (entity,
"family"));
break;
+ case PROP_DISTRO:
+ g_value_set_string (value,
+ osinfo_entity_get_param_value (entity,
+ "distro"));
+ break;
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -122,11 +128,11 @@ osinfo_os_class_init (OsinfoOsClass *klass)
/**
* OsinfoOs:family:
*
- * The generic family this OS belongs to, for example Linux, Windows,
- * Solaris, UNIX etc.
+ * The generic family this OS belongs to, based upon its kernel,
+ * for example Linux, Windows, Solaris, FreeBSD etc.
*/
pspec = g_param_spec_string ("family",
- "FAMILY",
+ "Family",
"Generic Family",
NULL /* default value */,
G_PARAM_READABLE |
@@ -136,6 +142,24 @@ osinfo_os_class_init (OsinfoOsClass *klass)
g_object_class_install_property (g_klass,
PROP_FAMILY,
pspec);
+
+ /**
+ * OsinfoOs:distro:
+ *
+ * The generic distro this OS belongs to, for example Fedora, Windows,
+ * Solaris, FreeBSD etc.
+ */
+ pspec = g_param_spec_string ("distro",
+ "Distro",
+ "Generic Distro",
+ NULL /* default value */,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (g_klass,
+ PROP_DISTRO,
+ pspec);
}
static void
@@ -336,8 +360,8 @@ OsinfoDeviceLink *osinfo_os_add_device(OsinfoOs *os, OsinfoDevice *dev)
* osinfo_os_get_family:
* @os: a OsinfoOs
*
- * Retrieves the generic family the OS @os belongs to, for example Linux,
- * Windows, Solaris, UNIX etc.
+ * Retrieves the generic family the OS @os belongs to, based upon its kernel,
+ * for example Linux, Windows, Solaris, FreeBSD etc.
*
* Returns: (transfer none): the family of this os
*/
@@ -349,6 +373,22 @@ const gchar *osinfo_os_get_family(OsinfoOs *os)
}
/**
+ * osinfo_os_get_distro:
+ * @os: a OsinfoOs
+ *
+ * Retrieves the generic family the OS @os belongs to, for example Fedora,
+ * Ubuntu, Windows, Solaris, FreeBSD etc.
+ *
+ * Returns: (transfer none): the distro of this os
+ */
+const gchar *osinfo_os_get_distro(OsinfoOs *os)
+{
+ g_return_val_if_fail(OSINFO_IS_OS(os), NULL);
+
+ return osinfo_entity_get_param_value(OSINFO_ENTITY(os), "distro");
+}
+
+/**
* osinfo_os_get_media_list:
* @os: an operating system
*
diff --git a/osinfo/osinfo_os.h b/osinfo/osinfo_os.h
index ca16dc3..862498c 100644
--- a/osinfo/osinfo_os.h
+++ b/osinfo/osinfo_os.h
@@ -53,6 +53,7 @@ typedef struct _OsinfoOsClass OsinfoOsClass;
typedef struct _OsinfoOsPrivate OsinfoOsPrivate;
#define OSINFO_OS_PROP_FAMILY "family"
+#define OSINFO_OS_PROP_DISTRO "distro"
/* object */
struct _OsinfoOs
@@ -87,6 +88,7 @@ OsinfoDeviceLinkList *osinfo_os_get_device_links(OsinfoOs *os, OsinfoFilter *fil
OsinfoDeviceLink *osinfo_os_add_device(OsinfoOs *os, OsinfoDevice *dev);
const gchar *osinfo_os_get_family(OsinfoOs *os);
+const gchar *osinfo_os_get_distro(OsinfoOs *os);
OsinfoMediaList *osinfo_os_get_media_list(OsinfoOs *os);
void osinfo_os_add_media(OsinfoOs *os, OsinfoMedia *media);
OsinfoTreeList *osinfo_os_get_tree_list(OsinfoOs *os);
--
1.7.7.6
More information about the virt-tools-list
mailing list