From patchwork Thu Jan 3 14:52:15 2013 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: 209266 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 8E7A92C0089 for ; Fri, 4 Jan 2013 01:53:15 +1100 (EST) Received: from localhost ([::1]:60362 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TqmAT-0008H7-Mb for incoming@patchwork.ozlabs.org; Thu, 03 Jan 2013 09:53:13 -0500 Received: from eggs.gnu.org ([208.118.235.92]:50750) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TqmAB-00089D-9d for qemu-devel@nongnu.org; Thu, 03 Jan 2013 09:52:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TqmA7-0005TA-6r for qemu-devel@nongnu.org; Thu, 03 Jan 2013 09:52:55 -0500 Received: from greensocs.com ([87.106.252.221]:53334 helo=s15328186.onlinehome-server.info) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TqmA6-0005Su-Qs for qemu-devel@nongnu.org; Thu, 03 Jan 2013 09:52:51 -0500 Received: from localhost (unknown [127.0.0.1]) by s15328186.onlinehome-server.info (Postfix) with ESMTP id BCD4C439E35; Thu, 3 Jan 2013 14:52:49 +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 TgZ1AxG1EjMT; Thu, 3 Jan 2013 15:52:49 +0100 (CET) Received: by s15328186.onlinehome-server.info (Postfix, from userid 491) id 9455B439E38; Thu, 3 Jan 2013 15:52:46 +0100 (CET) Received: from compaq.katmai.xl.cx.katmai.xl.cx (lan31-11-83-155-143-136.fbx.proxad.net [83.155.143.136]) by s15328186.onlinehome-server.info (Postfix) with ESMTPSA id 77336439E30; Thu, 3 Jan 2013 15:52:45 +0100 (CET) From: fred.konrad@greensocs.com To: qemu-devel@nongnu.org Date: Thu, 3 Jan 2013 15:52:15 +0100 Message-Id: <1357224744-14443-4-git-send-email-fred.konrad@greensocs.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1357224744-14443-1-git-send-email-fred.konrad@greensocs.com> References: <1357224744-14443-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, agraf@suse.de, stefanha@redhat.com, cornelia.huck@de.ibm.com, afaerber@suse.de, fred.konrad@greensocs.com Subject: [Qemu-devel] [RFC V9 03/12] virtio-pci-bus : introduce virtio-pci-bus. 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 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 | 19 +++++++++++++++++-- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index d2d2454..3f14be2 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 */ @@ -1116,6 +1117,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; + /* Only one virtio-device allowed for virtio-pci. */ + qbus->max_dev = 1; + return bus; +} + +static void virtio_pci_bus_class_init(ObjectClass *klass, void *data) +{ + VirtioBusClass *k = VIRTIO_BUS_CLASS(klass); + 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(VirtioBusState), + .class_init = virtio_pci_bus_class_init, +}; + static void virtio_pci_register_types(void) { type_register_static(&virtio_blk_info); @@ -1124,6 +1160,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..0e3288e 100644 --- a/hw/virtio-pci.h +++ b/hw/virtio-pci.h @@ -20,6 +20,21 @@ #include "virtio-rng.h" #include "virtio-serial.h" #include "virtio-scsi.h" +#include "virtio-bus.h" + +/* VirtIOPCIProxy will be renammed VirtioPCIState at the end. */ +typedef struct VirtIOPCIProxy VirtIOPCIProxy; + +/* virtio-pci-bus */ +#define TYPE_VIRTIO_PCI_BUS "virtio-pci-bus" +#define VIRTIO_PCI_BUS_GET_CLASS(obj) \ + OBJECT_GET_CLASS(VirtioBusClass, obj, TYPE_VIRTIO_PCI_BUS) +#define VIRTIO_PCI_BUS_CLASS(klass) \ + OBJECT_CLASS_CHECK(VirtioBusClass, klass, TYPE_VIRTIO_PCI_BUS) +#define VIRTIO_PCI_BUS(obj) \ + OBJECT_CHECK(VirtioBusState, (obj), 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 +46,7 @@ typedef struct { unsigned int users; } VirtIOIRQFD; -typedef struct { +struct VirtIOPCIProxy { PCIDevice pci_dev; VirtIODevice *vdev; MemoryRegion bar; @@ -51,7 +66,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);