WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-users

RE: [Xen-users] How to tell which tapX interface belongs to which domain

To: "Christian Horn" <chorn@xxxxxxxxxxxx>
Subject: RE: [Xen-users] How to tell which tapX interface belongs to which domain...
From: "James Harper" <james.harper@xxxxxxxxxxxxxxxx>
Date: Tue, 9 Oct 2007 15:35:47 +1000
Cc: xen-users@xxxxxxxxxxxxxxxxxxx
Delivery-date: Mon, 08 Oct 2007 22:37:35 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <20071009053051.GA18951@xxxxxxxxxxxx>
List-help: <mailto:xen-users-request@lists.xensource.com?subject=help>
List-id: Xen user discussion <xen-users.lists.xensource.com>
List-post: <mailto:xen-users@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=unsubscribe>
References: <AEC6C66638C05B468B556EA548C1A77D012499FA@trantor> <20071008165642.GA17799@xxxxxxxxxxxx> <AEC6C66638C05B468B556EA548C1A77D01249A1A@trantor> <20071009053051.GA18951@xxxxxxxxxxxx>
Sender: xen-users-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcgKNZ9AH8GcPlaGREmZGqnA0zVthwAABnug
Thread-topic: [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@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users