From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:60287) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UdFGT-0000n8-2e for qemu-devel@nongnu.org; Fri, 17 May 2013 03:39:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UdFGI-0003eM-V4 for qemu-devel@nongnu.org; Fri, 17 May 2013 03:39:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31345) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UdFGI-0003e9-Kz for qemu-devel@nongnu.org; Fri, 17 May 2013 03:39:34 -0400 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 r4H7dX2A030503 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 17 May 2013 03:39:33 -0400 Date: Fri, 17 May 2013 09:39:31 +0200 From: Stefan Hajnoczi Message-ID: <20130517073931.GC4669@stefanha-thinkpad.redhat.com> References: <1368702445-30733-1-git-send-email-akong@redhat.com> <1368702445-30733-3-git-send-email-akong@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1368702445-30733-3-git-send-email-akong@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2 2/2] net: introduce command to query mac-table information List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amos Kong Cc: lcapitulino@redhat.com, qemu-devel@nongnu.org, mst@redhat.com On Thu, May 16, 2013 at 07:07:25PM +0800, Amos Kong wrote: > @@ -961,6 +961,44 @@ void print_net_client(Monitor *mon, NetClientState *nc) > nc->info_str); > } > > +MacTableInfoList *qmp_query_mac_table(bool has_name, const char *name, > + Error **errp) > +{ > + NetClientState *nc; > + MacTableInfoList *table_list = NULL, *last_entry = NULL; > + > + QTAILQ_FOREACH(nc, &net_clients, next) { > + MacTableInfoList *entry; > + MacTableInfo *info; > + > + if (nc->info->type != NET_CLIENT_OPTIONS_KIND_NIC) { > + continue; > + } > + if (has_name && strcmp(nc->name, name) != 0) { > + continue; > + } > + > + if (nc->info->query_mac_table) { > + info = nc->info->query_mac_table(nc); > + entry = g_malloc0(sizeof(*entry)); > + entry->value = info; > + > + if (!table_list) { > + table_list = entry; > + } else { > + last_entry->next = entry; > + } > + last_entry = entry; > + } > + } > + > + if (table_list == NULL) { > + error_setg(errp, "invalid net client name: %s", name); > + } Produces confusing errors: 1. If query-mac-table is used without a name argument and the guest has no NIC or no NICs support ->query_mac_table(). 2. If the named NIC does not support ->query_mac_table().