From: fred.konrad@greensocs.com
To: qemu-devel@nongnu.org
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 PATCH V8 03/15] virtio-pci-bus : Introduce virtio-pci-bus.
Date: Wed, 19 Dec 2012 10:53:29 +0100 [thread overview]
Message-ID: <1355910821-21302-4-git-send-email-fred.konrad@greensocs.com> (raw)
In-Reply-To: <1355910821-21302-1-git-send-email-fred.konrad@greensocs.com>
From: KONRAD Frederic <fred.konrad@greensocs.com>
Introduce virtio-pci-bus, which extends virtio-bus. It is used with virtio-pci
transport device.
Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
---
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 7684ac9..859a1ed 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -32,6 +32,7 @@
#include "blockdev.h"
#include "virtio-pci.h"
#include "range.h"
+#include "virtio-bus.h"
/* from Linux's linux/virtio_pci.h */
@@ -1117,6 +1118,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);
@@ -1125,6 +1161,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);
--
1.7.11.7
next prev parent reply other threads:[~2012-12-19 9:53 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-19 9:53 [Qemu-devel] [RFC PATCH V8 00/15] Virtio refactoring fred.konrad
2012-12-19 9:53 ` [Qemu-devel] [RFC PATCH V8 01/15] qdev : add a maximum device allowed field for the bus fred.konrad
2013-01-02 14:08 ` Anthony Liguori
2013-01-02 14:16 ` Andreas Färber
2013-01-02 14:30 ` KONRAD Frédéric
2013-01-03 14:03 ` KONRAD Frédéric
2012-12-19 9:53 ` [Qemu-devel] [RFC PATCH V8 02/15] virtio-bus : Introduce virtio-bus fred.konrad
2013-01-02 14:12 ` Anthony Liguori
2013-01-03 9:57 ` KONRAD Frédéric
2012-12-19 9:53 ` fred.konrad [this message]
2013-01-02 14:12 ` [Qemu-devel] [RFC PATCH V8 03/15] virtio-pci-bus : Introduce virtio-pci-bus Anthony Liguori
2012-12-19 9:53 ` [Qemu-devel] [RFC PATCH V8 04/15] virtio-pci : Refactor virtio-pci device fred.konrad
2012-12-19 19:53 ` Blue Swirl
2013-01-02 14:14 ` Anthony Liguori
2013-01-02 14:17 ` KONRAD Frédéric
2012-12-19 9:53 ` [Qemu-devel] [RFC PATCH V8 05/15] virtio-device : Refactor virtio-device fred.konrad
2013-01-02 14:15 ` Anthony Liguori
2012-12-19 9:53 ` [Qemu-devel] [RFC PATCH V8 06/15] virtio-s390-bus : Add virtio-s390-bus fred.konrad
2012-12-19 18:09 ` Cornelia Huck
2012-12-20 8:03 ` KONRAD Frédéric
2012-12-19 9:53 ` [Qemu-devel] [RFC PATCH V8 07/15] virtio-s390-device : create a virtio-s390-bus during init fred.konrad
2012-12-19 9:53 ` [Qemu-devel] [RFC PATCH V8 08/15] virtio-blk : Add the virtio-blk device fred.konrad
2012-12-19 20:00 ` Blue Swirl
2012-12-19 23:22 ` Peter Maydell
2012-12-19 9:53 ` [Qemu-devel] [RFC PATCH V8 09/15] virtio-blk-pci : Switch to new API fred.konrad
2013-01-02 14:18 ` Anthony Liguori
2012-12-19 9:53 ` [Qemu-devel] [RFC PATCH V8 10/15] virtio-blk-s390 : Switch to the " fred.konrad
2012-12-19 9:53 ` [Qemu-devel] [RFC PATCH V8 11/15] virtio-blk : cleanup : use QOM cast fred.konrad
2012-12-19 9:53 ` [Qemu-devel] [RFC PATCH V8 12/15] virtio-blk : cleanup : remove qdev field fred.konrad
2012-12-19 9:53 ` [Qemu-devel] [RFC PATCH V8 13/15] virtio : Remove the function pointer fred.konrad
2012-12-19 19:50 ` Blue Swirl
2012-12-20 8:02 ` KONRAD Frédéric
2012-12-19 9:53 ` [Qemu-devel] [RFC PATCH V8 14/15] virtio : Remove VirtIOBindings fred.konrad
2012-12-19 19:54 ` Blue Swirl
2012-12-19 9:53 ` [Qemu-devel] [RFC PATCH V8 15/15] virtio : cleanup : init and exit function fred.konrad
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1355910821-21302-4-git-send-email-fred.konrad@greensocs.com \
--to=fred.konrad@greensocs.com \
--cc=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=aliguori@us.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=e.voevodin@samsung.com \
--cc=mark.burton@greensocs.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).