Revert query-netdev command for 6.0
Subsystems (3)
cover Revert query-netdev command for 6.0
Hi All:
Several issues has been reported for query-netdev command:
- coverity warnings of memory leak and cut-and-paste issue
- lacking of documentation for future new netdev development
Consider it's late in the rc, I would like to revert this series and let's retry for 6.1.
Thanks
Jason Wang (5):
Revert "net: Do not fill legacy info_str for backends" Revert "hmp: Use QAPI NetdevInfo in hmp_info_network" Revert "net: Move NetClientState.info_str to dynamic allocations" Revert "tests: Add tests for query-netdev command" Revert "qapi: net: Add query-netdev command"
hw/net/xen_nic.c | 5 +- include/net/net.h | 5 +- include/qapi/hmp-output-visitor.h | 30 ----- net/l2tpv3.c | 8 +- net/net.c | 73 ++--------- net/netmap.c | 7 -- net/slirp.c | 124 +------------------ net/socket.c | 92 ++++---------- net/tap-win32.c | 10 +- net/tap.c | 107 ++--------------- net/vde.c | 25 +--- net/vhost-user.c | 20 +--- net/vhost-vdpa.c | 15 +-- qapi/hmp-output-visitor.c | 193 ------------------------------ qapi/meson.build | 1 - qapi/net.json | 80 ------------- tests/qtest/meson.build | 3 - tests/qtest/test-query-netdev.c | 120 ------------------- 18 files changed, 62 insertions(+), 856 deletions(-) delete mode 100644 include/qapi/hmp-output-visitor.h delete mode 100644 qapi/hmp-output-visitor.c delete mode 100644 tests/qtest/test-query-netdev.c
Signature · 1 line
2.24.3 (Apple Git-128)
PATCH 1/5 Revert "net: Do not fill legacy info_str for backends"
Several issues has been reported for query-netdev info series. Consider it's late in the rc, this reverts commit f2e8319d456724c3d8514d943dc4607e2f08e88a.
--- net/l2tpv3.c | 2 ++ net/slirp.c | 3 +++ net/socket.c | 28 ++++++++++++++++++++++++++++ net/tap-win32.c | 2 ++ net/tap.c | 9 +++++++++ net/vde.c | 2 ++ net/vhost-user.c | 1 + net/vhost-vdpa.c | 1 + 8 files changed, 48 insertions(+)
net/l2tpv3.c +2 -0
@@ -729,6 +729,8 @@ int net_init_l2tpv3(const Netdev *netdev,QAPI_CLONE_MEMBERS (NetdevL2TPv3Options, &nc->stored_config->u.l2tpv3, l2tpv3); + + s->nc.info_str =g_strdup_printf ("l2tpv3: connected" );return 0 ; outerr:qemu_del_net_client (nc);
net/slirp.c +3 -0
@@ -674,6 +674,9 @@ static int net_slirp_init(NetClientState *peer, const char *model, stored->tftp_server_name =g_strdup (tftp_server_name); } + nc->info_str =g_strdup_printf ("net=%s,restrict=%s" ,inet_ntoa (net), + restricted ?"on" :"off" ); + s =DO_UPCAST (SlirpState, nc, nc); s->slirp = slirp_init(restricted, ipv4, net, mask, host,
net/socket.c +28 -0
@@ -180,6 +180,8 @@ static void net_socket_send(void *opaque) s->fd =-1 ;net_socket_rs_init (&s->rs, net_socket_rs_finalize, false); s->nc.link_down = true; +g_free (s->nc.info_str); + s->nc.info_str =g_new0 (char,1 );return ; }
@@ -399,10 +401,16 @@ static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer, stored->mcast =g_strdup (mcast); s->dgram_dst = saddr; + nc->info_str =g_strdup_printf ("socket: fd=%d (cloned mcast=%s:%d)" , + fd,inet_ntoa (saddr.sin_addr), +ntohs (saddr.sin_port)); }else {if (sa_type ==SOCKET_ADDRESS_TYPE_UNIX ) { s->dgram_dst.sin_family =AF_UNIX ; } + + nc->info_str =g_strdup_printf ("socket: fd=%d %s" , + fd,SocketAddressType_str (sa_type)); }return s;
@@ -437,6 +445,8 @@ static NetSocketState *net_socket_fd_init_stream(NetClientState *peer, nc =qemu_new_net_client (&net_socket_info, peer, model, name); + nc->info_str =g_strdup_printf ("socket: fd=%d" , fd); + s =DO_UPCAST (NetSocketState, nc, nc); s->fd = fd;
@@ -518,6 +528,11 @@ static void net_socket_accept(void *opaque) stored->has_fd = true; stored->fd =g_strdup_printf ("%d" , fd); + +g_free (s->nc.info_str); + s->nc.info_str =g_strdup_printf ("socket: connection from %s:%d" , +inet_ntoa (saddr.sin_addr), +ntohs (saddr.sin_port)); } static int net_socket_listen_init(NetClientState *peer,
@@ -632,6 +647,10 @@ static int net_socket_connect_init(NetClientState *peer, stored->has_connect = true; stored->connect =g_strdup (host_str); +g_free (s->nc.info_str); + s->nc.info_str =g_strdup_printf ("socket: connect to %s:%d" , +inet_ntoa (saddr.sin_addr), +ntohs (saddr.sin_port));return 0 ; }
@@ -688,7 +707,12 @@ static int net_socket_mcast_init(NetClientState *peer, stored->localaddr =g_strdup (localaddr_str); } +g_free (s->nc.info_str); + s->nc.info_str =g_strdup_printf ("socket: mcast=%s:%d" , +inet_ntoa (saddr.sin_addr), +ntohs (saddr.sin_port));return 0 ; + } static int net_socket_udp_init(NetClientState *peer,
@@ -749,6 +773,10 @@ static int net_socket_udp_init(NetClientState *peer, stored->has_udp = true; stored->udp =g_strdup (rhost); +g_free (s->nc.info_str); + s->nc.info_str =g_strdup_printf ("socket: udp=%s:%d" , +inet_ntoa (raddr.sin_addr), +ntohs (raddr.sin_port));return 0 ; }
net/tap-win32.c +2 -0
@@ -797,6 +797,8 @@ static int tap_win32_init(NetClientState *peer, const char *model, stored->has_ifname = true; stored->ifname =g_strdup (ifname); + s->nc.info_str =g_strdup_printf ("tap: ifname=%s" , ifname); + s->handle = handle;qemu_add_wait_object (s->handle->tap_semaphore, tap_win32_send, s);
net/tap.c +9 -0
@@ -635,6 +635,8 @@ int net_init_bridge(const Netdev *netdev, const char *name, stored->helper =g_strdup (helper); } + s->nc.info_str =g_strdup_printf ("helper=%s,br=%s" , helper, br); +return 0 ; }
@@ -720,6 +722,8 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, stored->fds =g_strdup_printf ("%s:%d" , stored->fds, fd);g_free (tmp_s); } + + s->nc.info_str =g_strdup_printf ("fd=%d" , fd); }else if (tap->has_helper) {if (!stored->has_helper) { stored->has_helper = true;
@@ -731,6 +735,8 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, stored->br = tap->has_br ?g_strdup (tap->br) :g_strdup (DEFAULT_BRIDGE_INTERFACE ); } + + s->nc.info_str =g_strdup_printf ("helper=%s" , tap->helper); }else {if (ifname && !stored->has_ifname) { stored->has_ifname = true;
@@ -747,6 +753,9 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, stored->downscript =g_strdup (downscript); } + s->nc.info_str =g_strdup_printf ("ifname=%s,script=%s,downscript=%s" , + ifname, script, downscript); +if (strcmp (downscript,"no" ) !=0 ) {snprintf (s->down_script,sizeof (s->down_script),"%s" , downscript); snprintf(s->down_script_arg, sizeof(s->down_script_arg),
net/vde.c +2 -0
@@ -100,6 +100,8 @@ static int net_vde_init(NetClientState *peer, const char *model, nc =qemu_new_net_client (&net_vde_info, peer, model, name); + nc->info_str =g_strdup_printf ("sock=%s,fd=%d" , sock,vde_datafd (vde)); + s =DO_UPCAST (VDEState, nc, nc); s->vde = vde;
net/vhost-user.c +1 -0
@@ -327,6 +327,7 @@ static int net_vhost_user_init(NetClientState *peer, const char *device, user = g_new0(struct VhostUserState, 1);for (i =0 ; i < queues; i++) { nc =qemu_new_net_client (&net_vhost_user_info, peer, device, name); + nc->info_str =g_strdup_printf ("vhost-user%d to %s" , i, chr->label); nc->queue_index = i;if (!nc0) { nc0 = nc;
net/vhost-vdpa.c +1 -0
@@ -200,6 +200,7 @@ static int net_vhost_vdpa_init(NetClientState *peer, const char *device, stored->has_queues = true; stored->queues =1 ;/* TODO: change when support multiqueue */ + nc->info_str =g_strdup_printf (TYPE_VHOST_VDPA ); nc->queue_index =0 ; s =DO_UPCAST (VhostVDPAState, nc, nc); vdpa_device_fd =qemu_open_old (vhostdev,O_RDWR );
Signature · 1 line
2.24.3 (Apple Git-128)
PATCH 2/5 Revert "hmp: Use QAPI NetdevInfo in hmp_info_network"
In reply to Jason WangSeveral issues has been reported for query-netdev info series. Consider it's late in the rc, this reverts commit a0724776c5a98a08fc946bb5a4ad16410ca64c0e.
--- include/qapi/hmp-output-visitor.h | 30 ----- net/net.c | 31 +---- qapi/hmp-output-visitor.c | 193 ------------------------------ qapi/meson.build | 1 - 4 files changed, 1 insertion(+), 254 deletions(-) delete mode 100644 include/qapi/hmp-output-visitor.h delete mode 100644 qapi/hmp-output-visitor.c
include/qapi/hmp-output-visitor.h deleted +0 -30
@@ -1,30 +0,0 @@ -/* -* HMP string output Visitor -* -* Copyright Yandex N.V., 2021 -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -* -*/ - -#ifndef HMP_OUTPUT_VISITOR_H -#define HMP_OUTPUT_VISITOR_H - -#include "qapi/visitor.h" - -typedef struct HMPOutputVisitor HMPOutputVisitor ; - -/** -* Create a HMP string output visitor for @obj -* -* Flattens dicts/structures, only shows arrays borders. -* -* Errors are not expected to happen. -* -* The caller is responsible for freeing the visitor with -* visit_free(). -*/ -Visitor *hmp_output_visitor_new (char **result); - -#endif
net/net.c +1 -30
@@ -55,7 +55,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)
@@ -1222,42 +1221,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 ? nc->info_str :"" );if (!QTAILQ_EMPTY (&nc->filters)) {monitor_printf (mon,"filters:\n" ); }
qapi/hmp-output-visitor.c deleted +0 -193
193 lines not on this page · raw message
qapi/meson.build +0 -1
@@ -8,7 +8,6 @@ util_ss.add(files( 'qobject-output-visitor.c', 'string-input-visitor.c', 'string-output-visitor.c', - 'hmp-output-visitor.c', )) if have_system or have_tools util_ss.add(files(
Signature · 1 line
2.24.3 (Apple Git-128)
PATCH 3/5 Revert "net: Move NetClientState.info_str to dynamic allocations"
In reply to Jason WangSeveral issues has been reported for query-netdev info series. Consider it's late in the rc, this reverts commitThis reverts commit 59b5437eb732d6b103a9bc279c3482c834d1eff9.
--- hw/net/xen_nic.c | 5 +++-- include/net/net.h | 2 +- net/l2tpv3.c | 3 ++- net/net.c | 14 ++++++-------- net/slirp.c | 5 +++-- net/socket.c | 43 +++++++++++++++++++------------------------ net/tap-win32.c | 3 ++- net/tap.c | 13 ++++++++----- net/vde.c | 3 ++- net/vhost-user.c | 3 ++- net/vhost-vdpa.c | 2 +- 11 files changed, 49 insertions(+), 47 deletions(-)
hw/net/xen_nic.c +3 -2
@@ -296,8 +296,9 @@ static int net_init(struct XenLegacyDevice *xendev) netdev->nic =qemu_new_nic (&net_xen_info, &netdev->conf,"xen" ,NULL , netdev); -qemu_get_queue (netdev->nic)->info_str =g_strdup_printf ( -"nic: xenbus vif macaddr=%s" , netdev->mac); +snprintf (qemu_get_queue (netdev->nic)->info_str, +sizeof (qemu_get_queue (netdev->nic)->info_str), +"nic: xenbus vif macaddr=%s" , netdev->mac);/* fill info */ xenstore_write_be_int (&netdev->xendev,"feature-rx-copy" ,1 );
include/net/net.h +1 -1
@@ -94,7 +94,7 @@ struct NetClientState {NetQueue *incoming_queue;char *model;char *name; -char *info_str; +char info_str[256 ];NetdevInfo *stored_config; unsigned receive_disabled : 1;NetClientDestructor *destructor;
net/l2tpv3.c +2 -1
@@ -730,7 +730,8 @@ int net_init_l2tpv3(const Netdev *netdev,QAPI_CLONE_MEMBERS (NetdevL2TPv3Options, &nc->stored_config->u.l2tpv3, l2tpv3); - s->nc.info_str =g_strdup_printf ("l2tpv3: connected" ); +snprintf (s->nc.info_str,sizeof (s->nc.info_str), +"l2tpv3: connected" );return 0 ; outerr:qemu_del_net_client (nc);
net/net.c +6 -8
@@ -129,12 +129,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 };
@@ -353,7 +352,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);
@@ -1228,7 +1226,7 @@ void print_net_client(Monitor *mon, NetClientState *nc)monitor_printf (mon,"%s: index=%d,type=%s,%s\n" , nc->name, nc->queue_index,NetClientDriver_str (nc->info->type), - nc->info_str ? nc->info_str :"" ); + nc->info_str);if (!QTAILQ_EMPTY (&nc->filters)) {monitor_printf (mon,"filters:\n" ); }
net/slirp.c +3 -2
@@ -674,8 +674,9 @@ static int net_slirp_init(NetClientState *peer, const char *model, stored->tftp_server_name =g_strdup (tftp_server_name); } - nc->info_str =g_strdup_printf ("net=%s,restrict=%s" ,inet_ntoa (net), - restricted ?"on" :"off" ); +snprintf (nc->info_str,sizeof (nc->info_str), +"net=%s,restrict=%s" ,inet_ntoa (net), + restricted ?"on" :"off" ); s =DO_UPCAST (SlirpState, nc, nc);
net/socket.c +19 -24
90 lines not on this page · raw message
net/tap-win32.c +2 -1
@@ -797,7 +797,8 @@ static int tap_win32_init(NetClientState *peer, const char *model, stored->has_ifname = true; stored->ifname =g_strdup (ifname); - s->nc.info_str =g_strdup_printf ("tap: ifname=%s" , ifname); +snprintf (s->nc.info_str,sizeof (s->nc.info_str), +"tap: ifname=%s" , ifname); s->handle = handle;
net/tap.c +8 -5
@@ -635,7 +635,8 @@ int net_init_bridge(const Netdev *netdev, const char *name, stored->helper =g_strdup (helper); } - s->nc.info_str =g_strdup_printf ("helper=%s,br=%s" , helper, br); +snprintf (s->nc.info_str,sizeof (s->nc.info_str),"helper=%s,br=%s" , helper, + br);return 0 ; }
@@ -723,7 +724,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,g_free (tmp_s); } - s->nc.info_str =g_strdup_printf ("fd=%d" , fd); +snprintf (s->nc.info_str,sizeof (s->nc.info_str),"fd=%d" , fd); }else if (tap->has_helper) {if (!stored->has_helper) { stored->has_helper = true;
@@ -736,7 +737,8 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,g_strdup (DEFAULT_BRIDGE_INTERFACE ); } - s->nc.info_str =g_strdup_printf ("helper=%s" , tap->helper); +snprintf (s->nc.info_str,sizeof (s->nc.info_str),"helper=%s" , + tap->helper); }else {if (ifname && !stored->has_ifname) { stored->has_ifname = true;
@@ -753,8 +755,9 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, stored->downscript =g_strdup (downscript); } - s->nc.info_str =g_strdup_printf ("ifname=%s,script=%s,downscript=%s" , - ifname, script, downscript); +snprintf (s->nc.info_str,sizeof (s->nc.info_str), +"ifname=%s,script=%s,downscript=%s" , ifname, script, + downscript);if (strcmp (downscript,"no" ) !=0 ) {snprintf (s->down_script,sizeof (s->down_script),"%s" , downscript);
net/vde.c +2 -1
@@ -100,7 +100,8 @@ static int net_vde_init(NetClientState *peer, const char *model, nc =qemu_new_net_client (&net_vde_info, peer, model, name); - nc->info_str =g_strdup_printf ("sock=%s,fd=%d" , sock,vde_datafd (vde)); +snprintf (nc->info_str,sizeof (nc->info_str),"sock=%s,fd=%d" , + sock,vde_datafd (vde)); s =DO_UPCAST (VDEState, nc, nc);
net/vhost-user.c +2 -1
@@ -327,7 +327,8 @@ static int net_vhost_user_init(NetClientState *peer, const char *device, user = g_new0(struct VhostUserState, 1);for (i =0 ; i < queues; i++) { nc =qemu_new_net_client (&net_vhost_user_info, peer, device, name); - nc->info_str =g_strdup_printf ("vhost-user%d to %s" , i, chr->label); +snprintf (nc->info_str,sizeof (nc->info_str),"vhost-user%d to %s" , + i, chr->label); nc->queue_index = i;if (!nc0) { nc0 = nc;
net/vhost-vdpa.c +1 -1
@@ -200,7 +200,7 @@ static int net_vhost_vdpa_init(NetClientState *peer, const char *device, stored->has_queues = true; stored->queues =1 ;/* TODO: change when support multiqueue */ - nc->info_str =g_strdup_printf (TYPE_VHOST_VDPA ); +snprintf (nc->info_str,sizeof (nc->info_str),TYPE_VHOST_VDPA ); nc->queue_index =0 ; s =DO_UPCAST (VhostVDPAState, nc, nc); vdpa_device_fd =qemu_open_old (vhostdev,O_RDWR );
Signature · 1 line
2.24.3 (Apple Git-128)
Re: [PATCH 3/5] Revert "net: Move NetClientState.info_str to dynamic allocations"
Quoted 2 lines · Jason Wang
Several issues has been reported for query-netdev info series. Consider it's late in the rc, this reverts commitThis reverts
copy and paste error :(.
Will fix this when applying the series.
Thanks
Quoted 316 lines
commit
59b5437eb732d6b103a9bc279c3482c834d1eff9.Signed-off-by Jason Wang <[email protected]>--- hw/net/xen_nic.c | 5 +++-- include/net/net.h | 2 +- net/l2tpv3.c | 3 ++- net/net.c | 14 ++++++-------- net/slirp.c | 5 +++-- net/socket.c | 43 +++++++++++++++++++------------------------ net/tap-win32.c | 3 ++- net/tap.c | 13 ++++++++----- net/vde.c | 3 ++- net/vhost-user.c | 3 ++- net/vhost-vdpa.c | 2 +- 11 files changed, 49 insertions(+), 47 deletions(-)hw/net/xen_nic.c +3
-2@@ -296,8 +296,9 @@ static int net_init(struct XenLegacyDevice *xendev) netdev->nic =qemu_new_nic (&net_xen_info, &netdev->conf,"xen" ,NULL , netdev); -qemu_get_queue (netdev->nic)->info_str =g_strdup_printf ( -"nic: xenbus vif macaddr=%s" , netdev->mac); +snprintf (qemu_get_queue (netdev->nic)->info_str, +sizeof (qemu_get_queue (netdev->nic)->info_str), +"nic: xenbus vif macaddr=%s" , netdev->mac);/* fill info */ xenstore_write_be_int (&netdev->xendev,"feature-rx-copy" ,1 );include/net/net.h +1
-1@@ -94,7 +94,7 @@ struct NetClientState {NetQueue *incoming_queue;char *model;char *name; -char *info_str; +char info_str[256 ];NetdevInfo *stored_config; unsigned receive_disabled : 1;NetClientDestructor *destructor;net/l2tpv3.c +2
-1@@ -730,7 +730,8 @@ int net_init_l2tpv3(const Netdev *netdev,QAPI_CLONE_MEMBERS (NetdevL2TPv3Options, &nc->stored_config->u.l2tpv3, l2tpv3); - s->nc.info_str =g_strdup_printf ("l2tpv3: connected" ); +snprintf (s->nc.info_str,sizeof (s->nc.info_str), +"l2tpv3: connected" );return 0 ; outerr:qemu_del_net_client (nc);net/net.c +6
-8@@ -129,12 +129,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 };@@ -353,7 +352,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);@@ -1228,7 +1226,7 @@ void print_net_client(Monitor *mon, NetClientState *nc)monitor_printf (mon,"%s: index=%d,type=%s,%s\n" , nc->name, nc->queue_index,NetClientDriver_str (nc->info->type), - nc->info_str ? nc->info_str :"" ); + nc->info_str);if (!QTAILQ_EMPTY (&nc->filters)) {monitor_printf (mon,"filters:\n" ); }net/slirp.c +3
-2@@ -674,8 +674,9 @@ static int net_slirp_init(NetClientState *peer, const char *model, stored->tftp_server_name =g_strdup (tftp_server_name); } - nc->info_str =g_strdup_printf ("net=%s,restrict=%s" ,inet_ntoa (net), - restricted ?"on" :"off" ); +snprintf (nc->info_str,sizeof (nc->info_str), +"net=%s,restrict=%s" ,inet_ntoa (net), + restricted ?"on" :"off" ); s =DO_UPCAST (SlirpState, nc, nc);net/socket.c +19
-24@@ -180,8 +180,7 @@ static void net_socket_send(void *opaque) s->fd =-1 ;net_socket_rs_init (&s->rs, net_socket_rs_finalize, false); s->nc.link_down = true; -g_free (s->nc.info_str); - s->nc.info_str =g_new0 (char,1 ); +memset (s->nc.info_str,0 ,sizeof (s->nc.info_str));return ; }@@ -401,16 +400,16 @@ static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer, stored->mcast =g_strdup (mcast); s->dgram_dst = saddr; - nc->info_str =g_strdup_printf ("socket: fd=%d (cloned mcast=%s:%d)" , - fd,inet_ntoa (saddr.sin_addr), -ntohs (saddr.sin_port)); +snprintf (nc->info_str,sizeof (nc->info_str), +"socket: fd=%d (cloned mcast=%s:%d)" , + fd,inet_ntoa (saddr.sin_addr),ntohs (saddr.sin_port)); }else {if (sa_type ==SOCKET_ADDRESS_TYPE_UNIX ) { s->dgram_dst.sin_family =AF_UNIX ; } - nc->info_str =g_strdup_printf ("socket: fd=%d %s" , - fd,SocketAddressType_str (sa_type)); +snprintf (nc->info_str,sizeof (nc->info_str), +"socket: fd=%d %s" , fd,SocketAddressType_str (sa_type)); }return s;@@ -445,7 +444,7 @@ static NetSocketState *net_socket_fd_init_stream(NetClientState *peer, nc =qemu_new_net_client (&net_socket_info, peer, model, name); - nc->info_str =g_strdup_printf ("socket: fd=%d" , fd); +snprintf (nc->info_str,sizeof (nc->info_str),"socket: fd=%d" , fd); s =DO_UPCAST (NetSocketState, nc, nc);@@ -529,10 +528,9 @@ static void net_socket_accept(void *opaque) stored->has_fd = true; stored->fd =g_strdup_printf ("%d" , fd); -g_free (s->nc.info_str); - s->nc.info_str =g_strdup_printf ("socket: connection from %s:%d" , -inet_ntoa (saddr.sin_addr), -ntohs (saddr.sin_port)); +snprintf (s->nc.info_str,sizeof (s->nc.info_str), +"socket: connection from %s:%d" , +inet_ntoa (saddr.sin_addr),ntohs (saddr.sin_port)); } static int net_socket_listen_init(NetClientState *peer,@@ -647,10 +645,9 @@ static int net_socket_connect_init(NetClientState *peer, stored->has_connect = true; stored->connect =g_strdup (host_str); -g_free (s->nc.info_str); - s->nc.info_str =g_strdup_printf ("socket: connect to %s:%d" , -inet_ntoa (saddr.sin_addr), -ntohs (saddr.sin_port)); +snprintf (s->nc.info_str,sizeof (s->nc.info_str), +"socket: connect to %s:%d" , +inet_ntoa (saddr.sin_addr),ntohs (saddr.sin_port));return 0 ; }@@ -707,10 +704,9 @@ static int net_socket_mcast_init(NetClientState *peer, stored->localaddr =g_strdup (localaddr_str); } -g_free (s->nc.info_str); - s->nc.info_str =g_strdup_printf ("socket: mcast=%s:%d" , -inet_ntoa (saddr.sin_addr), -ntohs (saddr.sin_port)); +snprintf (s->nc.info_str,sizeof (s->nc.info_str), +"socket: mcast=%s:%d" , +inet_ntoa (saddr.sin_addr),ntohs (saddr.sin_port));return 0 ; }@@ -773,10 +769,9 @@ static int net_socket_udp_init(NetClientState *peer, stored->has_udp = true; stored->udp =g_strdup (rhost); -g_free (s->nc.info_str); - s->nc.info_str =g_strdup_printf ("socket: udp=%s:%d" , -inet_ntoa (raddr.sin_addr), -ntohs (raddr.sin_port)); +snprintf (s->nc.info_str,sizeof (s->nc.info_str), +"socket: udp=%s:%d" , +inet_ntoa (raddr.sin_addr),ntohs (raddr.sin_port));return 0 ; }net/tap-win32.c +2
-1@@ -797,7 +797,8 @@ static int tap_win32_init(NetClientState *peer, const char *model, stored->has_ifname = true; stored->ifname =g_strdup (ifname); - s->nc.info_str =g_strdup_printf ("tap: ifname=%s" , ifname); +snprintf (s->nc.info_str,sizeof (s->nc.info_str), +"tap: ifname=%s" , ifname); s->handle = handle;net/tap.c +8
-5@@ -635,7 +635,8 @@ int net_init_bridge(const Netdev *netdev, const char *name, stored->helper =g_strdup (helper); } - s->nc.info_str =g_strdup_printf ("helper=%s,br=%s" , helper, br); +snprintf (s->nc.info_str,sizeof (s->nc.info_str),"helper=%s,br=%s" , helper, + br);return 0 ; }@@ -723,7 +724,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,g_free (tmp_s); } - s->nc.info_str =g_strdup_printf ("fd=%d" , fd); +snprintf (s->nc.info_str,sizeof (s->nc.info_str),"fd=%d" , fd); }else if (tap->has_helper) {if (!stored->has_helper) { stored->has_helper = true;@@ -736,7 +737,8 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,g_strdup (DEFAULT_BRIDGE_INTERFACE ); } - s->nc.info_str =g_strdup_printf ("helper=%s" , tap->helper); +snprintf (s->nc.info_str,sizeof (s->nc.info_str),"helper=%s" , + tap->helper); }else {if (ifname && !stored->has_ifname) { stored->has_ifname = true;@@ -753,8 +755,9 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, stored->downscript =g_strdup (downscript); } - s->nc.info_str =g_strdup_printf ("ifname=%s,script=%s,downscript=%s" , - ifname, script, downscript); +snprintf (s->nc.info_str,sizeof (s->nc.info_str), +"ifname=%s,script=%s,downscript=%s" , ifname, script, + downscript);if (strcmp (downscript,"no" ) !=0 ) {snprintf (s->down_script,sizeof (s->down_script),"%s" , downscript);net/vde.c +2
-1@@ -100,7 +100,8 @@ static int net_vde_init(NetClientState *peer, const char *model, nc =qemu_new_net_client (&net_vde_info, peer, model, name); - nc->info_str =g_strdup_printf ("sock=%s,fd=%d" , sock,vde_datafd (vde)); +snprintf (nc->info_str,sizeof (nc->info_str),"sock=%s,fd=%d" , + sock,vde_datafd (vde)); s =DO_UPCAST (VDEState, nc, nc);net/vhost-user.c +2
-1@@ -327,7 +327,8 @@ static int net_vhost_user_init(NetClientState *peer, const char *device, user = g_new0(struct VhostUserState, 1);for (i =0 ; i < queues; i++) { nc =qemu_new_net_client (&net_vhost_user_info, peer, device, name); - nc->info_str =g_strdup_printf ("vhost-user%d to %s" , i, chr->label); +snprintf (nc->info_str,sizeof (nc->info_str),"vhost-user%d to %s" , + i, chr->label); nc->queue_index = i;if (!nc0) { nc0 = nc;net/vhost-vdpa.c +1
-1@@ -200,7 +200,7 @@ static int net_vhost_vdpa_init(NetClientState *peer, const char *device, stored->has_queues = true; stored->queues =1 ;/* TODO: change when support multiqueue */ - nc->info_str =g_strdup_printf (TYPE_VHOST_VDPA ); +snprintf (nc->info_str,sizeof (nc->info_str),TYPE_VHOST_VDPA ); nc->queue_index =0 ; s =DO_UPCAST (VhostVDPAState, nc, nc); vdpa_device_fd =qemu_open_old (vhostdev,O_RDWR );
PATCH 4/5 Revert "tests: Add tests for query-netdev command"
In reply to Jason WangSeveral issues has been reported for query-netdev series. Consider it's late in the rc, this reverts commitThis reverts commit 3c3b656885473ef0d699290ba966177f17839aa5.
--- tests/qtest/meson.build | 3 - tests/qtest/test-query-netdev.c | 120 -------------------------------- 2 files changed, 123 deletions(-) delete mode 100644 tests/qtest/test-query-netdev.c
tests/qtest/meson.build +0 -3
@@ -33,9 +33,6 @@ qtests_generic = \ if config_host.has_key('CONFIG_MODULES') qtests_generic += [ 'modules-test' ] endif -if slirp.found() - qtests_generic += [ 'test-query-netdev' ] -endif qtests_pci = \ (config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : []) + \
tests/qtest/test-query-netdev.c deleted +0 -120
120 lines not on this page · raw message
Signature · 1 line
2.24.3 (Apple Git-128)
PATCH 5/5 Revert "qapi: net: Add query-netdev command"
In reply to Jason WangSeveral issues has been reported for query-netdev series. Consider it's late in the rc, this reverts commitThis reverts commit d32ad10a14d46dfe9304e3ed5858a11dcd5c71a0.
--- include/net/net.h | 3 -- net/l2tpv3.c | 7 --- net/net.c | 30 +----------- net/netmap.c | 7 --- net/slirp.c | 122 ---------------------------------------------- net/socket.c | 71 --------------------------- net/tap-win32.c | 9 ---- net/tap.c | 103 ++------------------------------------ net/vde.c | 22 --------- net/vhost-user.c | 18 ++----- net/vhost-vdpa.c | 14 ------ qapi/net.json | 80 ------------------------------ 12 files changed, 9 insertions(+), 477 deletions(-)
include/net/net.h +0 -3
@@ -5,8 +5,6 @@#include "qapi/qapi-types-net.h" #include "net/queue.h" #include "hw/qdev-properties-system.h" -#include "qapi/clone-visitor.h" -#include "qapi/qapi-visit-net.h" #define MAC_FMT "%02X:%02X:%02X:%02X:%02X:%02X"#define MAC_ARG (x) ((uint8_t *)(x))[0], ((uint8_t *)(x))[1], \
@@ -95,7 +93,6 @@ struct NetClientState {char *model;char *name;char info_str[256 ]; -NetdevInfo *stored_config; unsigned receive_disabled : 1;NetClientDestructor *destructor;unsigned int queue_index;
net/l2tpv3.c +0 -7
@@ -723,13 +723,6 @@ int net_init_l2tpv3(const Netdev *netdev,l2tpv3_read_poll (s, true); -/* Store startup parameters */ - nc->stored_config =g_new0 (NetdevInfo,1 ); - nc->stored_config->type =NET_BACKEND_L2TPV3 ; - -QAPI_CLONE_MEMBERS (NetdevL2TPv3Options, - &nc->stored_config->u.l2tpv3, l2tpv3); -snprintf (s->nc.info_str,sizeof (s->nc.info_str),"l2tpv3: connected" );return 0 ;
net/net.c +1 -29
@@ -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"
@@ -352,7 +353,6 @@ static void qemu_free_net_client(NetClientState *nc) }g_free (nc->name);g_free (nc->model); -qapi_free_NetdevInfo (nc->stored_config);if (nc->destructor) { nc->destructor (nc); }
@@ -1289,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;
net/netmap.c +0 -7
@@ -427,13 +427,6 @@ int net_init_netmap(const Netdev *netdev,pstrcpy (s->ifname,sizeof (s->ifname), netmap_opts->ifname);netmap_read_poll (s, true);/* Initially only poll for reads. */ -/* Store startup parameters */ - nc->stored_config =g_new0 (NetdevInfo,1 ); - nc->stored_config->type =NET_BACKEND_NETMAP ; - -QAPI_CLONE_MEMBERS (NetdevNetmapOptions, - &nc->stored_config->u.netmap, netmap_opts); -return 0 ; }
net/slirp.c +0 -122
149 lines not on this page · raw message
net/socket.c +0 -71
157 lines not on this page · raw message
net/tap-win32.c +0 -9
@@ -778,7 +778,6 @@ static int tap_win32_init(NetClientState *peer, const char *model,NetClientState *nc;TAPState *s;tap_win32_overlapped_t *handle; -NetdevTapOptions *stored;if (tap_win32_open (&handle, ifname) <0 ) {printf ("tap: Could not open '%s'\n" , ifname);
@@ -789,14 +788,6 @@ static int tap_win32_init(NetClientState *peer, const char *model, s =DO_UPCAST (TAPState, nc, nc); -/* Store startup parameters */ - nc->stored_config =g_new0 (NetdevInfo,1 ); - nc->stored_config->type =NET_BACKEND_TAP ; - stored = &nc->stored_config->u.tap; - - stored->has_ifname = true; - stored->ifname =g_strdup (ifname); -snprintf (s->nc.info_str,sizeof (s->nc.info_str),"tap: ifname=%s" , ifname);
net/tap.c +5 -98
182 lines not on this page · raw message
net/vde.c +0 -22
@@ -84,7 +84,6 @@ static int net_vde_init(NetClientState *peer, const char *model,VDECONN *vde;char *init_group = (char *)group;char *init_sock = (char *)sock; -NetdevVdeOptions *stored;struct vde_open_args args = { .port = port,
@@ -109,27 +108,6 @@ static int net_vde_init(NetClientState *peer, const char *model,qemu_set_fd_handler (vde_datafd (s->vde), vde_to_qemu,NULL , s); -/* Store startup parameters */ - nc->stored_config =g_new0 (NetdevInfo,1 ); - nc->stored_config->type =NET_BACKEND_VDE ; - stored = &nc->stored_config->u.vde; - -if (sock) { - stored->has_sock = true; - stored->sock =g_strdup (sock); - } - - stored->has_port = true; - stored->port = port; - -if (group) { - stored->has_group = true; - stored->group =g_strdup (group); - } - - stored->has_mode = true; - stored->mode = mode; -return 0 ; }
net/vhost-user.c +3 -15
@@ -311,15 +311,14 @@ static void net_vhost_user_event(void *opaque, QEMUChrEvent event) }static int net_vhost_user_init (NetClientState *peer,const char *device, -const char *name,const char *chardev, -Chardev *chr,int queues) +const char *name,Chardev *chr, +int queues) {Error *err =NULL ;NetClientState *nc, *nc0 =NULL ;NetVhostUserState *s =NULL ;VhostUserState *user;int i; -NetdevVhostUserOptions *stored;assert (name);assert (queues >0 );
@@ -356,16 +355,6 @@ static int net_vhost_user_init(NetClientState *peer, const char *device,assert (s->vhost_net); -/* Store startup parameters */ - nc0->stored_config =g_new0 (NetdevInfo,1 ); - nc0->stored_config->type =NET_BACKEND_VHOST_USER ; - stored = &nc0->stored_config->u.vhost_user; - - stored->chardev =g_strdup (chardev); - - stored->has_queues = true; - stored->queues = queues; -return 0 ; err:
@@ -457,6 +446,5 @@ int net_init_vhost_user(const Netdev *netdev, const char *name,return -1 ; } -return net_vhost_user_init (peer,"vhost_user" , name, - vhost_user_opts->chardev, chr, queues); +return net_vhost_user_init (peer,"vhost_user" , name, chr, queues); }
net/vhost-vdpa.c +0 -14
@@ -184,22 +184,8 @@ static int net_vhost_vdpa_init(NetClientState *peer, const char *device,VhostVDPAState *s;int vdpa_device_fd =-1 ;int ret =0 ; -NetdevVhostVDPAOptions *stored; -assert (name); nc =qemu_new_net_client (&net_vhost_vdpa_info, peer, device, name); - -/* Store startup parameters */ - nc->stored_config =g_new0 (NetdevInfo,1 ); - nc->stored_config->type =NET_BACKEND_VHOST_VDPA ; - stored = &nc->stored_config->u.vhost_vdpa; - - stored->has_vhostdev = true; - stored->vhostdev =g_strdup (vhostdev); - - stored->has_queues = true; - stored->queues =1 ;/* TODO: change when support multiqueue */ -snprintf (nc->info_str,sizeof (nc->info_str),TYPE_VHOST_VDPA ); nc->queue_index =0 ; s =DO_UPCAST (VhostVDPAState, nc, nc);
qapi/net.json +0 -80
83 lines not on this page · raw message
Signature · 1 line
2.24.3 (Apple Git-128)
Jason Wang
AppliedQuoted 9 lines · Jason Wang
Hi All:
Several issues has been reported for query-netdev command:
- coverity warnings of memory leak and cut-and-paste issue
- lacking of documentation for future new netdev developmentConsider it's late in the rc, I would like to revert this series and let's retry for 6.1.
Applied.
Thanks
Quoted 33 lines
Thanks
Jason Wang (5):
Revert "net: Do not fill legacyinfo_strfor backends" Revert "hmp: Use QAPI NetdevInfo inhmp_info_network" Revert "net: Move NetClientState.info_str to dynamic allocations" Revert "tests: Add tests for query-netdev command" Revert "qapi: net: Add query-netdev command"hw/net/xen_nic.c | 5 +- include/net/net.h | 5 +- include/qapi/hmp-output-visitor.h | 30 ----- net/l2tpv3.c | 8 +- net/net.c | 73 ++--------- net/netmap.c | 7 -- net/slirp.c | 124 +------------------ net/socket.c | 92 ++++---------- net/tap-win32.c | 10 +- net/tap.c | 107 ++--------------- net/vde.c | 25 +--- net/vhost-user.c | 20 +--- net/vhost-vdpa.c | 15 +-- qapi/hmp-output-visitor.c | 193 ------------------------------ qapi/meson.build | 1 - qapi/net.json | 80 ------------- tests/qtest/meson.build | 3 - tests/qtest/test-query-netdev.c | 120 ------------------- 18 files changed, 62 insertions(+), 856 deletions(-)delete mode 100644
include/qapi/hmp-output-visitor.hdelete mode 100644qapi/hmp-output-visitor.cdelete mode 100644tests/qtest/test-query-netdev.c