mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06: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/trunk@7150 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
32a8f6ae93
commit
b946a15332
19 changed files with 347 additions and 66 deletions
|
@ -69,6 +69,7 @@ typedef struct {
|
|||
VLANClientState *vc;
|
||||
qemu_irq irq;
|
||||
uint8_t macaddr[6];
|
||||
int mmio_index;
|
||||
} stellaris_enet_state;
|
||||
|
||||
static void stellaris_enet_update(stellaris_enet_state *s)
|
||||
|
@ -384,23 +385,35 @@ static int stellaris_enet_load(QEMUFile *f, void *opaque, int version_id)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void stellaris_enet_cleanup(VLANClientState *vc)
|
||||
{
|
||||
stellaris_enet_state *s = vc->opaque;
|
||||
|
||||
unregister_savevm("stellaris_enet", s);
|
||||
|
||||
cpu_unregister_io_memory(s->mmio_index);
|
||||
|
||||
qemu_free(s);
|
||||
}
|
||||
|
||||
void stellaris_enet_init(NICInfo *nd, uint32_t base, qemu_irq irq)
|
||||
{
|
||||
stellaris_enet_state *s;
|
||||
int iomemtype;
|
||||
|
||||
qemu_check_nic_model(nd, "stellaris");
|
||||
|
||||
s = (stellaris_enet_state *)qemu_mallocz(sizeof(stellaris_enet_state));
|
||||
iomemtype = cpu_register_io_memory(0, stellaris_enet_readfn,
|
||||
stellaris_enet_writefn, s);
|
||||
cpu_register_physical_memory(base, 0x00001000, iomemtype);
|
||||
s->mmio_index = cpu_register_io_memory(0, stellaris_enet_readfn,
|
||||
stellaris_enet_writefn, s);
|
||||
cpu_register_physical_memory(base, 0x00001000, s->mmio_index);
|
||||
s->irq = irq;
|
||||
memcpy(s->macaddr, nd->macaddr, 6);
|
||||
|
||||
if (nd->vlan) {
|
||||
s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
|
||||
stellaris_enet_receive, stellaris_enet_can_receive, s);
|
||||
stellaris_enet_receive,
|
||||
stellaris_enet_can_receive,
|
||||
stellaris_enet_cleanup, s);
|
||||
qemu_format_nic_info_str(s->vc, s->macaddr);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue