monitor: print hub port name during info network
PATCH 1/4 monitor: print hub port name during info network
--- net/hub.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/hub.c +4 -1
@@ -245,9 +245,12 @@ void net_hub_info(Monitor *mon) QLIST_FOREACH(hub, &hubs, next) {monitor_printf (mon,"hub %d\n" , hub->id); QLIST_FOREACH(port, &hub->ports, next) { +monitor_printf (mon," \\ %s" , port->nc.name);if (port->nc.peer) { -monitor_printf (mon," \\ " ); +monitor_printf (mon,": " );print_net_client (mon, port->nc.peer); + }else { +monitor_printf (mon,"\n" ); } } }
Signature · 1 line
1.9.1
PATCH 2/4 net: remove the wrong comment in net_init_hubport()
Not only nic could be the one to peer.
--- net/hub.c | 1 - 1 file changed, 1 deletion(-)
net/hub.c +0 -1
@@ -288,7 +288,6 @@ int net_init_hubport(const NetClientOptions *opts, const char *name,assert (opts->kind ==NET_CLIENT_OPTIONS_KIND_HUBPORT ); hubport = opts->hubport; -/* Treat hub port like a backend, NIC must be the one to peer */ if (peer) {return -EINVAL ; }
Signature · 1 line
1.9.1
PATCH 3/4 net: del hub port when peer is deleted
In reply to Jason WangWe should del hub port when peer is deleted since it will not be reused and will only be freed during exit.
--- net/net.c | 2 ++ 1 file changed, 2 insertions(+)
net/net.c +2 -0
@@ -996,6 +996,8 @@ void net_host_device_remove(Monitor *mon, const QDict *qdict)error_report ("invalid host network device '%s'" , device);return ; } + +qemu_del_net_client (nc->peer);qemu_del_net_client (nc); }
Signature · 1 line
1.9.1
Re: [Qemu-devel] [PATCH 3/4] net: del hub port when peer is deleted
Quoted 13 lines · Jason Wang
We should del hub port when peer is deleted since it will not be reused and will only be freed during exit.
Signed-off-by Jason Wang <[email protected]>--- net/net.c | 2 ++ 1 file changed, 2 insertions(+)net/net.c +0
-0
net/net.c void net_host_device_remove(Monitor *mon, const QDict *qdict) · line 1002
Quoted 7 lines
net/net.c +2
-0@@ -996,6 +996,8 @@ void net_host_device_remove(Monitor *mon, const QDict *qdict)error_report ("invalid host network device '%s'" , device);return ; } + +qemu_del_net_client (nc->peer);qemu_del_net_client (nc); }
If qmp_netdev_del() is used the hub port will stay alive.
Should the peer deletion happen in qemu_del_net_client(), similar to the existing NIC peer check?
/* If there is a peer NIC, delete and cleanup client, but do not free. */ if (nc->peer && nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC) {
This way the hub port is consistently deleted when its peer is deleted.
Stefan
Re: [Qemu-devel] [PATCH 3/4] net: del hub port when peer is deleted
Quoted 24 lines · Stefan Hajnoczi
Quoted 15 lines · Jason Wang
We should del hub port when peer is deleted since it will not be
reused
and will only be freed during exit.Signed-off-by Jason Wang <[email protected]>---
net/net.c | 2 ++ 1 file changed, 2 insertions(+)diff --git
a/net/net.cb/net/net.c
index 7acc162..74e651e 100644
---a/net/net.c
+++b/net/net.c
@@ -996,6 +996,8 @@ void net_host_device_remove(Monitor *mon, const
QDict *qdict)Quoted 7 lines
error_report("invalid host network device '%s'", device); return; } + + qemu_del_net_client(nc->peer); qemu_del_net_client(nc);}
Quoted 1 line
If
qmp_netdev_del()is used the hub port will stay alive.
This is true if it has a peer. And the port will be freed during the deletion of its peer. If no peer, it will be deleted soon. This is consistent with the behaviors of other type of netdevs.
Quoted 10 lines
Should the peer deletion happen in
qemu_del_net_client(), similar to the existing NIC peer check?/* If there is a peer NIC, delete and cleanup client, but do not
free. */
if (nc->peer&&nc->peer->info->type==NET_CLIENT_OPTIONS_KIND_NIC) {This way the hub port is consistently deleted when its peer is deleted.
Not sure, but if management always do netdev_del after device_del, it will get an error.
Thanks
Quoted 3 lines
Stefan
Re: [Qemu-devel] [PATCH 3/4] net: del hub port when peer is deleted
Quoted 31 lines · Jason Wang
Quoted 14 lines · Stefan Hajnoczi
Quoted 13 lines · Jason Wang
We should del hub port when peer is deleted since it will not be reused and will only be freed during exit.
Signed-off-by Jason Wang <[email protected]>--- net/net.c | 2 ++ 1 file changed, 2 insertions(+)net/net.c +0
-0@@ -996,6 +996,8 @@ void net_host_device_remove(Monitor *mon, const QDict *qdict) error_report("invalid host network device '%s'", device);Quoted 8 lines
net/net.c void net_host_device_remove(Monitor *mon, const QDict *qdict) · line 1002
Quoted 6 lines
net/net.c +2
-0return ; } + +qemu_del_net_client (nc->peer);qemu_del_net_client (nc); }If
qmp_netdev_del()is used the hub port will stay alive.This is true if it has a peer. And the port will be freed during the deletion of its peer. If no peer, it will be deleted soon. This is consistent with the behaviors of other type of netdevs.
Quoted 4 lines
Should the peer deletion happen in
qemu_del_net_client(), similar to the existing NIC peer check?
Quoted 8 lines
Quoted 5 lines
/* If there is a peer NIC, delete and cleanup client, but do not free.
*/
if (nc->peer&&nc->peer->info->type==NET_CLIENT_OPTIONS_KIND_NIC) {This way the hub port is consistently deleted when its peer is deleted.
Not sure, but if management always do
netdev_delafterdevice_del, it will get an error.
Okay, I will merge this patch as-is.
Stefan
PATCH 4/4 monitor: more accurate completion for host_net_remove()
In reply to Jason WangCurrent completion for host_net_remove will show hub ports and clients that were not peered with hub ports. Fix this.
--- monitor.c | 5 +++++ 1 file changed, 5 insertions(+)
monitor.c +5 -0
@@ -4597,8 +4597,13 @@ void host_net_remove_completion(ReadLineState *rs, int nb_args, const char *str) count =qemu_find_net_clients_except (NULL , ncs,NET_CLIENT_OPTIONS_KIND_NIC ,255 );for (i =0 ; i < count; i++) { +int id;const char *name; +if (ncs[i]->info->type ==NET_CLIENT_OPTIONS_KIND_HUBPORT || +net_hub_id_for_client (ncs[i], &id)) { +continue ; + } name = ncs[i]->name;if (!strncmp (str, name, len)) {readline_add_completion (rs, name);
Signature · 1 line
1.9.1
Stefan Hajnoczi
AppliedQuoted 4 lines · Jason Wang
Signed-off-by Jason Wang <[email protected]>--- net/hub.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Thanks, applied to my net tree:
https://github.com/stefanha/qemu/commits/net
Stefan