aboutsummaryrefslogtreecommitdiffstats
path: root/hw/eepro100.c
diff options
context:
space:
mode:
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-04-17 17:11:08 +0000
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-04-17 17:11:08 +0000
commitb946a1533209f61a93e34898aebb5b43154b99c3 (patch)
tree36b0017910ca42cc5a41671b8edc7faa5da0a452 /hw/eepro100.c
parent32a8f6ae93f175518f86f99249177c35d1a85114 (diff)
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
Diffstat (limited to 'hw/eepro100.c')
-rw-r--r--hw/eepro100.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/hw/eepro100.c b/hw/eepro100.c
index c72b990f2..18d81153b 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -1710,6 +1710,25 @@ static void nic_save(QEMUFile * f, void *opaque)
qemu_put_buffer(f, s->configuration, sizeof(s->configuration));
}
+static void nic_cleanup(VLANClientState *vc)
+{
+ EEPRO100State *s = vc->opaque;
+
+ unregister_savevm(vc->model, s);
+
+ eeprom93xx_free(s->eeprom);
+}
+
+static int pci_nic_uninit(PCIDevice *dev)
+{
+ PCIEEPRO100State *d = (PCIEEPRO100State *) dev;
+ EEPRO100State *s = &d->eepro100;
+
+ cpu_unregister_io_memory(s->mmio_index);
+
+ return 0;
+}
+
static PCIDevice *nic_init(PCIBus * bus, NICInfo * nd, uint32_t device)
{
PCIEEPRO100State *d;
@@ -1720,6 +1739,7 @@ static PCIDevice *nic_init(PCIBus * bus, NICInfo * nd, uint32_t device)
d = (PCIEEPRO100State *) pci_register_device(bus, nd->model,
sizeof(PCIEEPRO100State), -1,
NULL, NULL);
+ d->dev.unregister = pci_nic_uninit;
s = &d->eepro100;
s->device = device;
@@ -1750,7 +1770,8 @@ static PCIDevice *nic_init(PCIBus * bus, NICInfo * nd, uint32_t device)
nic_reset(s);
s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
- nic_receive, nic_can_receive, s);
+ nic_receive, nic_can_receive,
+ nic_cleanup, s);
qemu_format_nic_info_str(s->vc, s->macaddr);