[PATCH 3/8] API to query format of device driver

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

 



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

---
 data/oses/windows.xml.in      |  8 ++++----
 data/schemas/libosinfo.rng    | 11 +++++++++++
 osinfo/libosinfo.syms         |  6 ++++++
 osinfo/osinfo_device_driver.c |  9 +++++++++
 osinfo/osinfo_device_driver.h | 16 ++++++++++++++++
 osinfo/osinfo_loader.c        |  8 ++++++++
 6 files changed, 54 insertions(+), 4 deletions(-)

diff --git a/data/oses/windows.xml.in b/data/oses/windows.xml.in
index 310de62..1b762f8 100644
--- a/data/oses/windows.xml.in
+++ b/data/oses/windows.xml.in
@@ -383,7 +383,7 @@
     </installer>
 
     <!-- virtio block device driver -->
-    <driver arch="i386" location="http://zeenix.fedorapeople.org/drivers/win-tools/preinst/winxp/x86"; pre-installable="true">
+    <driver arch="i386" location="http://zeenix.fedorapeople.org/drivers/win-tools/preinst/winxp/x86"; pre-installable="true" format="windows">
       <file>viostor.cat</file>
       <file>viostor.inf</file>
       <file>viostor.sys</file>
@@ -392,7 +392,7 @@
       <device id="http://pciids.sourceforge.net/v2.2/pci.ids/1af4/1001"/>
     </driver>
 
-    <driver arch="x86_64" location="http://zeenix.fedorapeople.org/drivers/win-tools/preinst/winxp/amd64"; pre-installable="true">
+    <driver arch="x86_64" location="http://zeenix.fedorapeople.org/drivers/win-tools/preinst/winxp/amd64"; pre-installable="true" format="windows">
       <file>viostor.cat</file>
       <file>viostor.inf</file>
       <file>viostor.sys</file>
@@ -754,14 +754,14 @@
     </installer>
 
     <!-- virtio block device driver -->
-    <driver arch="i386" location="http://zeenix.fedorapeople.org/drivers/win-tools/preinst/win7/x86"; pre-installable="true">
+    <driver arch="i386" location="http://zeenix.fedorapeople.org/drivers/win-tools/preinst/win7/x86"; pre-installable="true" format="windows">
       <file>viostor.cat</file>
       <file>viostor.inf</file>
       <file>viostor.sys</file>
       <device id="http://pciids.sourceforge.net/v2.2/pci.ids/1af4/1001"/>
     </driver>
 
-    <driver arch="x86_64" location="http://zeenix.fedorapeople.org/drivers/win-tools/preinst/win7/amd64"; pre-installable="true">
+    <driver arch="x86_64" location="http://zeenix.fedorapeople.org/drivers/win-tools/preinst/win7/amd64"; pre-installable="true" format="windows">
       <file>viostor.cat</file>
       <file>viostor.inf</file>
       <file>viostor.sys</file>
diff --git a/data/schemas/libosinfo.rng b/data/schemas/libosinfo.rng
index 90b0dfb..05a34be 100644
--- a/data/schemas/libosinfo.rng
+++ b/data/schemas/libosinfo.rng
@@ -451,6 +451,11 @@
           <ref name='bool'/>
         </attribute>
       </optional>
+      <optional>
+        <attribute name="format">
+          <ref name='driver-formats'/>
+        </attribute>
+      </optional>
       <zeroOrMore>
         <element name='file'>
           <text/>
@@ -677,4 +682,10 @@
       <param name="pattern">dos|unix</param>
     </data>
   </define>
+
+  <define name='driver-formats'>
+    <data type="string">
+      <param name="pattern">windows|executable|package</param>
+    </data>
+  </define>
 </grammar>
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index 4615829..41d3756 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -399,6 +399,12 @@ LIBOSINFO_0.2.3 {
 
 } LIBOSINFO_0.2.2;
 
+LIBOSINFO_0.2.4 {
+    global:
+	osinfo_device_driver_format_get_type;
+	osinfo_device_driver_get_format;
+} LIBOSINFO_0.2.3;
+
 /* Symbols in next release...
 
   LIBOSINFO_0.0.2 {
diff --git a/osinfo/osinfo_device_driver.c b/osinfo/osinfo_device_driver.c
index d402bc7..d88273a 100644
--- a/osinfo/osinfo_device_driver.c
+++ b/osinfo/osinfo_device_driver.c
@@ -162,6 +162,15 @@ OsinfoDeviceList *osinfo_device_driver_get_devices(OsinfoDeviceDriver *driver)
     return driver->priv->devices;
 }
 
+OsinfoDeviceDriverFormat osinfo_device_driver_get_format(OsinfoDeviceDriver *driver)
+{
+    return osinfo_entity_get_param_value_enum
+        (OSINFO_ENTITY(driver),
+         OSINFO_DEVICE_DRIVER_PROP_FORMAT,
+         OSINFO_TYPE_DEVICE_DRIVER_FORMAT,
+         OSINFO_DEVICE_DRIVER_FORMAT_EXECUTABLE);
+}
+
 void osinfo_device_driver_add_device(OsinfoDeviceDriver *driver,
                                      OsinfoDevice *device)
 {
diff --git a/osinfo/osinfo_device_driver.h b/osinfo/osinfo_device_driver.h
index c894fe8..b45f0ab 100644
--- a/osinfo/osinfo_device_driver.h
+++ b/osinfo/osinfo_device_driver.h
@@ -55,6 +55,7 @@ typedef struct _OsinfoDeviceDriverPrivate OsinfoDeviceDriverPrivate;
 #define OSINFO_DEVICE_DRIVER_PROP_PRE_INSTALLABLE "pre-installable"
 #define OSINFO_DEVICE_DRIVER_PROP_FILE            "file"
 #define OSINFO_DEVICE_DRIVER_PROP_DEVICE          "device"
+#define OSINFO_DEVICE_DRIVER_PROP_FORMAT          "format"
 
 /* object */
 struct _OsinfoDeviceDriver
@@ -76,6 +77,20 @@ struct _OsinfoDeviceDriverClass
     /* class members */
 };
 
+/**
+ * OsinfoDeviceDriverFormat:
+ * @OSINFO_DEVICE_DRIVER_FORMAT_WINDOWS: Windows specific driver in the form of
+ *                                       .cat, .inf, .sys and (optionally) .dll
+ *                                       files.
+ * @OSINFO_DEVICE_DRIVER_FORMAT_EXECUTABLE: Executable installer script/binary.
+ * @OSINFO_DEVICE_DRIVER_FORMAT_PACKAGE: OS-specific installer package (e.g RPM or DEB etc).
+ */
+typedef enum {
+    OSINFO_DEVICE_DRIVER_FORMAT_WINDOWS,
+    OSINFO_DEVICE_DRIVER_FORMAT_EXECUTABLE,
+    OSINFO_DEVICE_DRIVER_FORMAT_PACKAGE
+} OsinfoDeviceDriverFormat;
+
 GType osinfo_device_driver_get_type(void);
 
 const gchar *osinfo_device_driver_get_architecture(OsinfoDeviceDriver *driver);
@@ -83,6 +98,7 @@ const gchar *osinfo_device_driver_get_location(OsinfoDeviceDriver *driver);
 gboolean osinfo_device_driver_get_pre_installable(OsinfoDeviceDriver *driver);
 GList *osinfo_device_driver_get_files(OsinfoDeviceDriver *driver);
 OsinfoDeviceList *osinfo_device_driver_get_devices(OsinfoDeviceDriver *driver);
+OsinfoDeviceDriverFormat osinfo_device_driver_get_format(OsinfoDeviceDriver *driver);
 
 #endif /* __OSINFO_DEVICE_DRIVER_H__ */
 /*
diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
index efbbc97..d186073 100644
--- a/osinfo/osinfo_loader.c
+++ b/osinfo/osinfo_loader.c
@@ -1018,6 +1018,7 @@ static OsinfoDeviceDriver *osinfo_loader_driver(OsinfoLoader *loader,
     xmlChar *arch = xmlGetProp(root, BAD_CAST OSINFO_DEVICE_DRIVER_PROP_ARCHITECTURE);
     xmlChar *location = xmlGetProp(root, BAD_CAST OSINFO_DEVICE_DRIVER_PROP_LOCATION);
     xmlChar *preinst = xmlGetProp(root, BAD_CAST OSINFO_DEVICE_DRIVER_PROP_PRE_INSTALLABLE);
+    xmlChar *format = xmlGetProp(root, BAD_CAST OSINFO_DEVICE_DRIVER_PROP_FORMAT);
 
     OsinfoDeviceDriver *driver = osinfo_device_driver_new(id);
 
@@ -1042,6 +1043,13 @@ static OsinfoDeviceDriver *osinfo_loader_driver(OsinfoLoader *loader,
         xmlFree(preinst);
     }
 
+    if (format) {
+        osinfo_entity_set_param(OSINFO_ENTITY(driver),
+                                OSINFO_DEVICE_DRIVER_PROP_FORMAT,
+                                (gchar *)format);
+        xmlFree(format);
+    }
+
     gint nnodes = osinfo_loader_nodeset("./*", ctxt, &nodes, err);
     if (error_is_set(err)) {
         g_object_unref(G_OBJECT(driver));
-- 
1.8.1

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo


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

  Powered by Linux