mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-01 23:03:54 -06:00
Introduce VLANClientState::cleanup() (Mark McLoughlin)
We're currently leaking memory and file descriptors on device hot-unplug. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7150 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
32a8f6ae93
commit
b946a15332
19 changed files with 347 additions and 66 deletions
|
@ -570,6 +570,21 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void virtio_net_cleanup(VLANClientState *vc)
|
||||
{
|
||||
VirtIONet *n = vc->opaque;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn)
|
||||
{
|
||||
VirtIONet *n;
|
||||
|
@ -598,7 +613,9 @@ PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn)
|
|||
memcpy(n->mac, nd->macaddr, ETH_ALEN);
|
||||
n->status = VIRTIO_NET_S_LINK_UP;
|
||||
n->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
|
||||
virtio_net_receive, virtio_net_can_receive, n);
|
||||
virtio_net_receive,
|
||||
virtio_net_can_receive,
|
||||
virtio_net_cleanup, n);
|
||||
n->vc->link_status_changed = virtio_net_set_link_status;
|
||||
|
||||
qemu_format_nic_info_str(n->vc, n->mac);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue