mirror of
https://github.com/mii443/qemu.git
synced 2025-08-25 08:29:25 +00: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/branches/stable_0_10@7160 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
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);
|
||||
|
||||
|
Reference in New Issue
Block a user