On Wed, Nov 10, 2010 at 06:37:45PM +0000, Blue Swirl wrote: > On Wed, Nov 10, 2010 at 5:14 PM, Gleb Natapov <gleb@xxxxxxxxxx> wrote: > > > > Signed-off-by: Gleb Natapov <gleb@xxxxxxxxxx> > > --- > > hw/usb-bus.c | 35 +++++++++++++++++++++++++++++++++++ > > 1 files changed, 35 insertions(+), 0 deletions(-) > > > > diff --git a/hw/usb-bus.c b/hw/usb-bus.c > > index 256b881..6292282 100644 > > --- a/hw/usb-bus.c > > +++ b/hw/usb-bus.c > > @@ -5,11 +5,13 @@ > > #include "monitor.h" > > > > static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent); > > +static char *usbbus_get_fw_dev_path(DeviceState *dev); > > > > static struct BusInfo usb_bus_info = { > > .name = "USB", > > .size = sizeof(USBBus), > > .print_dev = usb_bus_dev_print, > > + .get_fw_dev_path = usbbus_get_fw_dev_path, > > }; > > static int next_usb_bus = 0; > > static QTAILQ_HEAD(, USBBus) busses = QTAILQ_HEAD_INITIALIZER(busses); > > @@ -307,3 +309,36 @@ USBDevice *usbdevice_create(const char *cmdline) > > } > > return usb->usbdevice_init(params); > > } > > + > > +static int usbbus_get_fw_dev_path_helper(USBDevice *d, USBBus *bus, char *p, > > + int len) > > +{ > > + int l = 0; > > + USBPort *port; > > + > > + QTAILQ_FOREACH(port, &bus->used, next) { > > + if (port->dev != d) > > Braces. > > > + continue; > > + > > + if (port->pdev) { > > + l = usbbus_get_fw_dev_path_helper(port->pdev, bus, p, len); > > + } > > + l += snprintf(p + l, len - l, "%s@%x/", qdev_fw_name(&d->qdev), > > + port->index); > > + return l; > > + } > > + return 0; > > With this return value... > > > +} This can only happen if device is not attached to parent bus, so we should never get here I think. I do not know USB bus enough to be sure. May be we should abort here. > > + > > +static char *usbbus_get_fw_dev_path(DeviceState *dev) > > +{ > > + USBDevice *d = (USBDevice*)dev; > > + USBBus *bus = usb_bus_from_device(d); > > + char path[100]; > > + int l; > > + > > + l = usbbus_get_fw_dev_path_helper(d, bus, path, sizeof(path)); > > + path[l-1] = '\0'; > > ...this statement will have undesirable effects... > > > + > > + return strdup(path); > > ...like this. -- Gleb. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html