aboutsummaryrefslogtreecommitdiff
path: root/hw/virtio-net.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/virtio-net.c')
-rw-r--r--hw/virtio-net.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 3764170437..60aa6dab1b 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -585,18 +585,14 @@ static void virtio_net_cleanup(VLANClientState *vc)
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 @@ static void virtio_net_init(PCIDevice *pci_dev)
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 @@ static void virtio_net_init(PCIDevice *pci_dev)
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)