New Network Infrastructure for Xm-Test
PATCH 3/3 New Network Infrastructure for Xm-Test
This patch adds the new network infrastructure. It removes the existing Network.py and adds XenDevice.py and NetConfig.py. This patch basically adds the same functionality we had, but makes it much much easier. It also allows people to configure a range of IPs for a bridge environment, done when xm-test is configured.
This patch creates a new XenDevice and XenNetDevice to work with devices. These new objects should only be reverenced through XenDomain methods. Until support for attaching and detaching devices in xm-test is added, XenDevices must be added prior to starting a domain.
Support for DHCP and routed or NAT environments will be added later.
All comments welcome.
Thanks,
Dan
# HG changeset patch
# User [email protected] # Node ID 38ccc3bbb68f80511363b961e84fc912d29e6fce # Parent 45aaca4aed38771243e32414cc6964f306751bda
Add new networking infrastructure to Xm-Test. The goal is to make creating domains with networking very easy. This patch:
1) Adds new XenDevice class, with the XenNetDevice subclass. These classes represent devices for xm-test and are tied to XenDomains. This can eventually be used for block devices as well. Currently, devices must be added to domains prior to starting the domain. The attach and detach needs to be handled.
2) Adds a new NetConfig class to handle configuring the network environment in which the tests run. This patch only handles ranges of IPs in a bridged environment. DHCP needs to be added as well as handling NAT and routed environments.
3) Modifies XenDomain class to handle XenDevices.
4) Adds new configuration options for defining a range of IPs, their network address, and their netmask.
5) Removes the old Network.py and Network class.
6) Modifies the existing tests to use the new infrastructure.
7) Adds some documentation to help creating domains.
tools/xm-test/configure.ac +30 -0
@@ -37,6 +37,36 @@ AM_CONDITIONAL(HVM, test x$ENABLE_HVM = xTrue) AC_SUBST(ENABLE_HVM) + +# Network needs to know ips to use: dhcp or a range of IPs in the form +# of: 192.168.1.1-192.168.1.100 +# If not dhcp, a netmask and network address must be supplied. Defaults to +# zeroconf range. +NET_IP_RANGE="169.254.0.1-169.254.255.255" +AC_ARG_WITH(net-ip-range, + [ --with-net-ip-range=ip-range Set a range of ip addresses to use for xm-test guest domain networks. Can specify dhcp or a range of IPs: 192.168.1.1-192.168.1.100 [[default="169.254.0.1-169.254.255.255"]]], + [ NET_IP_RANGE="$withval" ]) + +iprange=`echo $NET_IP_RANGE | perl -e 'while(<>) { print if /\d+\.\d+\.\d+\.\d+-\d+\.\d+\.\d+\.\d+/ }'` + +NETWORK_ADDRESS="169.254.0.0" +AC_ARG_WITH(network-address, + [ --with-network-address=ip Set network address to use with ip range [[default="169.254.0.0"]]], + [ NETWORK_ADDRESS="$withval" ]) + +NETMASK="255.255.0.0" +AC_ARG_WITH(netmask, + [ --with-netmask=mask Set netmask to use with ip range [[default="255.255.0.0"]]], + [ NETMASK="$withval" ]) + +if test "x$NET_IP_RANGE" != "xdhcp" && test -z "$iprange" +then + AC_MSG_ERROR(Invalid net-ip-range.) +fi + +AC_SUBST(NET_IP_RANGE) +AC_SUBST(NETWORK_ADDRESS) +AC_SUBST(NETMASK) AC_ARG_WITH(hvm-kernel, [[ --with-hvm-kernel=kernel Use this kernel for hvm disk.img testing]],
tools/xm-test/lib/XmTestLib/XenDomain.py +79 -0
121 lines not on this page · raw message
tools/xm-test/lib/XmTestLib/__init__.py +8 -2
@@ -4,11 +4,15 @@ # from Console import * -from Network import * from Test import * from Xm import * from XenDomain import * from config import * +from XenDevice import * +from NetConfig import * + +# Make sure xen modules are in path +sys.path.append('/usr/lib/python') # Give this test a clean slate destroyAllDomUs();
@@ -18,6 +22,8 @@ else: verbose = False - if verbose: timeStamp() + +# We need to track network configuration, like ips, etc. +xmtest_netconf = NetConfig()
tools/xm-test/lib/XmTestLib/config.py.in +3 -1
@@ -1,4 +1,6 @@ #!/usr/bin/python ENABLE_HVM_SUPPORT = @ENABLE_HVM@ - +NETWORK_IP_RANGE = "@NET_IP_RANGE@" +NETWORK = "@NETWORK_ADDRESS@" +NETMASK = "@NETMASK@"
tools/xm-test/tests/create/13_create_multinic_pos.py +2 -5
@@ -5,17 +5,14 @@ from XmTestLib import * -# The current device model, qemu-dm, only supports 8 MAX_NICS currently. +# The device model, qemu-dm, only supports 8 MAX_NICS currently. if ENABLE_HVM_SUPPORT: MAX_NICS = 8 - nic = "type=ioemu, bridge=xenbr0" else: MAX_NICS = 10 - nic = '' for i in range(0,MAX_NICS): - config = {"vif": [ nic ] * i} - domain = XmTestDomain(extraConfig=config) + domain = XmTestNetDomain() try: console = domain.start()
tools/xm-test/tests/network/02_network_local_ping_pos.py +10 -17
@@ -16,24 +16,17 @@ pingsizes = [ 1, 48, 64, 512, 1440, 1500, 1505, 4096, 4192, 32767, 65507 ] - - from XmTestLib import * rc = 0 -Net = XmNetwork() +# Test creates 1 domain, which requires 2 ips: 1 for the domains and 1 for +# aliases on dom0 +if xmtest_netconf.canRunNetTest(2) == False: + SKIP("Don't have enough free configured IPs to run this test") -# read an IP address from the config -ip = Net.ip("dom1", "eth0") -mask = Net.mask("dom1", "eth0") +domain = XmTestDomain() +domain.newDevice(XenNetDevice, "eth0") -# Fire up a guest domain w/1 nic -if ENABLE_HVM_SUPPORT: - config = {"vif" : ['type=ioemu']} -else: - config = {"vif" : ['ip=%s' % ip ]} - -domain = XmTestDomain(extraConfig=config) try: console = domain.start() except DomainError, e:
@@ -43,10 +36,7 @@ FAIL(str(e)) try: - # Bring up the "lo" interface. - console.runCmd("ifconfig lo 127.0.0.1") - - console.runCmd("ifconfig eth0 inet "+ip+" netmask "+mask+" up") + console.setHistorySaveCmds(value=True) # First the loopback pings lofails=""
@@ -57,6 +47,8 @@ # Next comes eth0 eth0fails="" + netdev = domain.getDevice("eth0") + ip = netdev.getNetDevIP() for size in pingsizes: out = console.runCmd("ping -q -c 1 -s " + str(size) + " " + ip) if out["return"]:
@@ -66,6 +58,7 @@ except NetworkError, e: FAIL(str(e)) +domain.stop() # Tally up failures failures=""
tools/xm-test/tests/network/03_network_local_tcp_pos.py +10 -20
@@ -17,28 +17,18 @@ trysizes = [ 1, 48, 64, 512, 1440, 1448, 1500, 1505, 4096, 4192, 32767, 65495 ] - from XmTestLib import * rc = 0 -Net = XmNetwork() - -try: - # read an IP address from the config - ip = Net.ip("dom1", "eth0") - mask = Net.mask("dom1", "eth0") -except NetworkError, e: - FAIL(str(e)) +# Test creates 1 domain, which requires 2 ips: 1 for the domains and 1 for +# aliases on dom0 +if xmtest_netconf.canRunNetTest(2) == False: + SKIP("Don't have enough free configured IPs to run this test") # Fire up a guest domain w/1 nic -if ENABLE_HVM_SUPPORT: - brg = "xenbr0" - config = {"vif" : ['type=ioemu, bridge=%s' % brg]} -else: - brg = None - config = {"vif" : ['ip=%s' % ip]} +domain = XmTestDomain() +domain.newDevice(XenNetDevice, "eth0") -domain = XmTestDomain(extraConfig=config) try: console = domain.start() except DomainError, e:
@@ -48,10 +38,7 @@ FAIL(str(e)) try: - # Bring up the "lo" interface. - console.runCmd("ifconfig lo 127.0.0.1") - - console.runCmd("ifconfig eth0 inet "+ip+" netmask "+mask+" up") + console.setHistorySaveCmds(value=True) # First do loopback lofails=""
@@ -63,6 +50,8 @@ # Next comes eth0 eth0fails="" + netdev = domain.getDevice("eth0") + ip = netdev.getNetDevIP() for size in trysizes: out = console.runCmd("hping2 " + ip + " -E /dev/urandom -q -c 20 " + "--fast -d "+ str(size))
@@ -73,6 +62,7 @@ except NetworkError, e: FAIL(str(e)) +domain.stop() # Tally up failures failures=""
tools/xm-test/tests/network/04_network_local_udp_pos.py +10 -20
@@ -20,24 +20,14 @@ from XmTestLib import * rc = 0 -Net = XmNetwork() +# Test creates 1 domain, which requires 2 ips: 1 for the domains and 1 for +# aliases on dom0 +if xmtest_netconf.canRunNetTest(2) == False: + SKIP("Don't have enough free configured IPs to run this test") -try: - # read an IP address from the config - ip = Net.ip("dom1", "eth0") - mask = Net.mask("dom1", "eth0") -except NetworkError, e: - FAIL(str(e)) +domain = XmTestDomain() +domain.newDevice(XenNetDevice, "eth0") -# Fire up a guest domain w/1 nic -if ENABLE_HVM_SUPPORT: - brg = "xenbr0" - config = {"vif" : ['type=ioemu, bridge=%s' % brg]} -else: - brg = None - config = {"vif" : ['ip=%s' % ip]} - -domain = XmTestDomain(extraConfig=config) try: console = domain.start() except DomainError, e:
@@ -47,10 +37,7 @@ FAIL(str(e)) try: - # Bring up the "lo" interface. - console.runCmd("ifconfig lo 127.0.0.1") - - console.runCmd("ifconfig eth0 inet "+ip+" netmask "+mask+" up") + console.setHistorySaveCmds(value=True) # First do loopback lofails=""
@@ -63,6 +50,8 @@ # Next comes eth0 eth0fails="" + netdev = domain.getDevice("eth0") + ip = netdev.getNetDevIP() for size in trysizes: out = console.runCmd("hping2 " + ip + " -E /dev/urandom -2 -q -c 20 " + "--fast -d " + str(size))
@@ -74,6 +63,7 @@ except NetworkError, e: FAIL(str(e)) +domain.stop() # Tally up failures failures=""
tools/xm-test/tests/network/05_network_dom0_ping_pos.py +10 -26
@@ -16,29 +16,18 @@ pingsizes = [ 1, 48, 64, 512, 1440, 1500, 1505, 4096, 4192, 32767, 65507 ] - - from XmTestLib import * rc = 0 -Net = XmNetwork() - -try: - # read an IP address from the config - ip = Net.ip("dom1", "eth0") - mask = Net.mask("dom1", "eth0") -except NetworkError, e: - FAIL(str(e)) +# Test creates 1 domain, which requires 2 ips: 1 for the domains and 1 for +# aliases on dom0 +if xmtest_netconf.canRunNetTest(2) == False: + SKIP("Don't have enough free configured IPs to run this test") # Fire up a guest domain w/1 nic -if ENABLE_HVM_SUPPORT: - brg = "xenbr0" - config = {"vif" : ['type=ioemu, bridge=%s' % brg]} -else: - config = {"vif" : ['ip=%s' % ip ]} - brg = None +domain = XmTestDomain() +domain.newDevice(XenNetDevice, "eth0") -domain = XmTestDomain(extraConfig=config) try: console = domain.start() except DomainError, e:
@@ -48,16 +37,10 @@ FAIL(str(e)) try: - # Add a suitable dom0 IP address - dom0ip = Net.ip("dom0", "eth0", todomname=domain.getName(), toeth="eth0", bridge=brg) -except NetworkError, e: - FAIL(str(e)) - -try: - console.runCmd("ifconfig eth0 inet "+ip+" netmask "+mask+" up") - # Ping dom0 fails="" + netdev = domain.getDevice("eth0") + dom0ip = netdev.getDom0AliasIP() for size in pingsizes: out = console.runCmd("ping -q -c 1 -s " + str(size) + " " + dom0ip) if out["return"]:
@@ -65,6 +48,7 @@ except ConsoleError, e: FAIL(str(e)) +domain.stop() + if len(fails): FAIL("Ping to dom0 failed for size" + fails + ".") -
tools/xm-test/tests/network/06_network_dom0_tcp_pos.py +13 -28
66 lines not on this page · raw message
tools/xm-test/tests/network/07_network_dom0_udp_pos.py +10 -26
@@ -16,29 +16,18 @@ trysizes = [ 1, 48, 64, 512, 1440, 1500, 1505, 4096, 4192, 32767, 65495 ] - - from XmTestLib import * rc = 0 -Net = XmNetwork() - -try: - # read an IP address from the config - ip = Net.ip("dom1", "eth0") - mask = Net.mask("dom1", "eth0") -except NetworkError, e: - FAIL(str(e)) +# Test creates 1 domain, which requires 2 ips: 1 for the domains and 1 for +# aliases on dom0 +if xmtest_netconf.canRunNetTest(2) == False: + SKIP("Don't have enough free configured IPs to run this test") # Fire up a guest domain w/1 nic -if ENABLE_HVM_SUPPORT: - brg = "xenbr0" - config = {"vif" : ['type=ioemu, bridge=%s' % brg]} -else: - brg = None - config = {"vif" : ["ip=%s" % ip]} +domain = XmTestDomain() +domain.newDevice(XenNetDevice, "eth0") -domain = XmTestDomain(extraConfig=config) try: console = domain.start() except DomainError, e:
@@ -48,16 +37,10 @@ FAIL(str(e)) try: - # Add a suitable dom0 IP address - dom0ip = Net.ip("dom0", "eth0", todomname=domain.getName(), toeth="eth0", bridge=brg) -except NetworkError, e: - FAIL(str(e)) - -try: - console.runCmd("ifconfig eth0 inet "+ip+" netmask "+mask+" up") - # Ping dom0 fails="" + netdev = domain.getDevice("eth0") + dom0ip = netdev.getDom0AliasIP() for size in trysizes: out = console.runCmd("hping2 " + dom0ip + " -E /dev/urandom -2 -q -c 20" + " --fast -d " + str(size))
@@ -67,6 +50,7 @@ except ConsoleError, e: FAIL(str(e)) +domain.stop() + if len(fails): FAIL("UDP hping2 to dom0 failed for size" + fails + ".") -
tools/xm-test/tests/network/11_network_domU_ping_pos.py +19 -30
75 lines not on this page · raw message
tools/xm-test/tests/network/12_network_domU_tcp_pos.py +19 -30
75 lines not on this page · raw message
tools/xm-test/tests/network/13_network_domU_udp_pos.py +19 -30
75 lines not on this page · raw message
tools/xm-test/lib/XmTestLib/NetConfig.py new file +264 -0
264 lines not on this page · raw message
tools/xm-test/lib/XmTestLib/XenDevice.py new file +271 -0
271 lines not on this page · raw message
tools/xm-test/lib/XmTestLib/Network.py deleted +0 -110
110 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel