From 0a543602119aaadc180ec9301cd85bcefc31b0b0 Mon Sep 17 00:00:00 2001 From: Rich Lane Date: Thu, 18 Jul 2013 17:50:52 -0700 Subject: [PATCH] IVSSwitch: support running IVS in a namespace This change uses the `Node.cmd` method instead of `Popen`. The `cmd` method sends the input to a shell which may be in another namespace (if --innamespace is in use), while `Popen` would always run in the root namespace. --- mininet/node.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/mininet/node.py b/mininet/node.py index 3cd8a1f..131c9f7 100644 --- a/mininet/node.py +++ b/mininet/node.py @@ -1023,7 +1023,6 @@ class IVSSwitch(Switch): def __init__( self, name, **kwargs ): Switch.__init__( self, name, **kwargs ) - self.process = None @classmethod def setup( cls ): @@ -1052,18 +1051,13 @@ class IVSSwitch(Switch): if self.listenPort: args.extend( ['--listen', '127.0.0.1:%i' % self.listenPort] ) - with open( '/tmp/ivs.%s.log' % self.name, 'w' ) as logfile: - with open( '/dev/null', 'w' ) as nullfile: - self.process = Popen( args, stdout=logfile, stderr=STDOUT, - stdin=nullfile, preexec_fn=os.setsid ) - self.execed = False + logfile = '/tmp/ivs.%s.log' % self.name + + self.cmd( ' '.join(args) + ' >' + logfile + ' 2>&1