On 7 January 2013 18:40, <address@hidden> wrote:
From: KONRAD Frederic <address@hidden>
Create the virtio-pci device. This transport device will create a
virtio-pci-bus, so one VirtIODevice can be connected.
Signed-off-by: KONRAD Frederic <address@hidden>
---
hw/virtio-pci.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
hw/virtio-pci.h | 18 ++++++++
2 files changed, 145 insertions(+)
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 5ff03e8..1f0ecbe 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -1163,6 +1163,130 @@ static TypeInfo virtio_scsi_info = {
.class_init = virtio_scsi_class_init,
};
+/*
+ * virtio-pci : This is the PCIDevice which have a virtio-pci-bus.
"has"
+ */
+
+/* This is called by virtio-bus just after the device is plugged. */
+static void virtio_pci_device_plugged(DeviceState *d)
+{
+ VirtIOPCIProxy *proxy = VIRTIO_PCI(d);
+ VirtioBusState *bus = proxy->bus;
+ uint8_t *config;
+ uint32_t size;
+
+ /* Put the PCI IDs */
+ switch (virtio_device_get_id(proxy->bus)) {
+
+
+ default:
+ error_report("unknown device id\n");
+ break;
+
+ }
This doesn't have any code in it yet (it gets added in later patches) but
the final result looks very repetitive. I think you'd be better off just having
some arrays:
uint16_t virtio_pci_device_id[] = {
[VIRTIO_ID_BLOCK] = PCI_DEVICE_ID_VIRTIO_BLOCK,
[VIRTIO_ID_NET] = PCI_DEVICE_ID_VIRTIO_NET,
(etc)
};
similarly for the class. Then you can just drop the switch statement.
In fact I think you might as well put in the array entries for all
the virtio devices in this patch rather than adding one in each of the
"add virtio-foo device" patches; it will do no harm for them to be
there early and it makes the later patches a little smaller.