mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 07:13: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
14
hw/usb-net.c
14
hw/usb-net.c
|
@ -1415,14 +1415,20 @@ static int usbnet_can_receive(void *opaque)
|
|||
return !s->in_len;
|
||||
}
|
||||
|
||||
static void usbnet_cleanup(VLANClientState *vc)
|
||||
{
|
||||
USBNetState *s = vc->opaque;
|
||||
|
||||
rndis_clear_responsequeue(s);
|
||||
qemu_free(s);
|
||||
}
|
||||
|
||||
static void usb_net_handle_destroy(USBDevice *dev)
|
||||
{
|
||||
USBNetState *s = (USBNetState *) dev;
|
||||
|
||||
/* TODO: remove the nd_table[] entry */
|
||||
qemu_del_vlan_client(s->vc);
|
||||
rndis_clear_responsequeue(s);
|
||||
qemu_free(s);
|
||||
}
|
||||
|
||||
USBDevice *usb_net_init(NICInfo *nd)
|
||||
|
@ -1452,7 +1458,9 @@ USBDevice *usb_net_init(NICInfo *nd)
|
|||
pstrcpy(s->dev.devname, sizeof(s->dev.devname),
|
||||
"QEMU USB Network Interface");
|
||||
s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
|
||||
usbnet_receive, usbnet_can_receive, s);
|
||||
usbnet_receive,
|
||||
usbnet_can_receive,
|
||||
usbnet_cleanup, s);
|
||||
|
||||
qemu_format_nic_info_str(s->vc, s->mac);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue