Separate virtio PCI code

Split the PCI host bindings from the VRing transport implementation.

Signed-off-by: Paul Brook <paul@codesourcery.com>
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 3764170..60aa6da 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -585,18 +585,14 @@
     virtio_cleanup(&n->vdev);
 }
 
-static void virtio_net_init(PCIDevice *pci_dev)
+VirtIODevice *virtio_net_init(DeviceState *dev)
 {
     VirtIONet *n;
     static int virtio_net_id;
 
-    n = (VirtIONet *)virtio_init_pci(pci_dev, "virtio-net",
-                                     PCI_VENDOR_ID_REDHAT_QUMRANET,
-                                     PCI_DEVICE_ID_VIRTIO_NET,
-                                     PCI_VENDOR_ID_REDHAT_QUMRANET,
-                                     VIRTIO_ID_NET,
-                                     PCI_CLASS_NETWORK_ETHERNET, 0x00,
-                                     sizeof(struct virtio_net_config));
+    n = (VirtIONet *)virtio_common_init("virtio-net", VIRTIO_ID_NET,
+                                        sizeof(struct virtio_net_config),
+                                        sizeof(VirtIONet));
 
     n->vdev.get_config = virtio_net_get_config;
     n->vdev.set_config = virtio_net_set_config;
@@ -607,9 +603,9 @@
     n->rx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_rx);
     n->tx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_tx);
     n->ctrl_vq = virtio_add_queue(&n->vdev, 16, virtio_net_handle_ctrl);
-    qdev_get_macaddr(&pci_dev->qdev, n->mac);
+    qdev_get_macaddr(dev, n->mac);
     n->status = VIRTIO_NET_S_LINK_UP;
-    n->vc = qdev_get_vlan_client(&pci_dev->qdev,
+    n->vc = qdev_get_vlan_client(dev,
                                  virtio_net_receive,
                                  virtio_net_can_receive,
                                  virtio_net_cleanup, n);
@@ -628,11 +624,6 @@
 
     register_savevm("virtio-net", virtio_net_id++, VIRTIO_NET_VM_VERSION,
                     virtio_net_save, virtio_net_load, n);
-}
 
-static void virtio_net_register_devices(void)
-{
-    pci_qdev_register("virtio_net", sizeof(VirtIONet), virtio_net_init);
+    return &n->vdev;
 }
-
-device_init(virtio_net_register_devices)