[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] net: move rxfilter_notify() to net.c
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH] net: move rxfilter_notify() to net.c |
Date: |
Fri, 15 Nov 2013 16:27:17 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
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