Skip to contentSkip to conversation

hw/usb/bus.c: print device ID when 'info usb' used

PATCH New Programmingkid 1 participant 1 message Aug 28, 2015

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 hw/usb/bus.c: print device ID when 'info usb' used

Print the ID (if available) of each device when 'info usb' is used in the monitor.

---
Added conditional code that only prints the ID if it is available.

 hw/usb/bus.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)
hw/usb/bus.c +11 -3
index 5f39e1e..6da6695 100644
@@ -655,9 +655,17 @@ void hmp_info_usb(Monitor *mon, const QDict *qdict)
             dev = port->dev;
             if (!dev)
                 continue;
-            monitor_printf(mon, "  Device %d.%d, Port %s, Speed %s Mb/s, Product %s\n",
-                           bus->busnr, dev->addr, port->path, usb_speed(dev->speed),
-                           dev->product_desc);
+            if (dev->qdev.id) {  /* Print ID if available */
+                monitor_printf(mon, "  Device %d.%d, Port %s, Speed %s Mb/s, "
+                                    "Product %s, ID %s\n",
+                      bus->busnr, dev->addr, port->path, usb_speed(dev->speed),
+                      dev->product_desc, dev->qdev.id);
+            } else {
+                monitor_printf(mon, "  Device %d.%d, Port %s, Speed %s Mb/s, "
+                                    "Product %s\n",
+                                    bus->busnr, dev->addr, port->path,
+                                    usb_speed(dev->speed), dev->product_desc);
+            }
         }
     }
 }
Signature · 1 line
1.7.5.4