[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] net: remove all cleanup methods from NIC NetCli
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH] net: remove all cleanup methods from NIC NetClientInfos |
Date: |
Fri, 2 Jan 2015 14:00:52 +0000 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Tue, Dec 23, 2014 at 05:53:19PM +0100, Paolo Bonzini wrote:
> All NICs have a cleanup function that, in most cases, zeroes the pointer
> to the NICState. In some cases, it frees data belonging to the NIC.
>
> However, this function is never called except when exiting from QEMU.
> It is not necessary to NULL pointers and free data here; the right place
> to do that would be in the device's unrealize function, after calling
> qemu_del_nic. Zeroing the NIC multiple times is also wrong for multiqueue
> devices.
>
> This cleanup function gets in the way of making the NetClientStates for
> the NIC hold an object_ref reference to the object, so get rid of it.
This patch does not drop NetClientInfo->cleanup() and clean up net.c.
Do you have plans for a follow-up patch?
> diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c
> index 7eab7ad..7ce13d2 100644
> --- a/hw/net/dp8393x.c
> +++ b/hw/net/dp8393x.c
> @@ -859,22 +859,11 @@ static void nic_reset(void *opaque)
> dp8393x_update_irq(s);
> }
>
> -static void nic_cleanup(NetClientState *nc)
> -{
> - dp8393xState *s = qemu_get_nic_opaque(nc);
> -
> - timer_del(s->watchdog);
> - timer_free(s->watchdog);
> -
> - g_free(s);
> -}
How about moving code that frees resources to unrealize?
There are a couple of instances in this patch where we drop g_free() and
it's a shame to lose the resource management life cycle completely.
pgpdVxNvA2MIQ.pgp
Description: PGP signature
- Re: [Qemu-devel] [PATCH] net: remove all cleanup methods from NIC NetClientInfos,
Stefan Hajnoczi <=