diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2021-04-08 16:45:31 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2021-04-08 16:45:31 +0100 |
commit | ce69aa92d71e13db9c3702a8e8305e8d2463aeb8 (patch) | |
tree | db523c9f40dd1e69e3f0a829d20eb36898c25597 /net/net.c | |
parent | d8724020dd13c88a72fc391a6a2cf63abbd3dcca (diff) | |
parent | 21df394d9e2ffce9fa308f496d1ae228cf6cdb57 (diff) |
Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging
# gpg: Signature made Thu 08 Apr 2021 10:34:24 BST
# gpg: using RSA key EF04965B398D6211
# gpg: Good signature from "Jason Wang (Jason Wang on RedHat) <jasowang@redhat.com>" [marginal]
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg: It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 215D 46F4 8246 689E C77F 3562 EF04 965B 398D 6211
* remotes/jasowang/tags/net-pull-request:
tap-win32: correctly recycle buffers
Revert "qapi: net: Add query-netdev command"
Revert "tests: Add tests for query-netdev command"
Revert "net: Move NetClientState.info_str to dynamic allocations"
Revert "hmp: Use QAPI NetdevInfo in hmp_info_network"
Revert "net: Do not fill legacy info_str for backends"
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'net/net.c')
-rw-r--r-- | net/net.c | 73 |
1 files changed, 7 insertions, 66 deletions
@@ -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; |