From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:48648) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAgxD-0004Ni-2D for qemu-devel@nongnu.org; Thu, 22 Mar 2012 08:17:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SAgx6-0002Zj-Qm for qemu-devel@nongnu.org; Thu, 22 Mar 2012 08:17:18 -0400 Received: from mail-we0-f173.google.com ([74.125.82.173]:43781) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAgx6-0002Z8-FC for qemu-devel@nongnu.org; Thu, 22 Mar 2012 08:17:12 -0400 Received: by werp12 with SMTP id p12so2044127wer.4 for ; Thu, 22 Mar 2012 05:17:10 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4F6B1841.7050000@redhat.com> Date: Thu, 22 Mar 2012 13:17:05 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1332418064-23091-1-git-send-email-kraxel@redhat.com> In-Reply-To: <1332418064-23091-1-git-send-email-kraxel@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] usb/vmstate: add parent dev path List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: qemu-devel@nongnu.org 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