[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Fix xm-test network tests to work with hvm support enabled.



# HG changeset patch
# User adam@xxxxxxxxxxx
# Node ID 324caad9e1457ab4ca020c51ac5a392b2d0392da
# Parent  e2755215a1e59751360e131bfccb081fdff94525
Fix xm-test network tests to work with hvm support enabled.

diff -r e2755215a1e5 -r 324caad9e145 tools/xm-test/lib/XmTestLib/Network.py
--- a/tools/xm-test/lib/XmTestLib/Network.py    Fri Feb 10 01:04:24 2006
+++ b/tools/xm-test/lib/XmTestLib/Network.py    Fri Feb 10 01:05:26 2006
@@ -25,6 +25,7 @@
 
 from Test import *
 from Xm import *
+from config import *
 
 class NetworkError(Exception):
     def __init__(self, msg):
@@ -36,6 +37,9 @@
 def undo_dom0_alias(eth, ip):
     traceCommand("ip addr del " + ip + " dev " + eth)
 
+def net_from_ip(ip):
+    return ip[:ip.rfind(".")] + ".0/24"
+    
 class XmNetwork:
 
     def __init__(self):
@@ -56,14 +60,21 @@
         domnum = int(dom[len("dom"):])
         return "169.254."+ str(ethnum+153) + "." + str(domnum+10)
 
-    def ip(self, dom, interface, todomname=None, toeth=None):
+    def ip(self, dom, interface, todomname=None, toeth=None, bridge=None):
         newip = self.calc_ip_address(dom, interface)
 
         # If the testcase is going to talk to dom0, we need to add an 
         # IP address in the proper subnet
         if dom == "dom0":
-            # The domain's vif is a convenient place to add to
-            vifname = "vif" + str(domid(todomname)) + "." + toeth[3:]
+           if ENABLE_HVM_SUPPORT:
+               # HVM uses ioemu which uses a bridge
+               if not bridge:
+                   SKIP("no bridge supplied")
+               else:
+                   vifname = bridge
+           else:
+                # The domain's vif is a convenient place to add to
+                vifname = "vif" + str(domid(todomname)) + "." + toeth[3:]
 
             # register the exit handler FIRST, just in case
             atexit.register(undo_dom0_alias, vifname, newip)
@@ -73,6 +84,15 @@
                                               " dev " + vifname)
             if status:
                 SKIP("\"ip addr add\" failed")
+
+           if ENABLE_HVM_SUPPORT:
+               # We need to add a route to the bridge device
+               network = net_from_ip(newip)
+               status, output = traceCommand("ip route add " + network + " dev 
" + vifname + " scope link")
+
+                if status:
+                   SKIP("\"ip route add\" failed")
+
         return newip
 
     def mask(self, dom, interface):
diff -r e2755215a1e5 -r 324caad9e145 
tools/xm-test/tests/network/02_network_local_ping_pos.py
--- a/tools/xm-test/tests/network/02_network_local_ping_pos.py  Fri Feb 10 
01:04:24 2006
+++ b/tools/xm-test/tests/network/02_network_local_ping_pos.py  Fri Feb 10 
01:05:26 2006
@@ -28,7 +28,11 @@
 mask = Net.mask("dom1", "eth0")
 
 # Fire up a guest domain w/1 nic
-config = {"vif" : ['ip=%s' % ip]}
+if ENABLE_HVM_SUPPORT:
+    config = {"vif" : ['type=ioemu']}
+else:
+    config = {"vif" : ['ip=%s' % ip ]}
+
 domain = XmTestDomain(extraConfig=config)
 try:
     domain.start()
diff -r e2755215a1e5 -r 324caad9e145 
tools/xm-test/tests/network/05_network_dom0_ping_pos.py
--- a/tools/xm-test/tests/network/05_network_dom0_ping_pos.py   Fri Feb 10 
01:04:24 2006
+++ b/tools/xm-test/tests/network/05_network_dom0_ping_pos.py   Fri Feb 10 
01:05:26 2006
@@ -31,7 +31,13 @@
         FAIL(str(e))
 
 # Fire up a guest domain w/1 nic
-config = {"vif"  : ["ip=%s" % ip]}
+if ENABLE_HVM_SUPPORT:
+    brg = "xenbr0"
+    config = {"vif" : ['type=ioemu, bridge=%s' % brg]}
+else:
+    config = {"vif" : ['ip=%s' % ip ]}
+    brg = None
+
 domain = XmTestDomain(extraConfig=config)
 try:
     domain.start()
@@ -52,7 +58,7 @@
 
 try:
     # Add a suitable dom0 IP address 
-    dom0ip = Net.ip("dom0", "eth0", todomname=domain.getName(), toeth="eth0")
+    dom0ip = Net.ip("dom0", "eth0", todomname=domain.getName(), toeth="eth0", 
bridge=brg)
 except NetworkError, e:
         FAIL(str(e))
 
diff -r e2755215a1e5 -r 324caad9e145 
tools/xm-test/tests/network/11_network_domU_ping_pos.py
--- a/tools/xm-test/tests/network/11_network_domU_ping_pos.py   Fri Feb 10 
01:04:24 2006
+++ b/tools/xm-test/tests/network/11_network_domU_ping_pos.py   Fri Feb 10 
01:05:26 2006
@@ -18,7 +18,11 @@
 from XmTestLib import *
 
 def netDomain(ip):
-    config = {"vif"  : ["ip=%s" % ip]}
+    if ENABLE_HVM_SUPPORT:
+        config = {"vif" : ['type=ioemu']}
+    else:
+        config = {"vif" : ['ip=%s' % ip ]}
+
     dom = XmTestDomain(extraConfig=config)
     try:
         dom.start()

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.