From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:56241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TupPR-0003gz-OL for qemu-devel@nongnu.org; Mon, 14 Jan 2013 14:09:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TupPL-0003dv-CB for qemu-devel@nongnu.org; Mon, 14 Jan 2013 14:09:25 -0500 Received: from e33.co.us.ibm.com ([32.97.110.151]:36518) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TupPL-0003dq-5q for qemu-devel@nongnu.org; Mon, 14 Jan 2013 14:09:19 -0500 Received: from /spool/local by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 14 Jan 2013 12:09:12 -0700 Received: from d03relay05.boulder.ibm.com (d03relay05.boulder.ibm.com [9.17.195.107]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id 0362719D803F for ; Mon, 14 Jan 2013 12:09:01 -0700 (MST) Received: from d03av06.boulder.ibm.com (d03av06.boulder.ibm.com [9.17.195.245]) by d03relay05.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r0EJ8ehm085878 for ; Mon, 14 Jan 2013 12:08:45 -0700 Received: from d03av06.boulder.ibm.com (loopback [127.0.0.1]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r0EJAo0X014626 for ; Mon, 14 Jan 2013 12:10:50 -0700 From: Anthony Liguori In-Reply-To: <1357747019-20580-5-git-send-email-fred.konrad@greensocs.com> References: <1357747019-20580-1-git-send-email-fred.konrad@greensocs.com> <1357747019-20580-5-git-send-email-fred.konrad@greensocs.com> Date: Mon, 14 Jan 2013 13:08:24 -0600 Message-ID: <87bocrwpjr.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH V2 4/7] virtio-pci-bus: introduce virtio-pci-bus. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: fred.konrad@greensocs.com, qemu-devel@nongnu.org Cc: kwolf@redhat.com, peter.maydell@linaro.org, e.voevodin@samsung.com, mst@redhat.com, mark.burton@greensocs.com, agraf@suse.de, amit.shah@redhat.com, aneesh.kumar@linux.vnet.ibm.com, stefanha@redhat.com, cornelia.huck@de.ibm.com, pbonzini@redhat.com, afaerber@suse.de fred.konrad@greensocs.com writes: > From: KONRAD Frederic > > Introduce virtio-pci-bus, which extends virtio-bus. It is used with virtio-pci > transport device. > > Signed-off-by: KONRAD Frederic > --- > hw/virtio-pci.c | 37 +++++++++++++++++++++++++++++++++++++ > hw/virtio-pci.h | 23 +++++++++++++++++++++-- > 2 files changed, 58 insertions(+), 2 deletions(-) > > diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c > index c7f0c4d..090dc41 100644 > --- a/hw/virtio-pci.c > +++ b/hw/virtio-pci.c > @@ -31,6 +31,7 @@ > #include "sysemu/blockdev.h" > #include "virtio-pci.h" > #include "qemu/range.h" > +#include "virtio-bus.h" > > /* from Linux's linux/virtio_pci.h */ > > @@ -1162,6 +1163,41 @@ static TypeInfo virtio_scsi_info = { > .class_init = virtio_scsi_class_init, > }; > > +/* virtio-pci-bus */ > + > +VirtioBusState *virtio_pci_bus_new(VirtIOPCIProxy *dev) > +{ > + DeviceState *qdev = DEVICE(dev); > + BusState *qbus = qbus_create(TYPE_VIRTIO_PCI_BUS, qdev, NULL); > + VirtioBusState *bus = VIRTIO_BUS(qbus); > + qbus->allow_hotplug = 0; Any reason to not use a qbus_create_inplace()? Regards, Anthony Liguori > + return bus; > +} > + > +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; > + k->notify = virtio_pci_notify; > + k->save_config = virtio_pci_save_config; > + k->load_config = virtio_pci_load_config; > + k->save_queue = virtio_pci_save_queue; > + k->load_queue = virtio_pci_load_queue; > + k->get_features = virtio_pci_get_features; > + k->query_guest_notifiers = virtio_pci_query_guest_notifiers; > + k->set_host_notifier = virtio_pci_set_host_notifier; > + k->set_guest_notifiers = virtio_pci_set_guest_notifiers; > + k->vmstate_change = virtio_pci_vmstate_change; > +} > + > +static const TypeInfo virtio_pci_bus_info = { > + .name = TYPE_VIRTIO_PCI_BUS, > + .parent = TYPE_VIRTIO_BUS, > + .instance_size = sizeof(VirtioPCIBusState), > + .class_init = virtio_pci_bus_class_init, > +}; > + > static void virtio_pci_register_types(void) > { > type_register_static(&virtio_blk_info); > @@ -1170,6 +1206,7 @@ static void virtio_pci_register_types(void) > type_register_static(&virtio_balloon_info); > type_register_static(&virtio_scsi_info); > type_register_static(&virtio_rng_info); > + type_register_static(&virtio_pci_bus_info); > } > > type_init(virtio_pci_register_types) > diff --git a/hw/virtio-pci.h b/hw/virtio-pci.h > index b58d9a2..ed0097f 100644 > --- a/hw/virtio-pci.h > +++ b/hw/virtio-pci.h > @@ -20,6 +20,25 @@ > #include "virtio-rng.h" > #include "virtio-serial.h" > #include "virtio-scsi.h" > +#include "virtio-bus.h" > + > +typedef struct VirtIOPCIProxy VirtIOPCIProxy; > + > +/* virtio-pci-bus */ > + > +typedef struct VirtioBusState VirtioPCIBusState; > +typedef struct VirtioBusClass VirtioPCIBusClass; > + > +#define TYPE_VIRTIO_PCI_BUS "virtio-pci-bus" > +#define VIRTIO_PCI_BUS(obj) \ > + OBJECT_CHECK(VirtioPCIBusState, (obj), TYPE_VIRTIO_PCI_BUS) > +#define VIRTIO_PCI_BUS_GET_CLASS(obj) \ > + OBJECT_GET_CLASS(VirtioPCIBusClass, obj, TYPE_VIRTIO_PCI_BUS) > +#define VIRTIO_PCI_BUS_CLASS(klass) \ > + OBJECT_CLASS_CHECK(VirtioPCIBusClass, klass, TYPE_VIRTIO_PCI_BUS) > + > + > +VirtioBusState *virtio_pci_bus_new(VirtIOPCIProxy *dev); > > /* Performance improves when virtqueue kick processing is decoupled from the > * vcpu thread using ioeventfd for some devices. */ > @@ -31,7 +50,7 @@ typedef struct { > unsigned int users; > } VirtIOIRQFD; > > -typedef struct { > +struct VirtIOPCIProxy { > PCIDevice pci_dev; > VirtIODevice *vdev; > MemoryRegion bar; > @@ -51,7 +70,7 @@ typedef struct { > bool ioeventfd_disabled; > bool ioeventfd_started; > VirtIOIRQFD *vector_irqfd; > -} VirtIOPCIProxy; > +}; > > void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev); > void virtio_pci_reset(DeviceState *d); > -- > 1.7.11.7