ia64/xen-unstable

changeset 8823:324caad9e145

Fix xm-test network tests to work with hvm support enabled.
author adam@ipcoast.com
date Fri Feb 10 02:05:26 2006 +0100 (2006-02-10)
parents e2755215a1e5
children 52b2dc7fb9b7
files tools/xm-test/lib/XmTestLib/Network.py tools/xm-test/tests/network/02_network_local_ping_pos.py tools/xm-test/tests/network/05_network_dom0_ping_pos.py tools/xm-test/tests/network/11_network_domU_ping_pos.py
line diff
     1.1 --- a/tools/xm-test/lib/XmTestLib/Network.py	Fri Feb 10 02:04:24 2006 +0100
     1.2 +++ b/tools/xm-test/lib/XmTestLib/Network.py	Fri Feb 10 02:05:26 2006 +0100
     1.3 @@ -25,6 +25,7 @@ import atexit;
     1.4  
     1.5  from Test import *
     1.6  from Xm import *
     1.7 +from config import *
     1.8  
     1.9  class NetworkError(Exception):
    1.10      def __init__(self, msg):
    1.11 @@ -36,6 +37,9 @@ class NetworkError(Exception):
    1.12  def undo_dom0_alias(eth, ip):
    1.13      traceCommand("ip addr del " + ip + " dev " + eth)
    1.14  
    1.15 +def net_from_ip(ip):
    1.16 +    return ip[:ip.rfind(".")] + ".0/24"
    1.17 +    
    1.18  class XmNetwork:
    1.19  
    1.20      def __init__(self):
    1.21 @@ -56,14 +60,21 @@ class XmNetwork:
    1.22          domnum = int(dom[len("dom"):])
    1.23          return "169.254."+ str(ethnum+153) + "." + str(domnum+10)
    1.24  
    1.25 -    def ip(self, dom, interface, todomname=None, toeth=None):
    1.26 +    def ip(self, dom, interface, todomname=None, toeth=None, bridge=None):
    1.27          newip = self.calc_ip_address(dom, interface)
    1.28  
    1.29          # If the testcase is going to talk to dom0, we need to add an 
    1.30          # IP address in the proper subnet
    1.31          if dom == "dom0":
    1.32 -            # The domain's vif is a convenient place to add to
    1.33 -            vifname = "vif" + str(domid(todomname)) + "." + toeth[3:]
    1.34 +	    if ENABLE_HVM_SUPPORT:
    1.35 +	        # HVM uses ioemu which uses a bridge
    1.36 +		if not bridge:
    1.37 +		    SKIP("no bridge supplied")
    1.38 +		else:
    1.39 +		    vifname = bridge
    1.40 +	    else:
    1.41 +                # The domain's vif is a convenient place to add to
    1.42 +                vifname = "vif" + str(domid(todomname)) + "." + toeth[3:]
    1.43  
    1.44              # register the exit handler FIRST, just in case
    1.45              atexit.register(undo_dom0_alias, vifname, newip)
    1.46 @@ -73,6 +84,15 @@ class XmNetwork:
    1.47                                                " dev " + vifname)
    1.48              if status:
    1.49                  SKIP("\"ip addr add\" failed")
    1.50 +
    1.51 +	    if ENABLE_HVM_SUPPORT:
    1.52 +	        # We need to add a route to the bridge device
    1.53 +		network = net_from_ip(newip)
    1.54 +		status, output = traceCommand("ip route add " + network + " dev " + vifname + " scope link")
    1.55 +
    1.56 +                if status:
    1.57 +		    SKIP("\"ip route add\" failed")
    1.58 +
    1.59          return newip
    1.60  
    1.61      def mask(self, dom, interface):
     2.1 --- a/tools/xm-test/tests/network/02_network_local_ping_pos.py	Fri Feb 10 02:04:24 2006 +0100
     2.2 +++ b/tools/xm-test/tests/network/02_network_local_ping_pos.py	Fri Feb 10 02:05:26 2006 +0100
     2.3 @@ -28,7 +28,11 @@ ip   = Net.ip("dom1", "eth0")
     2.4  mask = Net.mask("dom1", "eth0")
     2.5  
     2.6  # Fire up a guest domain w/1 nic
     2.7 -config = {"vif" : ['ip=%s' % ip]}
     2.8 +if ENABLE_HVM_SUPPORT:
     2.9 +    config = {"vif" : ['type=ioemu']}
    2.10 +else:
    2.11 +    config = {"vif" : ['ip=%s' % ip ]}
    2.12 +
    2.13  domain = XmTestDomain(extraConfig=config)
    2.14  try:
    2.15      domain.start()
     3.1 --- a/tools/xm-test/tests/network/05_network_dom0_ping_pos.py	Fri Feb 10 02:04:24 2006 +0100
     3.2 +++ b/tools/xm-test/tests/network/05_network_dom0_ping_pos.py	Fri Feb 10 02:05:26 2006 +0100
     3.3 @@ -31,7 +31,13 @@ except NetworkError, e:
     3.4          FAIL(str(e))
     3.5  
     3.6  # Fire up a guest domain w/1 nic
     3.7 -config = {"vif"  : ["ip=%s" % ip]}
     3.8 +if ENABLE_HVM_SUPPORT:
     3.9 +    brg = "xenbr0"
    3.10 +    config = {"vif" : ['type=ioemu, bridge=%s' % brg]}
    3.11 +else:
    3.12 +    config = {"vif" : ['ip=%s' % ip ]}
    3.13 +    brg = None
    3.14 +
    3.15  domain = XmTestDomain(extraConfig=config)
    3.16  try:
    3.17      domain.start()
    3.18 @@ -52,7 +58,7 @@ except ConsoleError, e:
    3.19  
    3.20  try:
    3.21      # Add a suitable dom0 IP address 
    3.22 -    dom0ip = Net.ip("dom0", "eth0", todomname=domain.getName(), toeth="eth0")
    3.23 +    dom0ip = Net.ip("dom0", "eth0", todomname=domain.getName(), toeth="eth0", bridge=brg)
    3.24  except NetworkError, e:
    3.25          FAIL(str(e))
    3.26  
     4.1 --- a/tools/xm-test/tests/network/11_network_domU_ping_pos.py	Fri Feb 10 02:04:24 2006 +0100
     4.2 +++ b/tools/xm-test/tests/network/11_network_domU_ping_pos.py	Fri Feb 10 02:05:26 2006 +0100
     4.3 @@ -18,7 +18,11 @@ pingsizes = [ 1, 48, 64, 512, 1440, 1500
     4.4  from XmTestLib import *
     4.5  
     4.6  def netDomain(ip):
     4.7 -    config = {"vif"  : ["ip=%s" % ip]}
     4.8 +    if ENABLE_HVM_SUPPORT:
     4.9 +        config = {"vif" : ['type=ioemu']}
    4.10 +    else:
    4.11 +        config = {"vif" : ['ip=%s' % ip ]}
    4.12 +
    4.13      dom = XmTestDomain(extraConfig=config)
    4.14      try:
    4.15          dom.start()