virtio-pci: refactor virtio-pci device.

Create the virtio-pci device which is abstract. This transport device will
create a virtio-pci-bus, so one VirtIODevice can be connected.

Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
KONRAD Frederic 2013-01-15 00:08:04 +01:00 committed by Anthony Liguori
parent 0a2acf5eb3
commit 085bccb72c
2 changed files with 139 additions and 2 deletions

View file

@ -23,6 +23,8 @@
#include "virtio-scsi.h"
#include "virtio-bus.h"
typedef struct VirtIOPCIProxy VirtIOPCIProxy;
/* virtio-pci-bus */
typedef struct VirtioBusState VirtioPCIBusState;
@ -47,7 +49,23 @@ typedef struct {
unsigned int users;
} VirtIOIRQFD;
typedef struct {
/*
* virtio-pci: This is the PCIDevice which has 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)
typedef struct VirtioPCIClass {
PCIDeviceClass parent_class;
int (*init)(VirtIOPCIProxy *vpci_dev);
} VirtioPCIClass;
struct VirtIOPCIProxy {
PCIDevice pci_dev;
VirtIODevice *vdev;
MemoryRegion bar;
@ -68,7 +86,8 @@ typedef struct {
bool ioeventfd_started;
VirtIOIRQFD *vector_irqfd;
int nvqs_with_notifiers;
} VirtIOPCIProxy;
VirtioBusState bus;
};
void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev);
void virtio_pci_reset(DeviceState *d);