summary refs log tree commit diff stats
path: root/net/net.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/net.c')
-rw-r--r--net/net.c73
1 files changed, 7 insertions, 66 deletions
diff --git a/net/net.c b/net/net.c
index 725a4e1450..edf9b95418 100644
--- a/net/net.c
+++ b/net/net.c
@@ -36,6 +36,7 @@
 #include "monitor/monitor.h"
 #include "qemu/help_option.h"
 #include "qapi/qapi-commands-net.h"
+#include "qapi/qapi-visit-net.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/qerror.h"
 #include "qemu/error-report.h"
@@ -55,7 +56,6 @@
 #include "sysemu/sysemu.h"
 #include "net/filter.h"
 #include "qapi/string-output-visitor.h"
-#include "qapi/hmp-output-visitor.h"
 
 /* Net bridge is currently not supported for W32. */
 #if !defined(_WIN32)
@@ -130,12 +130,11 @@ char *qemu_mac_strdup_printf(const uint8_t *macaddr)
 
 void qemu_format_nic_info_str(NetClientState *nc, uint8_t macaddr[6])
 {
-    g_free(nc->info_str);
-    nc->info_str = g_strdup_printf(
-        "model=%s,macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
-        nc->model,
-        macaddr[0], macaddr[1], macaddr[2],
-        macaddr[3], macaddr[4], macaddr[5]);
+    snprintf(nc->info_str, sizeof(nc->info_str),
+             "model=%s,macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
+             nc->model,
+             macaddr[0], macaddr[1], macaddr[2],
+             macaddr[3], macaddr[4], macaddr[5]);
 }
 
 static int mac_table[256] = {0};
@@ -354,8 +353,6 @@ static void qemu_free_net_client(NetClientState *nc)
     }
     g_free(nc->name);
     g_free(nc->model);
-    g_free(nc->info_str);
-    qapi_free_NetdevInfo(nc->stored_config);
     if (nc->destructor) {
         nc->destructor(nc);
     }
@@ -1222,42 +1219,14 @@ static void netfilter_print_info(Monitor *mon, NetFilterState *nf)
     monitor_printf(mon, "\n");
 }
 
-static char *generate_info_str(NetClientState *nc)
-{
-    NetdevInfo *ni = nc->stored_config;
-    char *ret_out = NULL;
-    Visitor *v;
-
-    /* Use legacy field info_str for NIC and hubports */
-    if ((nc->info->type == NET_CLIENT_DRIVER_NIC) ||
-        (nc->info->type == NET_CLIENT_DRIVER_HUBPORT)) {
-        return g_strdup(nc->info_str ? nc->info_str : "");
-    }
-
-    if (!ni) {
-        return g_malloc0(1);
-    }
-
-    v = hmp_output_visitor_new(&ret_out);
-    if (visit_type_NetdevInfo(v, "", &ni, NULL)) {
-        visit_complete(v, &ret_out);
-    }
-    visit_free(v);
-
-    return ret_out;
-}
-
 void print_net_client(Monitor *mon, NetClientState *nc)
 {
     NetFilterState *nf;
-    char *info_str = generate_info_str(nc);
 
     monitor_printf(mon, "%s: index=%d,type=%s,%s\n", nc->name,
                    nc->queue_index,
                    NetClientDriver_str(nc->info->type),
-                   info_str);
-    g_free(info_str);
-
+                   nc->info_str);
     if (!QTAILQ_EMPTY(&nc->filters)) {
         monitor_printf(mon, "filters:\n");
     }
@@ -1320,34 +1289,6 @@ RxFilterInfoList *qmp_query_rx_filter(bool has_name, const char *name,
     return filter_list;
 }
 
-NetdevInfoList *qmp_query_netdev(Error **errp)
-{
-    NetdevInfoList *list = NULL;
-    NetClientState *nc;
-
-    QTAILQ_FOREACH(nc, &net_clients, next) {
-        /*
-         * Only look at netdevs (backend network devices), not for each queue
-         * or NIC / hubport
-         */
-        if (nc->stored_config) {
-            NetdevInfo *element = QAPI_CLONE(NetdevInfo, nc->stored_config);
-
-            g_free(element->id); /* Need to dealloc empty id after clone */
-            element->id = g_strdup(nc->name);
-
-            element->has_peer_id = nc->peer != NULL;
-            if (element->has_peer_id) {
-                element->peer_id = g_strdup(nc->peer->name);
-            }
-
-            QAPI_LIST_PREPEND(list, element);
-        }
-    }
-
-    return list;
-}
-
 void hmp_info_network(Monitor *mon, const QDict *qdict)
 {
     NetClientState *nc, *peer;