James Harper
2007-Oct-08 05:36 UTC
[Xen-users] How to tell which tapX interface belongs to which domain...
I''ve put together a script to get the traffic counters for a given vm interface (eg "vmif_traffic <domain> <if index>") and it works great except when the interface backend is ioemu, because all the traffic goes through the tapX interface instead of the vif interface. Is there a way to tell what the tapX interface is for a given domain''s interface? Thanks James _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Christian Horn
2007-Oct-08 16:56 UTC
Re: [Xen-users] How to tell which tapX interface belongs to which domain...
On Mon, Oct 08, 2007 at 03:36:39PM +1000, James Harper wrote:> I''ve put together a script to get the traffic counters for a given vm > interface (eg "vmif_traffic <domain> <if index>") and it works great > except when the interface backend is ioemu, because all the traffic goes > through the tapX interface instead of the vif interface.I''m just doing the same, and besides not getting i/o yet i also miss the number of tap-interfaces, would fit into ''xm list -l <domain>'' output. An idea to get the mapping could be to have a look on what tap-interfaces are in use bevore domain-creation and after, the interfaces in use now are the ones belonging to the domain. Had a look at the filehandles that are open for /dev/net/tun and the qemu-dm processed, and at the logfiles, without better hints. Christian _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
James Harper
2007-Oct-09 02:00 UTC
RE: [Xen-users] How to tell which tapX interface belongs to which domain...
> On Mon, Oct 08, 2007 at 03:36:39PM +1000, James Harper wrote: > > I''ve put together a script to get the traffic counters for a givenvm> > interface (eg "vmif_traffic <domain> <if index>") and it works great > > except when the interface backend is ioemu, because all the trafficgoes> > through the tapX interface instead of the vif interface. > > I''m just doing the same, and besides not getting i/o yet i also missthe> number of tap-interfaces, would fit into ''xm list -l <domain>'' output. > An idea to get the mapping could be to have a look on whattap-interfaces> are in use bevore domain-creation and after, the interfaces in use now > are the ones belonging to the domain. > > Had a look at the filehandles that are open for /dev/net/tun and the > qemu-dm processed, and at the logfiles, without better hints.I noticed that when I do a ''brctl show'', the tap interface is on the line before the vif interface, so I made use of that. Hopefully it''s always true! James _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
James Harper
2007-Oct-09 02:13 UTC
RE: [Xen-users] How to tell which tapX interface belongs to which domain...
212-798> -----Original Message----- > From: James Harper > Sent: Tuesday, 9 October 2007 12:00 > To: ''Christian Horn'' > Cc: xen-users@lists.xensource.com > Subject: RE: [Xen-users] How to tell which tapX interface belongs towhich> domain... > > > On Mon, Oct 08, 2007 at 03:36:39PM +1000, James Harper wrote: > > > I''ve put together a script to get the traffic counters for a givenvm> > > interface (eg "vmif_traffic <domain> <if index>") and it worksgreat> > > except when the interface backend is ioemu, because all thetraffic> goes > > > through the tapX interface instead of the vif interface. > > > > I''m just doing the same, and besides not getting i/o yet i also missthe> > number of tap-interfaces, would fit into ''xm list -l <domain>''output.> > An idea to get the mapping could be to have a look on what tap- > interfaces > > are in use bevore domain-creation and after, the interfaces in usenow> > are the ones belonging to the domain. > > > > Had a look at the filehandles that are open for /dev/net/tun and the > > qemu-dm processed, and at the logfiles, without better hints. > > I noticed that when I do a ''brctl show'', the tap interface is on theline> before the vif interface, so I made use of that. Hopefully it''s always > true! > > James_______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
James Harper
2007-Oct-09 02:22 UTC
RE: [Xen-users] How to tell which tapX interface belongs to which domain...
Err... sorry... I hit reply to the wrong email :)> -----Original Message----- > From: James Harper > Sent: Tuesday, 9 October 2007 12:13 > To: James Harper; Christian Horn > Cc: xen-users@lists.xensource.com > Subject: RE: [Xen-users] How to tell which tapX interface belongs towhich> domain... > > 212-798 > > > -----Original Message----- > > From: James Harper > > Sent: Tuesday, 9 October 2007 12:00 > > To: ''Christian Horn'' > > Cc: xen-users@lists.xensource.com > > Subject: RE: [Xen-users] How to tell which tapX interface belongs to > which > > domain... > > > > > On Mon, Oct 08, 2007 at 03:36:39PM +1000, James Harper wrote: > > > > I''ve put together a script to get the traffic counters for agiven> vm > > > > interface (eg "vmif_traffic <domain> <if index>") and it worksgreat> > > > except when the interface backend is ioemu, because all thetraffic> > goes > > > > through the tapX interface instead of the vif interface. > > > > > > I''m just doing the same, and besides not getting i/o yet i alsomiss> the > > > number of tap-interfaces, would fit into ''xm list -l <domain>''output.> > > An idea to get the mapping could be to have a look on what tap- > > interfaces > > > are in use bevore domain-creation and after, the interfaces in usenow> > > are the ones belonging to the domain. > > > > > > Had a look at the filehandles that are open for /dev/net/tun andthe> > > qemu-dm processed, and at the logfiles, without better hints. > > > > I noticed that when I do a ''brctl show'', the tap interface is on the > line > > before the vif interface, so I made use of that. Hopefully it''salways> > true! > > > > James_______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Christian Horn
2007-Oct-09 05:30 UTC
Re: [Xen-users] How to tell which tapX interface belongs to which domain...
On Tue, Oct 09, 2007 at 12:00:29PM +1000, James Harper wrote:> > I noticed that when I do a ''brctl show'', the tap interface is on the > line before the vif interface, so I made use of that. Hopefully it''s > always true!Also seen that, but how do you conclude from that to which domU the tap-device belongs? I think i found something usable: - ping the ip of the domU on the tap-interface you want to identify, i.e. ''ping -c2 ch_hvmadm'' I also have the mac of my domU on that interface from the xen-config, its aa:00:00:00:00:03 in this case. - from the ping we have the mac in the arp-cache, and ''brctl showmacs xenadm0'' shows the macs known on that bridge: ----------- port no mac addr is local? ageing timer 2 00:03:d2:11:0d:fb no 1.57 [....] 4 6e:14:9d:77:3a:cd yes 0.00 4 aa:00:00:00:00:03 no 138.21 1 fe:ff:ff:ff:ff:ff yes 0.00 ----------- - the ''port'' column of my well-known mac is important, its 4. Issuing ''brctl show'' i get the connected tap-interface on the 4th line: ----------- bridge name bridge id STP enabled interfaces xenadm0 8000.6e149d773acd no vif0.0 peth0 vif1.0 tap0 vif17.0 [.....] ----------- So now for implementing it into my perl/rrdtool scripts.. Christian _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
James Harper
2007-Oct-09 05:35 UTC
RE: [Xen-users] How to tell which tapX interface belongs to which domain...
> On Tue, Oct 09, 2007 at 12:00:29PM +1000, James Harper wrote: > > > > I noticed that when I do a ''brctl show'', the tap interface is on the > > line before the vif interface, so I made use of that. Hopefully it''s > > always true! > > Also seen that, but how do you conclude from that to which domU the > tap-device belongs? >You can get that from xenstore. My scripts are (excuse the line feeds): 1. Generic interface script (parameter is interface name): " #!/bin/sh cat /proc/net/dev | egrep "^[ ]*$1:" | sed ''s/[ ]*[^:][^:]*://'' | while read rxbytes rxpackets rxerrs rxdrop rxfifo rxframe rxcompressed rxmulticast txbytes txpackets txerrs txdrop txfifo txcolls txcarrier txcompressed do echo $rxbytes echo $txbytes uptime | cut -c14- | sed ''s/, .*//'' hostname done " 2. DomU interface script (parameters are domain name and interface index) " #!/bin/sh domname=$1 vifindex=$2 /usr/sbin/xenstore-list /local/domain | while read domid do name=`/usr/sbin/xenstore-read /local/domain/$domid/name` if [ "$name" = "$domname" ] then type=`/usr/sbin/xenstore-read /local/domain/0/backend/vif/$domid/$vifindex/type 2>/dev/null` if [ "$type" = "ioemu" ] then if=`/usr/sbin/brctl show | sed ''s/.*[ ]//'' | egrep -B 1 "^vif$domid.$vifindex" | head -1` else if=vif$domid.$vifindex fi /usr/local/bin/if_traffic $if exit fi done " The only problem I can see with the second script, is that I don''t think you can rely on the ''ioemu'' text being present in that key, on another machine it is blank. It probably comes from the config script... James _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Christian Horn
2007-Oct-09 14:16 UTC
Re: [Xen-users] How to tell which tapX interface belongs to which domain...
On Tue, Oct 09, 2007 at 03:35:47PM +1000, James Harper wrote:> > You can get that from xenstore. > > [..] > > /usr/sbin/xenstore-list /local/domain | while read domid > do > name=`/usr/sbin/xenstore-read /local/domain/$domid/name` > > if [ "$name" = "$domname" ] > then > type=`/usr/sbin/xenstore-read > /local/domain/0/backend/vif/$domid/$vifindex/type 2>/dev/null` > if [ "$type" = "ioemu" ] > then > if=`/usr/sbin/brctl show | sed ''s/.*[ ]//'' | egrep -B 1 > "^vif$domid.$vifindex" | head -1` > else > if=vif$domid.$vifindex > fi > /usr/local/bin/if_traffic $if > exit > fi > done > "Works great, thanks. And /proc/net/dev gives me all values at ones, till today i read single files under /sys for each interface.> The only problem I can see with the second script, is that I don''t think > you can rely on the ''ioemu'' text being present in that key, on another > machine it is blank. It probably comes from the config script...My perl-script here returns different errorcodes for ''value could not be read'' (=para-domU) and ''error executing xenstore-read'' at all. Christian _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
James Oakley
2007-Oct-10 18:03 UTC
Re: [Xen-users] How to tell which tapX interface belongs to which domain...
On October 9, 2007, Christian Horn wrote:> - from the ping we have the mac in the arp-cache, and > ''brctl showmacs xenadm0'' shows the macs known on that bridge: > ----------- > port no mac addr is local? ageing timer > 2 00:03:d2:11:0d:fb no 1.57 > [....] > 4 6e:14:9d:77:3a:cd yes 0.00 > 4 aa:00:00:00:00:03 no 138.21 > 1 fe:ff:ff:ff:ff:ff yes 0.00 > ----------- > > > - the ''port'' column of my well-known mac is important, its 4. > Issuing ''brctl show'' i get the connected tap-interface on the > 4th line: > ----------- > bridge name bridge id STP enabled interfaces > xenadm0 8000.6e149d773acd no vif0.0 > peth0 > vif1.0 > tap0 > vif17.0 > [.....] > -----------One thing to watch out for: While the port number gets incremented for each device you add to the bridge, any devices that are removed leave a hole. If you remove vif1.0 from the bridge above, tap0 will still be port 4, but it will be the third entry in ''brctl show'' output. If you start/stop instances a lot, you will run into that problem. Unfortunately, the true mapping is not exposed to userspace. At least I could not find it in linux/if_bridge.h. -- James Oakley jfunk@funktronics.ca _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users