aboutsummaryrefslogtreecommitdiff
path: root/hw/virtio-net.c
diff options
context:
space:
mode:
authorPaul Brook <paul@codesourcery.com>2009-05-14 22:35:07 +0100
committerPaul Brook <paul@codesourcery.com>2009-05-14 22:35:07 +0100
commitcf21e106cd9b34a12a533191932a8a08a1f5ebe4 (patch)
treeab36cc019c2ff8908586a7fcb12b869ccb76cc46 /hw/virtio-net.c
parent9d07d7579bcaf01e05c511c63d091ed2ac310091 (diff)
downloadqemu-cf21e106cd9b34a12a533191932a8a08a1f5ebe4.zip
qemu-cf21e106cd9b34a12a533191932a8a08a1f5ebe4.tar.gz
qemu-cf21e106cd9b34a12a533191932a8a08a1f5ebe4.tar.bz2
Virtio-net qdev conversion
Signed-off-by: Paul Brook <paul@codesourcery.com>
Diffstat (limited to 'hw/virtio-net.c')
-rw-r--r--hw/virtio-net.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index f9717c0..3764170 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -585,21 +585,18 @@ static void virtio_net_cleanup(VLANClientState *vc)
virtio_cleanup(&n->vdev);
}
-PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn)
+static void virtio_net_init(PCIDevice *pci_dev)
{
VirtIONet *n;
static int virtio_net_id;
- n = (VirtIONet *)virtio_init_pci(bus, "virtio-net",
+ 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),
- sizeof(VirtIONet));
- if (!n)
- return NULL;
+ sizeof(struct virtio_net_config));
n->vdev.get_config = virtio_net_get_config;
n->vdev.set_config = virtio_net_set_config;
@@ -610,9 +607,9 @@ PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn)
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);
- memcpy(n->mac, nd->macaddr, ETH_ALEN);
+ qdev_get_macaddr(&pci_dev->qdev, n->mac);
n->status = VIRTIO_NET_S_LINK_UP;
- n->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
+ n->vc = qdev_get_vlan_client(&pci_dev->qdev,
virtio_net_receive,
virtio_net_can_receive,
virtio_net_cleanup, n);
@@ -631,5 +628,11 @@ PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn)
register_savevm("virtio-net", virtio_net_id++, VIRTIO_NET_VM_VERSION,
virtio_net_save, virtio_net_load, n);
- return (PCIDevice *)n;
}
+
+static void virtio_net_register_devices(void)
+{
+ pci_qdev_register("virtio_net", sizeof(VirtIONet), virtio_net_init);
+}
+
+device_init(virtio_net_register_devices)