mirror of
https://github.com/mii443/qemu.git
synced 2025-08-26 17:10:08 +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:
16
hw/mipsnet.c
16
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user