]> git.proxmox.com Git - mirror_qemu.git/commitdiff
net: Make "info network" output more readable info
authorZhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Tue, 24 Jul 2012 15:35:16 +0000 (16:35 +0100)
committerStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Wed, 1 Aug 2012 12:32:11 +0000 (13:32 +0100)
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
net.c
net.h
net/hub.c

diff --git a/net.c b/net.c
index 88ccb2efc0145f38022741078b7a2eb5435e54ac..7edb52b5c80450d020a24b1c12ce2da4e9ac2d2c 100644 (file)
--- a/net.c
+++ b/net.c
@@ -855,7 +855,7 @@ void qmp_netdev_del(const char *id, Error **errp)
     qemu_opts_del(qemu_opts_find(qemu_find_opts_err("netdev", errp), id));
 }
 
-static void print_net_client(Monitor *mon, NetClientState *nc)
+void print_net_client(Monitor *mon, NetClientState *nc)
 {
     monitor_printf(mon, "%s: type=%s,%s\n", nc->name,
                    NetClientOptionsKind_lookup[nc->info->type], nc->info_str);
@@ -866,20 +866,25 @@ void do_info_network(Monitor *mon)
     NetClientState *nc, *peer;
     NetClientOptionsKind type;
 
-    monitor_printf(mon, "Devices not on any VLAN:\n");
+    net_hub_info(mon);
+
     QTAILQ_FOREACH(nc, &net_clients, next) {
         peer = nc->peer;
         type = nc->info->type;
+
+        /* Skip if already printed in hub info */
+        if (net_hub_id_for_client(nc, NULL) == 0) {
+            continue;
+        }
+
         if (!peer || type == NET_CLIENT_OPTIONS_KIND_NIC) {
-            monitor_printf(mon, "  ");
             print_net_client(mon, nc);
         } /* else it's a netdev connected to a NIC, printed with the NIC */
         if (peer && type == NET_CLIENT_OPTIONS_KIND_NIC) {
-            monitor_printf(mon, "   \\ ");
+            monitor_printf(mon, " \\ ");
             print_net_client(mon, peer);
         }
     }
-    net_hub_info(mon);
 }
 
 void qmp_set_link(const char *name, bool up, Error **errp)
diff --git a/net.h b/net.h
index 7e629d3aacf26191f6903f6144cc0c50ab98c6fe..adeef0c08da602efd8076a4b0fc0458f99411fd4 100644 (file)
--- a/net.h
+++ b/net.h
@@ -100,6 +100,7 @@ void qemu_check_nic_model(NICInfo *nd, const char *model);
 int qemu_find_nic_model(NICInfo *nd, const char * const *models,
                         const char *default_model);
 
+void print_net_client(Monitor *mon, NetClientState *nc);
 void do_info_network(Monitor *mon);
 
 /* NIC info */
index 900fa4ebb9db6b0640c0a3172a5ff5cc02b6c9a1..522fe990a2faae9c2fff5ad18d760b41e4b2dfb0 100644 (file)
--- a/net/hub.c
+++ b/net/hub.c
@@ -223,8 +223,10 @@ 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, "    port %d peer %s\n", port->id,
-                           port->nc.peer ? port->nc.peer->name : "<none>");
+            if (port->nc.peer) {
+                monitor_printf(mon, " \\ ");
+                print_net_client(mon, port->nc.peer);
+            }
         }
     }
 }