[PATCH] node_device_udev: Try harder to get human readable vendor:product

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

 



The manufacurer and product from USB device itself are usually not particularly
useful -- they tend to be missing, or ugly (all-uppercase, padded with spaces,
etc.). Prefer what's in the usb id database and fall back to descriptors only
if the device is too now to be in database.
---
Before: http://v3.sk/~lkundrak/virt/old.png
After: http://v3.sk/~lkundrak/virt/libvirt.png

 src/node_device/node_device_udev.c | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 0fe474d..53792f0 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -580,6 +580,7 @@ static int udevProcessUSBDevice(struct udev_device *device,
 {
     union _virNodeDevCapData *data = &def->caps->data;
     int ret = -1;
+    int err;
 
     if (udevGetUintProperty(device,
                             "BUSNUM",
@@ -602,10 +603,17 @@ static int udevProcessUSBDevice(struct udev_device *device,
         goto out;
     }
 
-    if (udevGetStringSysfsAttr(device,
-                              "manufacturer",
-                              &data->usb_dev.vendor_name) == PROPERTY_ERROR) {
+    err = udevGetStringProperty(device,
+                                "ID_VENDOR_FROM_DATABASE",
+                                &data->usb_dev.vendor_name);
+    if (err == PROPERTY_ERROR)
         goto out;
+    if (err == PROPERTY_MISSING) {
+        if (udevGetStringSysfsAttr(device,
+                                  "manufacturer",
+                                  &data->usb_dev.vendor_name) == PROPERTY_ERROR) {
+            goto out;
+        }
     }
 
     if (udevGetUintProperty(device,
@@ -615,10 +623,17 @@ static int udevProcessUSBDevice(struct udev_device *device,
         goto out;
     }
 
-    if (udevGetStringSysfsAttr(device,
-                              "product",
-                              &data->usb_dev.product_name) == PROPERTY_ERROR) {
+    err = udevGetStringProperty(device,
+                                "ID_MODEL_FROM_DATABASE",
+                                &data->usb_dev.product_name);
+    if (err == PROPERTY_ERROR)
         goto out;
+    if (err == PROPERTY_MISSING) {
+        if (udevGetStringSysfsAttr(device,
+                                  "product",
+                                  &data->usb_dev.product_name) == PROPERTY_ERROR) {
+            goto out;
+        }
     }
 
     if (udevGenerateDeviceName(device, def, NULL) != 0) {
-- 
1.9.3

--
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]