From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LuSum-0007Sn-Q7 for qemu-devel@nongnu.org; Thu, 16 Apr 2009 10:50:08 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LuSuh-0007SN-C2 for qemu-devel@nongnu.org; Thu, 16 Apr 2009 10:50:07 -0400 Received: from [199.232.76.173] (port=46820 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LuSuh-0007SI-3j for qemu-devel@nongnu.org; Thu, 16 Apr 2009 10:50:03 -0400 Received: from mx2.redhat.com ([66.187.237.31]:58711) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LuSug-0008LD-Lo for qemu-devel@nongnu.org; Thu, 16 Apr 2009 10:50:02 -0400 From: Mark McLoughlin In-Reply-To: <49E61A9D.2060605@siemens.com> References: <1239812969-8320-1-git-send-email-markmc@redhat.com> <1239812969-8320-2-git-send-email-markmc@redhat.com> <1239812969-8320-3-git-send-email-markmc@redhat.com> <1239812969-8320-4-git-send-email-markmc@redhat.com> <1239812969-8320-5-git-send-email-markmc@redhat.com> <1239812969-8320-6-git-send-email-markmc@redhat.com> <1239812969-8320-7-git-send-email-markmc@redhat.com> <1239812969-8320-8-git-send-email-markmc@redhat.com> <1239812969-8320-9-git-send-email-markmc@redhat.com> <1239812969-8320-10-git-send-email-markmc@redhat.com> <49E61A9D.2060605@siemens.com> Content-Type: text/plain Date: Thu, 16 Apr 2009 15:49:55 +0100 Message-Id: <1239893395.6860.189.camel@blaa> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 9/9] Introduce VLANClientState::cleanup() Reply-To: Mark McLoughlin , qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Kiszka Cc: Anthony Liguori , qemu-devel@nongnu.org Hi Jan, On Wed, 2009-04-15 at 19:34 +0200, Jan Kiszka wrote: > Mark McLoughlin wrote: > > @@ -1095,12 +1095,12 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn) > > > > d->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, > > e1000_receive, e1000_can_receive, d); > > + d->vc->cleanup = e1000_cleanup; > > Just to leave my comment here as well :) : I still consider this an > important, mostly required callback that should be lifted into > qemu_new_vlan_client(). That way, everyone who thinks (s)he doesn't need > it will have to explicitly null'ify it. I still think this is terribly ugly, but I'll add the argument to new_vlan_client() until I can fix the ugliness more comprehensively :-) > qemu_format_nic_info_str(n->vc, n->mac); > > diff --git a/net.c b/net.c > > index 34ec4c8..1378ea8 100644 > > --- a/net.c > > +++ b/net.c > > @@ -362,6 +362,8 @@ void qemu_del_vlan_client(VLANClientState *vc) > > while (*pvc != NULL) > > if (*pvc == vc) { > > *pvc = vc->next; > > + if (vc->cleanup) > > + vc->cleanup(vc); > > free(vc->name); > > free(vc->model); > > free(vc); > > That should become qemu_free(vc) at this chance. The rest should be > strdup-allocated. I'll queue that up as a separate patch. ... > > @@ -748,6 +752,18 @@ static void tap_send(void *opaque) > > } > > } > > > > +static void tap_cleanup(VLANClientState *vc) > > +{ > > + TAPState *s = vc->opaque; > > + > > + if (s->down_script[0]) > > + launch_script(s->down_script, s->down_script_arg, s->fd); > > + > > + qemu_set_fd_handler(s->fd, NULL, NULL, NULL); > > + close(s->fd); > > + free(s); > > free -> qemu_free Thanks; I had spotted this and forgot to fix it before posting. Cheers, Mark.