From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57305) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ViOQn-0002Oc-7Q for qemu-devel@nongnu.org; Mon, 18 Nov 2013 08:00:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ViOQh-00086D-8B for qemu-devel@nongnu.org; Mon, 18 Nov 2013 07:59:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35779) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ViOQg-000864-Ut for qemu-devel@nongnu.org; Mon, 18 Nov 2013 07:59:51 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rAICxnmv019824 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 18 Nov 2013 07:59:49 -0500 Date: Mon, 18 Nov 2013 20:59:46 +0800 From: Amos Kong Message-ID: <20131118125946.GA20192@amosk.info> References: <1383649248-13854-1-git-send-email-akong@redhat.com> <20131115152717.GA26518@stefanha-thinkpad.redhat.com> <52865097.1050505@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <52865097.1050505@redhat.com> Subject: Re: [Qemu-devel] [PATCH] net: move rxfilter_notify() to net.c List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vlad Yasevich Cc: qemu-devel@nongnu.org On Fri, Nov 15, 2013 at 11:49:27AM -0500, Vlad Yasevich wrote: > On 11/15/2013 10:27 AM, Stefan Hajnoczi wrote: > >On Tue, Nov 05, 2013 at 07:00:48PM +0800, Amos Kong wrote: > >>@@ -545,7 +523,7 @@ static int virtio_net_handle_rx_mode(VirtIONet *n, uint8_t cmd, > >> return VIRTIO_NET_ERR; > >> } > >> > >>- rxfilter_notify(nc); > >>+ rxfilter_notify(nc, object_get_canonical_path(OBJECT(n->qdev))); > >> > >> return VIRTIO_NET_OK; > >> } > >[...] > >>diff --git a/net/net.c b/net/net.c > >>index c330c9a..f41a457 100644 > >>--- a/net/net.c > >>+++ b/net/net.c > >>@@ -40,6 +40,7 @@ > >> #include "qapi-visit.h" > >> #include "qapi/opts-visitor.h" > >> #include "qapi/dealloc-visitor.h" > >>+#include "qapi/qmp/qjson.h" > >> > >> /* Net bridge is currently not supported for W32. */ > >> #if !defined(_WIN32) > >>@@ -962,6 +963,25 @@ void print_net_client(Monitor *mon, NetClientState *nc) > >> nc->info_str); > >> } > >> > >>+void rxfilter_notify(NetClientState *nc, const char *path) > >>+{ > >>+ QObject *event_data; > >>+ > >>+ if (nc->rxfilter_notify_enabled) { > >>+ if (nc->name) { > >>+ event_data = qobject_from_jsonf("{ 'name': %s, 'path': %s }", > >>+ nc->name, path); > >>+ } else { > >>+ event_data = qobject_from_jsonf("{ 'path': %s }", path); > >>+ } > >>+ monitor_protocol_event(QEVENT_NIC_RX_FILTER_CHANGED, event_data); > >>+ qobject_decref(event_data); > >>+ > >>+ /* disable event notification to avoid events flooding */ > >>+ nc->rxfilter_notify_enabled = 0; > >>+ } > >>+} > > > >Please fix the memory leak: > >object_get_canonical_path() returns a gchar* that the caller must free. > Wow, this memory leak is all over the place and not just in this patch. Yes, my v2 fix the memory leak in rxfilter_notify(). I just check the code, your patch fixed _the last_ leak of object_get_canonical_path(). Thanks. > -vlad -- Amos.