From patchwork Fri Nov 30 17:12:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: fred.konrad@greensocs.com X-Patchwork-Id: 203011 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 98C0F2C008F for ; Sat, 1 Dec 2012 05:00:53 +1100 (EST) Received: from localhost ([::1]:48378 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TeU8n-0004Py-7U for incoming@patchwork.ozlabs.org; Fri, 30 Nov 2012 12:12:41 -0500 Received: from eggs.gnu.org ([208.118.235.92]:35129) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TeU83-0002MP-GV for qemu-devel@nongnu.org; Fri, 30 Nov 2012 12:11:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TeU81-0000RN-1I for qemu-devel@nongnu.org; Fri, 30 Nov 2012 12:11:55 -0500 Received: from greensocs.com ([87.106.252.221]:41238 helo=s15328186.onlinehome-server.info) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TeU80-0000RE-MA for qemu-devel@nongnu.org; Fri, 30 Nov 2012 12:11:52 -0500 Received: from localhost (unknown [127.0.0.1]) by s15328186.onlinehome-server.info (Postfix) with ESMTP id 2E97D42AFCE; Fri, 30 Nov 2012 17:11:52 +0000 (UTC) Received: from s15328186.onlinehome-server.info ([127.0.0.1]) by localhost (s15328186.onlinehome-server.info [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id N+WYUS6a07DZ; Fri, 30 Nov 2012 18:11:52 +0100 (CET) Received: by s15328186.onlinehome-server.info (Postfix, from userid 491) id EA194439E21; Fri, 30 Nov 2012 18:11:51 +0100 (CET) Received: from localhost.localdomain (214.155.72.86.rev.sfr.net [86.72.155.214]) by s15328186.onlinehome-server.info (Postfix) with ESMTPSA id 1541E42AFCE; Fri, 30 Nov 2012 18:11:51 +0100 (CET) From: fred.konrad@greensocs.com To: qemu-devel@nongnu.org Date: Fri, 30 Nov 2012 18:12:08 +0100 Message-Id: <1354295530-18644-5-git-send-email-fred.konrad@greensocs.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1354295530-18644-1-git-send-email-fred.konrad@greensocs.com> References: <1354295530-18644-1-git-send-email-fred.konrad@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 87.106.252.221 Cc: peter.maydell@linaro.org, aliguori@us.ibm.com, e.voevodin@samsung.com, mark.burton@greensocs.com, stefanha@redhat.com, cornelia.huck@de.ibm.com, afaerber@suse.de, fred.konrad@greensocs.com Subject: [Qemu-devel] [RFC PATCH V4 4/6] virtio-pci : Introduce virtio-pci device. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: KONRAD Frederic Signed-off-by: KONRAD Frederic --- hw/virtio-pci.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++- hw/virtio-pci.h | 15 +++++++++++++++ 2 files changed, 62 insertions(+), 1 deletions(-) diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index a73704d..1fb1905 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -1119,6 +1119,52 @@ static TypeInfo virtio_scsi_info = { .class_init = virtio_scsi_class_init, }; +/* + * virtio-pci : This is the PCIDevice which have a virtio-pci-bus. + */ + +static int virtio_pci_init(PCIDevice *pci_dev) +{ + VirtIOPCIProxy *dev = VIRTIO_PCI(pci_dev); + dev->bus = virtio_pci_bus_new(dev); + return 0; +} + +static void virtio_pci_exit(PCIDevice *pci_dev) +{ + VirtIOPCIProxy *dev = VIRTIO_PCI(pci_dev); + /* + * TODO: + * -> Destroy the bus. + * -> Destroy the device. + * + */ +} + +static void virtio_pci_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); + + k->init = virtio_pci_init; + k->exit = virtio_pci_exit; + /* + k->exit = virtio_scsi_exit_pci; + k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET; + k->device_id = PCI_DEVICE_ID_VIRTIO_SCSI; + k->revision = 0x00; + k->class_id = PCI_CLASS_STORAGE_SCSI; + dc->reset = virtio_pci_reset; + dc->props = virtio_scsi_properties;*/ +} + +static const TypeInfo virtio_pci_info = { + .name = TYPE_VIRTIO_PCI, + .parent = TYPE_PCI_DEVICE, + .instance_size = sizeof(VirtIOPCIProxy), + .class_init = virtio_pci_class_init, +}; + /* virtio-pci-bus */ VirtioBusState *virtio_pci_bus_new(VirtIOPCIProxy *dev) @@ -1154,7 +1200,7 @@ static void virtio_pci_bus_class_init(ObjectClass *klass, void *data) */ } -static TypeInfo virtio_pci_bus_info = { +static const TypeInfo virtio_pci_bus_info = { .name = TYPE_VIRTIO_PCI_BUS, .parent = TYPE_VIRTIO_BUS, .instance_size = sizeof(VirtioBusState), diff --git a/hw/virtio-pci.h b/hw/virtio-pci.h index 0e3288e..62c9198 100644 --- a/hw/virtio-pci.h +++ b/hw/virtio-pci.h @@ -46,6 +46,17 @@ typedef struct { unsigned int users; } VirtIOIRQFD; +/* + * virtio-pci : This is the PCIDevice which have a virtio-pci-bus. + */ +#define TYPE_VIRTIO_PCI "virtio-pci" +#define VIRTIO_PCI_GET_CLASS(obj) \ + OBJECT_GET_CLASS(VirtioPCIClass, obj, TYPE_VIRTIO_PCI) +#define VIRTIO_PCI_CLASS(klass) \ + OBJECT_CLASS_CHECK(VirtioPCIClass, klass, TYPE_VIRTIO_PCI) +#define VIRTIO_PCI(obj) \ + OBJECT_CHECK(VirtIOPCIProxy, (obj), TYPE_VIRTIO_PCI) + struct VirtIOPCIProxy { PCIDevice pci_dev; VirtIODevice *vdev; @@ -66,6 +77,10 @@ struct VirtIOPCIProxy { bool ioeventfd_disabled; bool ioeventfd_started; VirtIOIRQFD *vector_irqfd; + + /* That's the virtio-bus on which VirtioDevice will be connected. */ + VirtioBusState *bus; + /* Nothing more for the moment. */ }; void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev);