From b946a1533209f61a93e34898aebb5b43154b99c3 Mon Sep 17 00:00:00 2001 From: aliguori Date: Fri, 17 Apr 2009 17:11:08 +0000 Subject: Introduce VLANClientState::cleanup() (Mark McLoughlin) We're currently leaking memory and file descriptors on device hot-unplug. Signed-off-by: Mark McLoughlin Signed-off-by: Anthony Liguori git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7150 c046a42c-6fe2-441c-8c8c-71466251a162 --- hw/mipsnet.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'hw/mipsnet.c') 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; } -- cgit v1.2.3