[PATCH libosinfo] Fix XML loader to correctly distinguish vendor/product names & IDs

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

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

The loading of pci.ids/usb.ids was setting the 'product' and
'vendor' properties with ID values. The loading of devices from
XML was setting 'product' and 'vendor' properties with name
strings, but forgetting to parse ID values from the XML
---
 osinfo/libosinfo.syms  |    2 ++
 osinfo/osinfo_device.c |   10 ++++++++++
 osinfo/osinfo_device.h |   14 +++++++++-----
 osinfo/osinfo_loader.c |    9 +++++++--
 4 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index eef796a..dcf12ab 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -26,7 +26,9 @@ LIBOSINFO_0.0.1 {
 	osinfo_device_get_type;
 	osinfo_device_new;
 	osinfo_device_get_vendor;
+	osinfo_device_get_vendor_id;
 	osinfo_device_get_product;
+	osinfo_device_get_product_id;
 	osinfo_device_get_class;
 	osinfo_device_get_bus_type;
 	osinfo_device_get_name;
diff --git a/osinfo/osinfo_device.c b/osinfo/osinfo_device.c
index 5df930e..47d5e29 100644
--- a/osinfo/osinfo_device.c
+++ b/osinfo/osinfo_device.c
@@ -85,11 +85,21 @@ const gchar *osinfo_device_get_vendor(OsinfoDevice *dev)
     return osinfo_entity_get_param_value(OSINFO_ENTITY(dev), OSINFO_DEVICE_PROP_VENDOR);
 }
 
+const gchar *osinfo_device_get_vendor_id(OsinfoDevice *dev)
+{
+    return osinfo_entity_get_param_value(OSINFO_ENTITY(dev), OSINFO_DEVICE_PROP_VENDOR_ID);
+}
+
 const gchar *osinfo_device_get_product(OsinfoDevice *dev)
 {
     return osinfo_entity_get_param_value(OSINFO_ENTITY(dev), OSINFO_DEVICE_PROP_PRODUCT);
 }
 
+const gchar *osinfo_device_get_product_id(OsinfoDevice *dev)
+{
+    return osinfo_entity_get_param_value(OSINFO_ENTITY(dev), OSINFO_DEVICE_PROP_PRODUCT_ID);
+}
+
 const gchar *osinfo_device_get_bus_type(OsinfoDevice *dev)
 {
     return osinfo_entity_get_param_value(OSINFO_ENTITY(dev), OSINFO_DEVICE_PROP_BUS_TYPE);
diff --git a/osinfo/osinfo_device.h b/osinfo/osinfo_device.h
index 96d6348..c31c530 100644
--- a/osinfo/osinfo_device.h
+++ b/osinfo/osinfo_device.h
@@ -44,11 +44,13 @@ typedef struct _OsinfoDeviceClass   OsinfoDeviceClass;
 
 typedef struct _OsinfoDevicePrivate OsinfoDevicePrivate;
 
-#define OSINFO_DEVICE_PROP_VENDOR   "vendor"
-#define OSINFO_DEVICE_PROP_PRODUCT  "product"
-#define OSINFO_DEVICE_PROP_NAME     "name"
-#define OSINFO_DEVICE_PROP_CLASS    "class"
-#define OSINFO_DEVICE_PROP_BUS_TYPE "bus-type"
+#define OSINFO_DEVICE_PROP_VENDOR     "vendor"
+#define OSINFO_DEVICE_PROP_VENDOR_ID  "vendor-id"
+#define OSINFO_DEVICE_PROP_PRODUCT    "product"
+#define OSINFO_DEVICE_PROP_PRODUCT_ID "product-id"
+#define OSINFO_DEVICE_PROP_NAME       "name"
+#define OSINFO_DEVICE_PROP_CLASS      "class"
+#define OSINFO_DEVICE_PROP_BUS_TYPE   "bus-type"
 
 /* object */
 struct _OsinfoDevice
@@ -75,7 +77,9 @@ OsinfoDevice *osinfo_device_new(const gchar *id);
 
 
 const gchar *osinfo_device_get_vendor(OsinfoDevice *dev);
+const gchar *osinfo_device_get_vendor_id(OsinfoDevice *dev);
 const gchar *osinfo_device_get_product(OsinfoDevice *dev);
+const gchar *osinfo_device_get_product_id(OsinfoDevice *dev);
 const gchar *osinfo_device_get_bus_type(OsinfoDevice *dev);
 const gchar *osinfo_device_get_class(OsinfoDevice *dev);
 const gchar *osinfo_device_get_name(OsinfoDevice *dev);
diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
index e440a15..337f737 100644
--- a/osinfo/osinfo_loader.c
+++ b/osinfo/osinfo_loader.c
@@ -263,7 +263,9 @@ static void osinfo_loader_device(OsinfoLoader *loader,
     gchar *id = (gchar *)xmlGetProp(root, BAD_CAST "id");
     const gchar *const keys[] = {
         OSINFO_DEVICE_PROP_VENDOR,
+        OSINFO_DEVICE_PROP_VENDOR_ID,
         OSINFO_DEVICE_PROP_PRODUCT,
+        OSINFO_DEVICE_PROP_PRODUCT_ID,
         OSINFO_DEVICE_PROP_BUS_TYPE,
         OSINFO_DEVICE_PROP_CLASS,
         OSINFO_DEVICE_PROP_NAME,
@@ -1038,11 +1040,14 @@ osinfo_loader_process_file_reg_ids(OsinfoLoader *loader,
 
                 OsinfoDevice *dev = osinfo_loader_get_device(loader, id);
                 osinfo_entity_set_param(OSINFO_ENTITY(dev),
-                                        OSINFO_DEVICE_PROP_VENDOR,
+                                        OSINFO_DEVICE_PROP_VENDOR_ID,
                                         vendor_id);
                 osinfo_entity_set_param(OSINFO_ENTITY(dev),
-                                        OSINFO_DEVICE_PROP_PRODUCT,
+                                        OSINFO_DEVICE_PROP_PRODUCT_ID,
                                         device_id);
+                osinfo_entity_set_param(OSINFO_ENTITY(dev),
+                                        OSINFO_DEVICE_PROP_BUS_TYPE,
+                                        busType);
                 g_free(id);
             }
         } else {
-- 
1.7.7.6


[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux