diff --git a/examples/limit.py b/examples/limit.py index 0b23ca1de1eb67f2555d4e23fc993aa6189b8631..4984bb9427d822436fe5a65253551351ee6f8df5 100755 --- a/examples/limit.py +++ b/examples/limit.py @@ -8,15 +8,14 @@ from mininet.link import TCIntf from mininet.node import CPULimitedHost from mininet.topolib import TreeTopo -from mininet.util import custom -from mininet.log import setLogLevel +from mininet.util import custom, quietRun +from mininet.log import setLogLevel, info def testLinkLimit( net, bw ): "Run bandwidth limit test" - print '*** Testing network %.2f Mbps bandwidth limit' % bw - net.iperf( ) - + info( '*** Testing network %.2f Mbps bandwidth limit\n' % bw ) + net.iperf() def limit( bw=10, cpu=.1 ): """Example/test of link and CPU bandwidth limits @@ -25,7 +24,13 @@ def limit( bw=10, cpu=.1 ): intf = custom( TCIntf, bw=bw ) myTopo = TreeTopo( depth=1, fanout=2 ) for sched in 'rt', 'cfs': - print '*** Testing with', sched, 'bandwidth limiting' + info( '*** Testing with', sched, 'bandwidth limiting\n' ) + if sched == 'rt': + release = quietRun( 'uname -r' ).strip('\r\n') + output = quietRun( 'grep CONFIG_RT_GROUP_SCHED /boot/config-%s' % release ) + if output == '# CONFIG_RT_GROUP_SCHED is not set\n': + info( '*** RT Scheduler is not enabled in your kernel. Skipping this test\n' ) + continue host = custom( CPULimitedHost, sched=sched, cpu=cpu ) net = Mininet( topo=myTopo, intf=intf, host=host ) net.start() diff --git a/mininet/node.py b/mininet/node.py index 20b18aae1b47ff7ff6c2cfe1572615c64201c7b4..457123e89083747ef4e040ab9d4a1ed045b30d8d 100644 --- a/mininet/node.py +++ b/mininet/node.py @@ -606,6 +606,12 @@ def __init__( self, name, sched='cfs', **kwargs ): # still does better with larger period values. self.period_us = kwargs.get( 'period_us', 100000 ) self.sched = sched + if self.sched == 'rt': + release = quietRun( 'uname -r' ).strip('\r\n') + output = quietRun( 'grep CONFIG_RT_GROUP_SCHED /boot/config-%s' % release ) + if output == '# CONFIG_RT_GROUP_SCHED is not set\n': + error( '\n*** error: please enable RT_GROUP_SCHED in your kernel\n' ) + exit( 1 ) self.rtprio = 20 def cgroupSet( self, param, value, resource='cpu' ):