From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:47734) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPHxI-0006oY-6I for qemu-devel@nongnu.org; Tue, 01 May 2012 14:37:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SPHxF-0000d6-Tw for qemu-devel@nongnu.org; Tue, 01 May 2012 14:37:43 -0400 Received: from e34.co.us.ibm.com ([32.97.110.152]:59624) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPHxF-0000Oa-LU for qemu-devel@nongnu.org; Tue, 01 May 2012 14:37:41 -0400 Received: from /spool/local by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 1 May 2012 12:37:11 -0600 Received: from d03relay03.boulder.ibm.com (d03relay03.boulder.ibm.com [9.17.195.228]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id EBDAB19D805C for ; Tue, 1 May 2012 12:36:21 -0600 (MDT) Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay03.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q41IaEeY153208 for ; Tue, 1 May 2012 12:36:22 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q41IaCwA006586 for ; Tue, 1 May 2012 12:36:14 -0600 Message-ID: <4FA02D1A.1090807@us.ibm.com> Date: Tue, 01 May 2012 13:36:10 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1335896294-9530-1-git-send-email-aliguori@us.ibm.com> <1335896294-9530-6-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1335896294-9530-6-git-send-email-aliguori@us.ibm.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 05/14] qdev: use wrapper for qdev_get_path List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Peter Maydell , Wanpeng Li , qemu-devel@nongnu.org, Gerd Hoffmann , Paolo Bonzini , Andreas Faerber Hi Gerd, Could you carefully review the USB changes here? I'm not really sure what our contract is with the guest in terms of ABI compatibility. I think it's good but it could use a second set of eyes. Regards, Anthony Liguori On 05/01/2012 01:18 PM, Anthony Liguori wrote: > This makes it easier to remove it from BusInfo. > > Signed-off-by: Anthony Liguori > --- > exec.c | 4 ++-- > hw/qdev.c | 16 ++++++++++++++++ > hw/qdev.h | 2 ++ > hw/usb/desc.c | 7 +++++-- > savevm.c | 12 ++++++------ > 5 files changed, 31 insertions(+), 10 deletions(-) > > diff --git a/exec.c b/exec.c > index 0607c9b..e3523d2 100644 > --- a/exec.c > +++ b/exec.c > @@ -2583,8 +2583,8 @@ void qemu_ram_set_idstr(ram_addr_t addr, const char *name, DeviceState *dev) > assert(new_block); > assert(!new_block->idstr[0]); > > - if (dev&& dev->parent_bus&& dev->parent_bus->info->get_dev_path) { > - char *id = dev->parent_bus->info->get_dev_path(dev); > + if (dev) { > + char *id = qdev_get_dev_path(dev); > if (id) { > snprintf(new_block->idstr, sizeof(new_block->idstr), "%s/", id); > g_free(id); > diff --git a/hw/qdev.c b/hw/qdev.c > index e17a9ab..e835650 100644 > --- a/hw/qdev.c > +++ b/hw/qdev.c > @@ -519,6 +519,22 @@ char* qdev_get_fw_dev_path(DeviceState *dev) > return strdup(path); > } > > +char *qdev_get_dev_path(DeviceState *dev) > +{ > + BusClass *bc; > + > + if (!dev->parent_bus) { > + return NULL; > + } > + > + bc = BUS_GET_CLASS(dev->parent_bus); > + if (bc->get_dev_path) { > + return bc->get_dev_path(dev); > + } > + > + return NULL; > +} > + > static char *qdev_get_type(Object *obj, Error **errp) > { > return g_strdup(object_get_typename(obj)); > diff --git a/hw/qdev.h b/hw/qdev.h > index ca8386a..fc3b50f 100644 > --- a/hw/qdev.h > +++ b/hw/qdev.h > @@ -362,4 +362,6 @@ extern int qdev_hotplug; > > void qdev_add_properties(DeviceState *dev, Property *props); > > +char *qdev_get_dev_path(DeviceState *dev); > + > #endif > diff --git a/hw/usb/desc.c b/hw/usb/desc.c > index e8a3c6a..64352c9 100644 > --- a/hw/usb/desc.c > +++ b/hw/usb/desc.c > @@ -433,11 +433,14 @@ void usb_desc_create_serial(USBDevice *dev) > int index = desc->id.iSerialNumber; > char serial[64]; > int dst; > + char *path = NULL; > > assert(index != 0&& desc->str[index] != NULL); > dst = snprintf(serial, sizeof(serial), "%s", desc->str[index]); > - if (hcd&& hcd->parent_bus&& hcd->parent_bus->info->get_dev_path) { > - char *path = hcd->parent_bus->info->get_dev_path(hcd); > + if (hcd->parent_bus&& hcd->parent_bus->parent) { > + path = qdev_get_dev_path(hcd->parent_bus->parent); > + } > + if (path) { > dst += snprintf(serial+dst, sizeof(serial)-dst, "-%s", path); > } > dst += snprintf(serial+dst, sizeof(serial)-dst, "-%s", dev->port->path); > diff --git a/savevm.c b/savevm.c > index 2d18bab..818ddfc 100644 > --- a/savevm.c > +++ b/savevm.c > @@ -1248,8 +1248,8 @@ int register_savevm_live(DeviceState *dev, > se->is_ram = 1; > } > > - if (dev&& dev->parent_bus&& dev->parent_bus->info->get_dev_path) { > - char *id = dev->parent_bus->info->get_dev_path(dev); > + if (dev) { > + char *id = qdev_get_dev_path(dev); > if (id) { > pstrcpy(se->idstr, sizeof(se->idstr), id); > pstrcat(se->idstr, sizeof(se->idstr), "/"); > @@ -1292,8 +1292,8 @@ void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque) > SaveStateEntry *se, *new_se; > char id[256] = ""; > > - if (dev&& dev->parent_bus&& dev->parent_bus->info->get_dev_path) { > - char *path = dev->parent_bus->info->get_dev_path(dev); > + if (dev) { > + char *path = qdev_get_dev_path(dev); > if (path) { > pstrcpy(id, sizeof(id), path); > pstrcat(id, sizeof(id), "/"); > @@ -1334,8 +1334,8 @@ int vmstate_register_with_alias_id(DeviceState *dev, int instance_id, > se->alias_id = alias_id; > se->no_migrate = vmsd->unmigratable; > > - if (dev&& dev->parent_bus&& dev->parent_bus->info->get_dev_path) { > - char *id = dev->parent_bus->info->get_dev_path(dev); > + if (dev) { > + char *id = qdev_get_dev_path(dev); > if (id) { > pstrcpy(se->idstr, sizeof(se->idstr), id); > pstrcat(se->idstr, sizeof(se->idstr), "/");