[CRIU] [PATCH 1/2] netapi: add the net_dev class (v2)
Andrey Vagin
avagin at openvz.org
Sat Mar 22 04:59:33 PDT 2014
It's more readable than a tuple
v2: fix the ovz driver
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
p_haul_netapi.py | 5 +++++
p_haul_ovz.py | 15 ++++++++++-----
p_haul_service.py | 4 ++--
3 files changed, 17 insertions(+), 7 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
diff --git a/p_haul_ovz.py b/p_haul_ovz.py
index 7838108..f3cf01e 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()
@@ -166,13 +171,13 @@ class p_haul_type:
def net_lock(self):
for veth in self._veths:
- netif.ifdown(veth[1])
+ netif.ifdown(veth.pair)
def net_unlock(self):
for veth in self._veths:
- netif.ifup(veth[1])
- if veth[2] and not self._bridged:
- netif.bridge_add(veth[1], veth[2])
+ netif.ifup(veth.pair)
+ if veth.link and not self._bridged:
+ netif.bridge_add(veth.pair, veth.link)
def can_migrate_tcp(self):
return True
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:
--
1.8.5.3
More information about the CRIU
mailing list