From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44193) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VhLIv-0001h5-Ti for qemu-devel@nongnu.org; Fri, 15 Nov 2013 10:27:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VhLIn-0007Qb-Bw for qemu-devel@nongnu.org; Fri, 15 Nov 2013 10:27:29 -0500 Received: from mail-we0-x22a.google.com ([2a00:1450:400c:c03::22a]:49304) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VhLIn-0007QJ-5D for qemu-devel@nongnu.org; Fri, 15 Nov 2013 10:27:21 -0500 Received: by mail-we0-f170.google.com with SMTP id p61so3746161wes.1 for ; Fri, 15 Nov 2013 07:27:20 -0800 (PST) Date: Fri, 15 Nov 2013 16:27:17 +0100 From: Stefan Hajnoczi Message-ID: <20131115152717.GA26518@stefanha-thinkpad.redhat.com> References: <1383649248-13854-1-git-send-email-akong@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1383649248-13854-1-git-send-email-akong@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: Amos Kong Cc: jasowang@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, mst@redhat.com 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. Stefan