From 71938a09d2b9fd4007515fec6c395916cb08f868 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Wed, 12 Jun 2013 13:01:49 +0200 Subject: usb: add serial bus property This patch adds a serial property for all usb devices, which can be used to set the serial number of a usb device (as listed by lsusb -v) to a specific value. Applies to emulated devices only. Signed-off-by: Gerd Hoffmann --- hw/usb/desc.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'hw/usb/desc.c') diff --git a/hw/usb/desc.c b/hw/usb/desc.c index fce303e9c8..bf6c522682 100644 --- a/hw/usb/desc.c +++ b/hw/usb/desc.c @@ -566,6 +566,12 @@ void usb_desc_create_serial(USBDevice *dev) char *path; int dst; + if (dev->serial) { + /* 'serial' usb bus property has priority if present */ + usb_desc_set_string(dev, index, dev->serial); + return; + } + assert(index != 0 && desc->str[index] != NULL); dst = snprintf(serial, sizeof(serial), "%s", desc->str[index]); path = qdev_get_dev_path(hcd); -- cgit v1.2.1