From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:43177) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ud1AC-00008H-Ga for qemu-devel@nongnu.org; Thu, 16 May 2013 12:36:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ud1A7-0000og-Lm for qemu-devel@nongnu.org; Thu, 16 May 2013 12:36:20 -0400 Received: from mail-ie0-x22f.google.com ([2607:f8b0:4001:c03::22f]:53548) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ud1A7-0000oc-G4 for qemu-devel@nongnu.org; Thu, 16 May 2013 12:36:15 -0400 Received: by mail-ie0-f175.google.com with SMTP id s9so6997357iec.34 for ; Thu, 16 May 2013 09:36:15 -0700 (PDT) Sender: fluxion Date: Thu, 16 May 2013 11:35:51 -0500 From: mdroth Message-ID: <20130516163551.GA2441@vm> References: <1368662027-14213-1-git-send-email-aliguori@us.ibm.com> <20130516142151.GC23880@vm> <5194F279.30200@redhat.com> <51950139.5000209@greensocs.com> <51950430.9030107@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <51950430.9030107@redhat.com> Subject: Re: [Qemu-devel] [ANNOUNCE] QEMU 1.5.0-rc2 is now available List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Anthony Liguori , qemu-devel@nongnu.org, KONRAD =?iso-8859-1?Q?Fr=E9d=E9ric?= On Thu, May 16, 2013 at 06:07:12PM +0200, Paolo Bonzini wrote: > Il 16/05/2013 17:54, KONRAD Frédéric ha scritto: > > I think this can do the job, any better idea? > > > > diff --git a/hw/pci/pci.c b/hw/pci/pci.c > > index d5257ed..e033b53 100644 > > --- a/hw/pci/pci.c > > +++ b/hw/pci/pci.c > > @@ -43,7 +43,6 @@ > > #endif > > > > static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent); > > -static char *pcibus_get_dev_path(DeviceState *dev); > > static char *pcibus_get_fw_dev_path(DeviceState *dev); > > static int pcibus_reset(BusState *qbus); > > > > @@ -2129,7 +2128,7 @@ static char *pcibus_get_fw_dev_path(DeviceState *dev) > > return g_strdup(path); > > } > > > > -static char *pcibus_get_dev_path(DeviceState *dev) > > +char *pcibus_get_dev_path(DeviceState *dev) > > { > > PCIDevice *d = container_of(dev, PCIDevice, qdev); > > PCIDevice *t; > > diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c > > index 70d2c6b..0241223 100644 > > --- a/hw/virtio/virtio-pci.c > > +++ b/hw/virtio/virtio-pci.c > > @@ -1514,11 +1514,19 @@ static void virtio_pci_bus_new(VirtioBusState > > *bus, VirtIOPCIProxy *dev) > > qbus->allow_hotplug = 1; > > } > > > > +static char *virtio_pci_bus_get_dev_path(DeviceState *dev) > > +{ > > + BusState *bus = qdev_get_parent_bus(dev); > > + DeviceState *proxy = DEVICE(bus->parent); > > + return g_strdup(pcibus_get_dev_path(proxy)); > > You do not need to export pcibus_get_dev_path. This should just return > qdev_get_dev_path(proxy) and should be in TYPE_VIRTIO_BUS, not in the > PCI-specific subclass. > > (The g_strdup is not needed, either). I've been testing the patch below and it seems to do the trick. If it seems reasonable I'll submit it after a bit more testing. diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c index aab72ff..91b7bad 100644 --- a/hw/virtio/virtio-bus.c +++ b/hw/virtio/virtio-bus.c @@ -154,12 +154,35 @@ void virtio_bus_set_vdev_config(VirtioBusState *bus, uint8_t *config) } } +static char *virtio_bus_get_dev_path(DeviceState *dev) +{ + DeviceState *parent_dev = DEVICE(OBJECT(dev)->parent); + BusClass *parent_bus_klass = BUS_GET_CLASS(qdev_get_parent_bus(parent_dev)); + + /* pass this call up to the device's parent's bus to get at + * guest-visible hardware topology + */ + if (parent_bus_klass->get_dev_path) { + return parent_bus_klass->get_dev_path(parent_dev); + } + + return NULL; +} + +static void virtio_bus_class_init(ObjectClass *klass, void *data) +{ + BusClass *k = BUS_CLASS(klass); + + k->get_dev_path = virtio_bus_get_dev_path; +} + static const TypeInfo virtio_bus_info = { .name = TYPE_VIRTIO_BUS, .parent = TYPE_BUS, .instance_size = sizeof(VirtioBusState), .abstract = true, .class_size = sizeof(VirtioBusClass), + .class_init = virtio_bus_class_init, }; > > Paolo > > > +} > > + > > static void virtio_pci_bus_class_init(ObjectClass *klass, void *data) > > { > > BusClass *bus_class = BUS_CLASS(klass); > > VirtioBusClass *k = VIRTIO_BUS_CLASS(klass); > > bus_class->max_dev = 1; > > + bus_class->get_dev_path = virtio_pci_bus_get_dev_path; > > k->notify = virtio_pci_notify; > > k->save_config = virtio_pci_save_config; > > k->load_config = virtio_pci_load_config; > > diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h > > index 8d075ab..fb5723c 100644 > > --- a/include/hw/pci/pci.h > > +++ b/include/hw/pci/pci.h > > @@ -708,6 +708,8 @@ static inline void pci_dma_sglist_init(QEMUSGList > > *qsg, PCIDevice *dev, > > > > extern const VMStateDescription vmstate_pci_device; > > > > +char *pcibus_get_dev_path(DeviceState *dev); > > + > > #define VMSTATE_PCI_DEVICE(_field, _state) { \ > > .name = (stringify(_field)), \ > > .size = sizeof(PCIDevice), \ >