From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH v4 13/16] net: Make "info network" output more readable info Date: Fri, 25 May 2012 11:50:50 -0300 Message-ID: <4FBF9C4A.7010407@siemens.com> References: <1337954529-9099-1-git-send-email-zwu.kernel@gmail.com> <4FBF9483.5040001@siemens.com> <4FBF99C5.1060505@siemens.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: "qemu-devel@nongnu.org" , "kvm@vger.kernel.org" , "pbonzini@redhat.com" , "stefanha@linux.vnet.ibm.com" , "wuzhy@linux.vnet.ibm.com" To: Zhi Yong Wu Return-path: Received: from david.siemens.de ([192.35.17.14]:23900 "EHLO david.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752927Ab2EYOvG (ORCPT ); Fri, 25 May 2012 10:51:06 -0400 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On 2012-05-25 11:44, Zhi Yong Wu wrote: > On Fri, May 25, 2012 at 10:40 PM, Jan Kiszka wrote: >> On 2012-05-25 11:25, Zhi Yong Wu wrote: >>>>> diff --git a/net/hub.c b/net/hub.c >>>>> index 122de69..8c77d03 100644 >>>>> --- a/net/hub.c >>>>> +++ b/net/hub.c >>>>> @@ -184,6 +184,25 @@ NetClientState *net_hub_find_client_by_name(unsigned int hub_id, >>>>> } >>>>> >>>>> /** >>>>> + * Determine if one nc peers with one hub port >>>>> + */ >>>>> +bool net_hub_port_peer_nc(NetClientState *nc) >>>>> +{ >>>>> + NetHub *hub; >>>>> + NetHubPort *port; >>>>> + >>>>> + QLIST_FOREACH(hub, &hubs, next) { >>>>> + QLIST_FOREACH(port, &hub->ports, next) { >>>>> + if (nc == port->nc.peer) { >>>>> + return true; >>>>> + } >>>>> + } >>>>> + } >>>>> + >>>>> + return false; >>>>> +} >>>>> + >>>>> +/** >>>>> * Print hub configuration >>>>> */ >>>>> void net_hub_info(Monitor *mon) >>>>> @@ -194,8 +213,8 @@ 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, >>>>> - port->nc.peer ? port->nc.peer->name : ""); >>>>> + monitor_printf(mon, " \\ "); >>> This will have the following layout: >>> (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 >>> ^^^ >>>> >>>> Two space too much of indention (you remove them above for the existing >>> It is three space, not two. >>>> peer \ peer outputs). >>> Do you mean that it should be like "monitor_printf(mon, "\\ ");" but >>> this indention will not match with those peers in hub case. >> >> This line is for printing peers attached to a hub, isn't it? So it > Yeah, but it is three spaces, not one. You can check the code in > do_info_network. For non-hub peers, it is also three spaces. Then non-hub needs adjustment to a single space as well. Just remove the two spaces I added to indent the categories (VLAN vs. non-VLAN listing) for _both_ peer lines. (I love nit-picking discussions :) ) Jan -- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux