summaryrefslogtreecommitdiff
path: root/hw/virtio-net.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2009-10-21 15:25:35 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-10-27 12:28:40 -0500
commit97b156213e0e38b29da4480a32d4ec33d14d3012 (patch)
tree051ed08c9332b8d80e852051176d0b28228eae03 /hw/virtio-net.c
parent254111ecc80501a7d5c0e82f78bfa5ca8749ae20 (diff)
downloadqemu-97b156213e0e38b29da4480a32d4ec33d14d3012.zip
virtio: use qdev properties for configuration.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/virtio-net.c')
-rw-r--r--hw/virtio-net.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 218f985037..0a8d2aa859 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -700,20 +700,10 @@ static void virtio_net_cleanup(VLANClientState *vc)
{
VirtIONet *n = vc->opaque;
- qemu_purge_queued_packets(vc);
-
- unregister_savevm("virtio-net", n);
-
- qemu_free(n->mac_table.macs);
- qemu_free(n->vlans);
-
- qemu_del_timer(n->tx_timer);
- qemu_free_timer(n->tx_timer);
-
- virtio_cleanup(&n->vdev);
+ n->vc = NULL;
}
-VirtIODevice *virtio_net_init(DeviceState *dev)
+VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf)
{
VirtIONet *n;
static int virtio_net_id;
@@ -731,15 +721,16 @@ VirtIODevice *virtio_net_init(DeviceState *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, 64, virtio_net_handle_ctrl);
- qdev_get_macaddr(dev, n->mac);
+ qemu_macaddr_default_if_unset(&conf->macaddr);
n->status = VIRTIO_NET_S_LINK_UP;
- n->vc = qdev_get_vlan_client(dev,
+ n->vc = qemu_new_vlan_client(NET_CLIENT_TYPE_NIC, conf->vlan, conf->peer,
+ dev->info->name, dev->id,
virtio_net_can_receive,
- virtio_net_receive, NULL,
+ virtio_net_receive, NULL, NULL,
virtio_net_cleanup, n);
n->vc->link_status_changed = virtio_net_set_link_status;
- qemu_format_nic_info_str(n->vc, n->mac);
+ qemu_format_nic_info_str(n->vc, conf->macaddr.a);
n->tx_timer = qemu_new_timer(vm_clock, virtio_net_tx_timer, n);
n->tx_timer_active = 0;
@@ -749,13 +740,27 @@ VirtIODevice *virtio_net_init(DeviceState *dev)
n->mac_table.macs = qemu_mallocz(MAC_TABLE_ENTRIES * ETH_ALEN);
n->vlans = qemu_mallocz(MAX_VLAN >> 3);
- if (dev->nd->nvectors == NIC_NVECTORS_UNSPECIFIED)
- n->vdev.nvectors = 3;
- else
- n->vdev.nvectors = dev->nd->nvectors;
register_savevm("virtio-net", virtio_net_id++, VIRTIO_NET_VM_VERSION,
virtio_net_save, virtio_net_load, n);
return &n->vdev;
}
+
+void virtio_net_exit(VirtIODevice *vdev)
+{
+ VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev);
+
+ qemu_purge_queued_packets(n->vc);
+
+ unregister_savevm("virtio-net", n);
+
+ qemu_free(n->mac_table.macs);
+ qemu_free(n->vlans);
+
+ qemu_del_timer(n->tx_timer);
+ qemu_free_timer(n->tx_timer);
+
+ virtio_cleanup(&n->vdev);
+ qemu_del_vlan_client(n->vc);
+}