From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37342) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VhMaQ-0000XR-3F for qemu-devel@nongnu.org; Fri, 15 Nov 2013 11:49:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VhMaI-0004mb-FX for qemu-devel@nongnu.org; Fri, 15 Nov 2013 11:49:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48206) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VhMaI-0004mC-7M for qemu-devel@nongnu.org; Fri, 15 Nov 2013 11:49:30 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rAFGnS01027871 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 15 Nov 2013 11:49:28 -0500 Message-ID: <52865097.1050505@redhat.com> Date: Fri, 15 Nov 2013 11:49:27 -0500 From: Vlad Yasevich MIME-Version: 1.0 References: <1383649248-13854-1-git-send-email-akong@redhat.com> <20131115152717.GA26518@stefanha-thinkpad.redhat.com> In-Reply-To: <20131115152717.GA26518@stefanha-thinkpad.redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] net: move rxfilter_notify() to net.c Reply-To: vyasevic@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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. -vlad