diff mbox

[v3,13/16] net: Make the monitor output more reasonable hub info

Message ID 1337882362-20100-14-git-send-email-zwu.kernel@gmail.com
State New
Headers show

Commit Message

Zhiyong Wu May 24, 2012, 5:59 p.m. UTC
From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
---
 net.c     |    7 ++++++-
 net/hub.c |    2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)

Comments

Jan Kiszka May 24, 2012, 8:34 p.m. UTC | #1
On 2012-05-24 14:59, zwu.kernel@gmail.com wrote:
> From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
> 
> Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
> ---
>  net.c     |    7 ++++++-
>  net/hub.c |    2 +-
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/net.c b/net.c
> index 61dc28d..79ac51f 100644
> --- a/net.c
> +++ b/net.c
> @@ -887,6 +887,12 @@ static const struct {
>          },
>      },
>  #endif /* CONFIG_NET_BRIDGE */
> +    [NET_CLIENT_TYPE_HUB] = {
> +        .type = "hubport",
> +        .desc = {
> +            { /* end of list */ }
> +        },
> +    },
>  };
>  
>  int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
> @@ -1079,7 +1085,6 @@ void do_info_network(Monitor *mon)
>      NetClientState *nc, *peer;
>      net_client_type type;
>  
> -    monitor_printf(mon, "Devices not on any VLAN:\n");
>      QTAILQ_FOREACH(nc, &net_clients, next) {
>          peer = nc->peer;
>          type = nc->info->type;
> diff --git a/net/hub.c b/net/hub.c
> index 0cc385e..8a583ab 100644
> --- a/net/hub.c
> +++ b/net/hub.c
> @@ -193,7 +193,7 @@ void net_hub_info(Monitor *mon)
>      QLIST_FOREACH(hub, &hubs, next) {
>          monitor_printf(mon, "hub %u\n", hub->id);
>          QLIST_FOREACH(port, &hub->ports, next) {
> -            monitor_printf(mon, "    port %u peer %s\n", port->id,
> +            monitor_printf(mon, "   \\ %s\n",
>                             port->nc.peer ? port->nc.peer->name : "<none>");
>          }
>      }

I still do not agree with this formatting (peer -> hubport + hub ->
abbreviated peers instead of just hub -> peers). But the series has a
higher value than this, and we can fix on top - unless there is a need
for another round anyway.

Jan
Zhiyong Wu May 25, 2012, 12:48 a.m. UTC | #2
On Fri, May 25, 2012 at 4:34 AM, Jan Kiszka <jan.kiszka@siemens.com> wrote:
> On 2012-05-24 14:59, zwu.kernel@gmail.com wrote:
>> From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
>>
>> Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
>> ---
>>  net.c     |    7 ++++++-
>>  net/hub.c |    2 +-
>>  2 files changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/net.c b/net.c
>> index 61dc28d..79ac51f 100644
>> --- a/net.c
>> +++ b/net.c
>> @@ -887,6 +887,12 @@ static const struct {
>>          },
>>      },
>>  #endif /* CONFIG_NET_BRIDGE */
>> +    [NET_CLIENT_TYPE_HUB] = {
>> +        .type = "hubport",
>> +        .desc = {
>> +            { /* end of list */ }
>> +        },
>> +    },
>>  };
>>
>>  int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
>> @@ -1079,7 +1085,6 @@ void do_info_network(Monitor *mon)
>>      NetClientState *nc, *peer;
>>      net_client_type type;
>>
>> -    monitor_printf(mon, "Devices not on any VLAN:\n");
>>      QTAILQ_FOREACH(nc, &net_clients, next) {
>>          peer = nc->peer;
>>          type = nc->info->type;
>> diff --git a/net/hub.c b/net/hub.c
>> index 0cc385e..8a583ab 100644
>> --- a/net/hub.c
>> +++ b/net/hub.c
>> @@ -193,7 +193,7 @@ void net_hub_info(Monitor *mon)
>>      QLIST_FOREACH(hub, &hubs, next) {
>>          monitor_printf(mon, "hub %u\n", hub->id);
>>          QLIST_FOREACH(port, &hub->ports, next) {
>> -            monitor_printf(mon, "    port %u peer %s\n", port->id,
>> +            monitor_printf(mon, "   \\ %s\n",
>>                             port->nc.peer ? port->nc.peer->name : "<none>");
>>          }
>>      }
>
> I still do not agree with this formatting (peer -> hubport + hub ->
> abbreviated peers instead of just hub -> peers). But the series has a
> higher value than this, and we can fix on top - unless there is a need
> for another round anyway.
OK, i agree.
>
> Jan
>
> --
> Siemens AG, Corporate Technology, CT T DE IT 1
> Corporate Competence Center Embedded Linux
Zhiyong Wu May 25, 2012, noon UTC | #3
On Fri, May 25, 2012 at 4:34 AM, Jan Kiszka <jan.kiszka@siemens.com> wrote:
> On 2012-05-24 14:59, zwu.kernel@gmail.com wrote:
>> From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
>>
>> Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
>> ---
>>  net.c     |    7 ++++++-
>>  net/hub.c |    2 +-
>>  2 files changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/net.c b/net.c
>> index 61dc28d..79ac51f 100644
>> --- a/net.c
>> +++ b/net.c
>> @@ -887,6 +887,12 @@ static const struct {
>>          },
>>      },
>>  #endif /* CONFIG_NET_BRIDGE */
>> +    [NET_CLIENT_TYPE_HUB] = {
>> +        .type = "hubport",
>> +        .desc = {
>> +            { /* end of list */ }
>> +        },
>> +    },
>>  };
>>
>>  int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
>> @@ -1079,7 +1085,6 @@ void do_info_network(Monitor *mon)
>>      NetClientState *nc, *peer;
>>      net_client_type type;
>>
>> -    monitor_printf(mon, "Devices not on any VLAN:\n");
>>      QTAILQ_FOREACH(nc, &net_clients, next) {
>>          peer = nc->peer;
>>          type = nc->info->type;
>> diff --git a/net/hub.c b/net/hub.c
>> index 0cc385e..8a583ab 100644
>> --- a/net/hub.c
>> +++ b/net/hub.c
>> @@ -193,7 +193,7 @@ void net_hub_info(Monitor *mon)
>>      QLIST_FOREACH(hub, &hubs, next) {
>>          monitor_printf(mon, "hub %u\n", hub->id);
>>          QLIST_FOREACH(port, &hub->ports, next) {
>> -            monitor_printf(mon, "    port %u peer %s\n", port->id,
>> +            monitor_printf(mon, "   \\ %s\n",
>>                             port->nc.peer ? port->nc.peer->name : "<none>");
>>          }
>>      }
>
> I still do not agree with this formatting (peer -> hubport + hub ->
> abbreviated peers instead of just hub -> peers). But the series has a
> higher value than this, and we can fix on top - unless there is a need
> for another round anyway.
Can the following formatting let you be happy?

(qemu) info network
hub 1
   \ dump.0: type=dump,dump to qemu-vlan1.pcap (len=65536)
   \ user.1: type=user,net=10.0.2.0,restrict=off
   \ virtio-net-pci.0: type=nic,model=virtio-net-pci,macaddr=52:54:00:12:34:58
hub 0
   \ user.0: type=user,net=10.0.2.0,restrict=off
   \ e1000.0: type=nic,model=e1000,macaddr=52:54:00:12:34:57
virtio-net-pci.1: type=nic,model=virtio-net-pci,macaddr=52:54:00:12:34:56
\ ur: type=tap,ifname=tap0,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown
(qemu)

>
> Jan
>
> --
> Siemens AG, Corporate Technology, CT T DE IT 1
> Corporate Competence Center Embedded Linux
Jan Kiszka May 25, 2012, 1:49 p.m. UTC | #4
On 2012-05-25 09:00, Zhi Yong Wu wrote:
> On Fri, May 25, 2012 at 4:34 AM, Jan Kiszka <jan.kiszka@siemens.com> wrote:
>> On 2012-05-24 14:59, zwu.kernel@gmail.com wrote:
>>> From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
>>>
>>> Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
>>> ---
>>>  net.c     |    7 ++++++-
>>>  net/hub.c |    2 +-
>>>  2 files changed, 7 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/net.c b/net.c
>>> index 61dc28d..79ac51f 100644
>>> --- a/net.c
>>> +++ b/net.c
>>> @@ -887,6 +887,12 @@ static const struct {
>>>          },
>>>      },
>>>  #endif /* CONFIG_NET_BRIDGE */
>>> +    [NET_CLIENT_TYPE_HUB] = {
>>> +        .type = "hubport",
>>> +        .desc = {
>>> +            { /* end of list */ }
>>> +        },
>>> +    },
>>>  };
>>>
>>>  int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
>>> @@ -1079,7 +1085,6 @@ void do_info_network(Monitor *mon)
>>>      NetClientState *nc, *peer;
>>>      net_client_type type;
>>>
>>> -    monitor_printf(mon, "Devices not on any VLAN:\n");
>>>      QTAILQ_FOREACH(nc, &net_clients, next) {
>>>          peer = nc->peer;
>>>          type = nc->info->type;
>>> diff --git a/net/hub.c b/net/hub.c
>>> index 0cc385e..8a583ab 100644
>>> --- a/net/hub.c
>>> +++ b/net/hub.c
>>> @@ -193,7 +193,7 @@ void net_hub_info(Monitor *mon)
>>>      QLIST_FOREACH(hub, &hubs, next) {
>>>          monitor_printf(mon, "hub %u\n", hub->id);
>>>          QLIST_FOREACH(port, &hub->ports, next) {
>>> -            monitor_printf(mon, "    port %u peer %s\n", port->id,
>>> +            monitor_printf(mon, "   \\ %s\n",
>>>                             port->nc.peer ? port->nc.peer->name : "<none>");
>>>          }
>>>      }
>>
>> I still do not agree with this formatting (peer -> hubport + hub ->
>> abbreviated peers instead of just hub -> peers). But the series has a
>> higher value than this, and we can fix on top - unless there is a need
>> for another round anyway.
> Can the following formatting let you be happy?
> 
> (qemu) info network
> hub 1
>    \ dump.0: type=dump,dump to qemu-vlan1.pcap (len=65536)
>    \ user.1: type=user,net=10.0.2.0,restrict=off
>    \ virtio-net-pci.0: type=nic,model=virtio-net-pci,macaddr=52:54:00:12:34:58
> hub 0
>    \ user.0: type=user,net=10.0.2.0,restrict=off
>    \ e1000.0: type=nic,model=e1000,macaddr=52:54:00:12:34:57
> virtio-net-pci.1: type=nic,model=virtio-net-pci,macaddr=52:54:00:12:34:56
> \ ur: type=tap,ifname=tap0,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown

Yes, this is what I was propose. You can just save the peer indentions
in the hub case.

Thanks!
Jan
Zhiyong Wu May 25, 2012, 1:58 p.m. UTC | #5
On Fri, May 25, 2012 at 9:49 PM, Jan Kiszka <jan.kiszka@siemens.com> wrote:
> On 2012-05-25 09:00, Zhi Yong Wu wrote:
>> On Fri, May 25, 2012 at 4:34 AM, Jan Kiszka <jan.kiszka@siemens.com> wrote:
>>> On 2012-05-24 14:59, zwu.kernel@gmail.com wrote:
>>>> From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
>>>>
>>>> Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
>>>> ---
>>>>  net.c     |    7 ++++++-
>>>>  net/hub.c |    2 +-
>>>>  2 files changed, 7 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/net.c b/net.c
>>>> index 61dc28d..79ac51f 100644
>>>> --- a/net.c
>>>> +++ b/net.c
>>>> @@ -887,6 +887,12 @@ static const struct {
>>>>          },
>>>>      },
>>>>  #endif /* CONFIG_NET_BRIDGE */
>>>> +    [NET_CLIENT_TYPE_HUB] = {
>>>> +        .type = "hubport",
>>>> +        .desc = {
>>>> +            { /* end of list */ }
>>>> +        },
>>>> +    },
>>>>  };
>>>>
>>>>  int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
>>>> @@ -1079,7 +1085,6 @@ void do_info_network(Monitor *mon)
>>>>      NetClientState *nc, *peer;
>>>>      net_client_type type;
>>>>
>>>> -    monitor_printf(mon, "Devices not on any VLAN:\n");
>>>>      QTAILQ_FOREACH(nc, &net_clients, next) {
>>>>          peer = nc->peer;
>>>>          type = nc->info->type;
>>>> diff --git a/net/hub.c b/net/hub.c
>>>> index 0cc385e..8a583ab 100644
>>>> --- a/net/hub.c
>>>> +++ b/net/hub.c
>>>> @@ -193,7 +193,7 @@ void net_hub_info(Monitor *mon)
>>>>      QLIST_FOREACH(hub, &hubs, next) {
>>>>          monitor_printf(mon, "hub %u\n", hub->id);
>>>>          QLIST_FOREACH(port, &hub->ports, next) {
>>>> -            monitor_printf(mon, "    port %u peer %s\n", port->id,
>>>> +            monitor_printf(mon, "   \\ %s\n",
>>>>                             port->nc.peer ? port->nc.peer->name : "<none>");
>>>>          }
>>>>      }
>>>
>>> I still do not agree with this formatting (peer -> hubport + hub ->
>>> abbreviated peers instead of just hub -> peers). But the series has a
>>> higher value than this, and we can fix on top - unless there is a need
>>> for another round anyway.
>> Can the following formatting let you be happy?
>>
>> (qemu) info network
>> hub 1
>>    \ dump.0: type=dump,dump to qemu-vlan1.pcap (len=65536)
>>    \ user.1: type=user,net=10.0.2.0,restrict=off
>>    \ virtio-net-pci.0: type=nic,model=virtio-net-pci,macaddr=52:54:00:12:34:58
>> hub 0
>>    \ user.0: type=user,net=10.0.2.0,restrict=off
>>    \ e1000.0: type=nic,model=e1000,macaddr=52:54:00:12:34:57
>> virtio-net-pci.1: type=nic,model=virtio-net-pci,macaddr=52:54:00:12:34:56
>> \ ur: type=tap,ifname=tap0,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown
>
> Yes, this is what I was propose. You can just save the peer indentions
> in the hub case.
OK. sent out v4 for this patch.
>
> Thanks!
> Jan
>
> --
> Siemens AG, Corporate Technology, CT T DE IT 1
> Corporate Competence Center Embedded Linux
diff mbox

Patch

diff --git a/net.c b/net.c
index 61dc28d..79ac51f 100644
--- a/net.c
+++ b/net.c
@@ -887,6 +887,12 @@  static const struct {
         },
     },
 #endif /* CONFIG_NET_BRIDGE */
+    [NET_CLIENT_TYPE_HUB] = {
+        .type = "hubport",
+        .desc = {
+            { /* end of list */ }
+        },
+    },
 };
 
 int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
@@ -1079,7 +1085,6 @@  void do_info_network(Monitor *mon)
     NetClientState *nc, *peer;
     net_client_type type;
 
-    monitor_printf(mon, "Devices not on any VLAN:\n");
     QTAILQ_FOREACH(nc, &net_clients, next) {
         peer = nc->peer;
         type = nc->info->type;
diff --git a/net/hub.c b/net/hub.c
index 0cc385e..8a583ab 100644
--- a/net/hub.c
+++ b/net/hub.c
@@ -193,7 +193,7 @@  void net_hub_info(Monitor *mon)
     QLIST_FOREACH(hub, &hubs, next) {
         monitor_printf(mon, "hub %u\n", hub->id);
         QLIST_FOREACH(port, &hub->ports, next) {
-            monitor_printf(mon, "    port %u peer %s\n", port->id,
+            monitor_printf(mon, "   \\ %s\n",
                            port->nc.peer ? port->nc.peer->name : "<none>");
         }
     }