[CRIU] [PATCH 1/2] netapi: add the net_dev class

Andrew Vagin avagin at parallels.com
Thu Mar 20 04:39:38 PDT 2014


On Thu, Mar 20, 2014 at 12:24:37PM +0400, Pavel Emelyanov wrote:
> On 03/19/2014 10:55 PM, Andrey Vagin wrote:
> > It's more readable than a tuple
> > 
> > * I have not tested this pathc for OpenVZ
> > 
> > Signed-off-by: Andrey Vagin <avagin at openvz.org>
> > ---
> >  p_haul_netapi.py  | 5 +++++
> >  p_haul_ovz.py     | 7 ++++++-
> >  p_haul_service.py | 4 ++--
> >  3 files changed, 13 insertions(+), 3 deletions(-)
> >  create mode 100644 p_haul_netapi.py
> > 
> > diff --git a/p_haul_netapi.py b/p_haul_netapi.py
> > new file mode 100644
> > index 0000000..5e55818
> > --- /dev/null
> > +++ b/p_haul_netapi.py
> > @@ -0,0 +1,5 @@
> > +class net_dev:
> > +	def init(self):
> > +		self.name = None
> > +		self.pair = None
> > +		self.link = None
> 
> Why not put it into existing netifapi?

netifapi is used for comunicating with kernel, isn't it?

> 
> > diff --git a/p_haul_ovz.py b/p_haul_ovz.py
> > index 7838108..9bfb572 100644
> > --- a/p_haul_ovz.py
> > +++ b/p_haul_ovz.py
> > @@ -7,6 +7,7 @@ import shutil
> >  import p_haul_cgroup
> >  import p_haul_netifapi as netif
> >  import p_haul_fsapi as fsapi
> > +import p_haul_netapi as netapi
> >  import fs_haul_shared
> >  import fs_haul_subtree
> >  
> > @@ -58,7 +59,11 @@ class p_haul_type:
> >  
> >  				if v_in and v_out:
> >  					print "\tCollect %s -> %s (%s) veth" % (v_in, v_out, v_bridge)
> > -					self._veths.append((v_in, v_out, v_bridge))
> > +					veth = netapi.net_dev()
> > +					veth.name = v_in
> > +					veth.pair = v_out
> > +					veth.link = v_bridge
> > +					self._veths.append(veth)
> >  
> >  		ifd.close()
> >  
> > diff --git a/p_haul_service.py b/p_haul_service.py
> > index ceadbb0..ae243d6 100644
> > --- a/p_haul_service.py
> > +++ b/p_haul_service.py
> > @@ -95,8 +95,8 @@ class phaul_service(rpyc.Service):
> >  
> >  		for veth in self.htype.veths():
> >  			v = req.opts.veths.add()
> > -			v.if_in = veth[0]
> > -			v.if_out = veth[1]
> > +			v.if_in = veth.name
> > +			v.if_out = veth.pair
> >  
> >  		nroot = self.htype.mount()
> >  		if nroot:
> > 
> 
> 


More information about the CRIU mailing list