diff options
author | aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162> | 2009-04-17 18:06:56 +0000 |
---|---|---|
committer | aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162> | 2009-04-17 18:06:56 +0000 |
commit | a34b6eb776fbd357fb0dfbdbfa680b4f54e12a4c (patch) | |
tree | 8bd5b118f5e89f6c2101057eb25a73bb4e1e15c4 /hw/mipsnet.c | |
parent | 1ed3d07a22ab918037379b21e92090a7072707bf (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/branches/stable_0_10@7160 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw/mipsnet.c')
-rw-r--r-- | hw/mipsnet.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/hw/mipsnet.c b/hw/mipsnet.c index 415b04e2ce..e842984219 100644 --- a/hw/mipsnet.c +++ b/hw/mipsnet.c @@ -33,6 +33,7 @@ typedef struct MIPSnetState { uint32_t intctl; uint8_t rx_buffer[MAX_ETH_FRAME_SIZE]; uint8_t tx_buffer[MAX_ETH_FRAME_SIZE]; + int io_base; qemu_irq irq; VLANClientState *vc; } MIPSnetState; @@ -231,6 +232,17 @@ static int mipsnet_load(QEMUFile *f, void *opaque, int version_id) return 0; } +static void mipsnet_cleanup(VLANClientState *vc) +{ + MIPSnetState *s = vc->opaque; + + unregister_savevm("mipsnet", s); + + isa_unassign_ioport(s->io_base, 36); + + qemu_free(s); +} + void mipsnet_init (int base, qemu_irq irq, NICInfo *nd) { MIPSnetState *s; @@ -246,10 +258,12 @@ void mipsnet_init (int base, qemu_irq irq, NICInfo *nd) register_ioport_write(base, 36, 4, mipsnet_ioport_write, s); register_ioport_read(base, 36, 4, mipsnet_ioport_read, s); + s->io_base = base; s->irq = irq; if (nd && nd->vlan) { s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, - mipsnet_receive, mipsnet_can_receive, s); + mipsnet_receive, mipsnet_can_receive, + mipsnet_cleanup, s); } else { s->vc = NULL; } |