[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] usb/vmstate: add parent dev path
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH] usb/vmstate: add parent dev path |
Date: |
Thu, 22 Mar 2012 13:17:05 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120216 Thunderbird/10.0.1 |
Il 22/03/2012 13:07, Gerd Hoffmann ha scritto:
> @@ -460,7 +462,21 @@ static void usb_bus_dev_print(Monitor *mon, DeviceState
> *qdev, int indent)
> static char *usb_get_dev_path(DeviceState *qdev)
> {
> USBDevice *dev = USB_DEVICE(qdev);
> - return g_strdup(dev->port->path);
> + DeviceState *hcd = qdev->parent_bus->parent;
> + char *id = NULL;
> +
> + if ((dev->flags & (1 << USB_DEV_FLAG_FULL_PATH)) &&
> + hcd && hcd->parent_bus && hcd->parent_bus->info->get_dev_path) {
> + id = hcd->parent_bus->info->get_dev_path(hcd);
> + }
> + if (id) {
> + int len = strlen(id)+strlen(dev->port->path)+2;
> + char *ret = g_malloc(len);
> + snprintf(ret, len, "%s/%s", id, dev->port->path);
You can use g_strdup_printf here, also this is leaking id (I have to fix
it for SCSI too).
> + return ret;
> + } else {
> + return g_strdup(dev->port->path);
> + }
> }
>
> static char *usb_get_fw_dev_path(DeviceState *qdev)
Paolo