[CRIU] [PATCH 3/3] p.haul: rework logging
Nikita Spiridonov
nspiridonov at odin.com
Wed Sep 30 09:48:22 PDT 2015
Replace all prints with logging.info calls. This change is needed to
simplify output redirection to file (--log-file option).
Signed-off-by: Nikita Spiridonov <nspiridonov at odin.com>
---
p.haul-service | 6 ++--
phaul/criu_api.py | 5 ++-
phaul/fs_haul_shared.py | 5 ++-
phaul/fs_haul_subtree.py | 8 +++---
phaul/images.py | 19 +++++++++--------
phaul/mstats.py | 15 +++++++------
phaul/p_haul_cgroup.py | 7 +++--
phaul/p_haul_iters.py | 47 +++++++++++++++++++++++----------------------
phaul/p_haul_lxc.py | 9 ++++---
phaul/p_haul_module.py | 5 ++-
phaul/p_haul_pid.py | 3 +-
phaul/p_haul_service.py | 25 ++++++++++++-----------
phaul/p_haul_type.py | 3 +-
phaul/p_haul_vz.py | 21 +++++++++++--------
phaul/util.py | 7 +++--
phaul/xem_rpc.py | 5 ++-
16 files changed, 103 insertions(+), 87 deletions(-)
diff --git a/p.haul-service b/p.haul-service
index 76e5b3e..fbaa7ff 100755
--- a/p.haul-service
+++ b/p.haul-service
@@ -27,10 +27,10 @@ host = (args.bind_addr, args.bind_port)
sfd = None
def fin(foo, bar):
- print "Stop by %d" % foo
+ logging.info("Stop by %d", foo)
sfd.close()
-print "Starting p.haul rpyc service"
+logging.info("Starting p.haul rpyc service")
t = ph_xem_rpc.rpc_threaded_srv(ph_srv.phaul_service, host)
# FIXME: Setup stop handlers
@@ -41,4 +41,4 @@ signal.signal(signal.SIGINT, fin)
t.start()
signal.pause()
t.join()
-print "Bye!"
+logging.info("Bye!")
diff --git a/phaul/criu_api.py b/phaul/criu_api.py
index 2946e6d..725b2db 100644
--- a/phaul/criu_api.py
+++ b/phaul/criu_api.py
@@ -5,8 +5,9 @@
import socket
import os
-import util
import subprocess
+import logging
+import util
import pycriu.rpc as cr_rpc
import pycriu.images as images
import criu_req
@@ -27,7 +28,7 @@ class criu_conn:
self.verb = def_verb
css = socket.socketpair(socket.AF_UNIX, socket.SOCK_SEQPACKET)
util.set_cloexec(css[1])
- print "`- Passing (ctl:%d, data:%d) pair to CRIU" % (css[0].fileno(), mem_sk.fileno())
+ logging.info("`- Passing (ctl:%d, data:%d) pair to CRIU", css[0].fileno(), mem_sk.fileno())
self._swrk = subprocess.Popen([criu_binary, "swrk", "%d" % css[0].fileno()])
css[0].close()
self._cs = css[1]
diff --git a/phaul/fs_haul_shared.py b/phaul/fs_haul_shared.py
index 54e231a..d6b3a61 100644
--- a/phaul/fs_haul_shared.py
+++ b/phaul/fs_haul_shared.py
@@ -2,10 +2,11 @@
# Shared FS hauler (noop)
#
+import logging
+
class p_haul_fs:
def __init__(self):
- print "Initilized shared FS hauler"
- pass
+ logging.info("Initilized shared FS hauler")
def set_target_host(self, thost):
pass
diff --git a/phaul/fs_haul_subtree.py b/phaul/fs_haul_subtree.py
index 3181c79..5d90cb9 100644
--- a/phaul/fs_haul_subtree.py
+++ b/phaul/fs_haul_subtree.py
@@ -6,14 +6,14 @@
import subprocess as sp
import os
+import logging
rsync_log_file = "rsync.log"
class p_haul_fs:
def __init__(self, subtree_path):
- print "Initialized subtree FS hauler (%s)" % subtree_path
+ logging.info("Initialized subtree FS hauler (%s)", subtree_path)
self.__root = subtree_path
- pass
def set_target_host(self, thost):
self.__thost = thost
@@ -35,14 +35,14 @@ class p_haul_fs:
raise Exception("Rsync failed")
def start_migration(self):
- print "Starting FS migration"
+ logging.info("Starting FS migration")
self.__run_rsync()
def next_iteration(self):
pass
def stop_migration(self):
- print "Doing final FS sync"
+ logging.info("Doing final FS sync")
self.__run_rsync()
# When rsync-ing FS inodes number will change
diff --git a/phaul/images.py b/phaul/images.py
index a4d465c..b9326ce 100644
--- a/phaul/images.py
+++ b/phaul/images.py
@@ -9,6 +9,7 @@ import time
import shutil
import time
import threading
+import logging
import util
import criu_api
@@ -69,7 +70,7 @@ class phaul_images:
self._current_dir = None
def save_images(self):
- print "Keeping images"
+ logging.info("Keeping images")
self._keep_on_close = True
def set_options(self, opts):
@@ -91,10 +92,10 @@ class phaul_images:
self._current_dir.close()
if not self._keep_on_close:
- print "Removing images"
+ logging.info("Removing images")
shutil.rmtree(self._wdir.name())
else:
- print "Images are kept in %s" % self._wdir.name()
+ logging.info("Images are kept in %s", self._wdir.name())
pass
def img_sync_time(self):
@@ -105,7 +106,7 @@ class phaul_images:
self._current_dir.close()
self.current_iter += 1
img_dir = "%s/%d" % (self._img_path, self.current_iter)
- print "\tMaking directory %s" % img_dir
+ logging.info("\tMaking directory %s", img_dir)
os.mkdir(img_dir)
self._current_dir = opendir(img_dir)
@@ -133,7 +134,7 @@ class phaul_images:
def sync_imgs_to_target(self, th, htype, sock):
# Pre-dump doesn't generate any images (yet?)
# so copy only those from the top dir
- print "Sending images to target"
+ logging.info("Sending images to target")
start = time.time()
cdir = self.image_dir()
@@ -141,11 +142,11 @@ class phaul_images:
th.start_accept_images(phaul_images.IMGDIR)
tf = img_tar(sock, cdir)
- print "\tPack"
+ logging.info("\tPack")
for img in filter(lambda x: x.endswith(".img"), os.listdir(cdir)):
tf.add(img)
- print "\tAdd htype images"
+ logging.info("\tAdd htype images")
for himg in htype.get_meta_images(cdir):
tf.add(himg[1], himg[0])
@@ -169,8 +170,8 @@ class phaul_images:
self.__acc_tar = untar_thread(sk, dirname)
self.__acc_tar.start()
- print "Started images server"
+ logging.info("Started images server")
def stop_accept_images(self):
- print "Waiting for images to unpack"
+ logging.info("Waiting for images to unpack")
self.__acc_tar.join()
diff --git a/phaul/mstats.py b/phaul/mstats.py
index f1a9c32..dad9747 100644
--- a/phaul/mstats.py
+++ b/phaul/mstats.py
@@ -1,4 +1,5 @@
import time
+import logging
def usec2sec(usec):
return usec / 1000000.
@@ -19,15 +20,15 @@ class migration_stats:
self._print_stats()
def iteration(self, stats):
- print "Dumped %d pages, %d skipped" % \
- (stats.pages_written, stats.pages_skipped_parent)
+ logging.info("Dumped %d pages, %d skipped",
+ stats.pages_written, stats.pages_skipped_parent)
self._iter_fr_times.append("%.2lf" % usec2sec(stats.frozen_time))
self._frozen_time += stats.frozen_time
def _print_stats(self):
- print "Migration succeeded"
- print "\t total time is ~%.2lf sec" % (self._end_time - self._start_time)
- print "\t frozen time is ~%.2lf sec (" % usec2sec(self._frozen_time), self._iter_fr_times, ")"
- print "\t restore time is ~%.2lf sec" % usec2sec(self._rst_time)
- print "\timg sync time is ~%.2lf sec" % (self._img_sync_time)
+ logging.info("Migration succeeded")
+ logging.info("\t total time is ~%.2lf sec", self._end_time - self._start_time)
+ logging.info("\t frozen time is ~%.2lf sec (%s)", usec2sec(self._frozen_time), str(self._iter_fr_times))
+ logging.info("\t restore time is ~%.2lf sec", usec2sec(self._rst_time))
+ logging.info("\timg sync time is ~%.2lf sec", self._img_sync_time)
diff --git a/phaul/p_haul_cgroup.py b/phaul/p_haul_cgroup.py
index 846ee62..92e13a4 100644
--- a/phaul/p_haul_cgroup.py
+++ b/phaul/p_haul_cgroup.py
@@ -5,6 +5,7 @@
#
import os
+import logging
cg_root_dir = "/sys/fs/cgroup"
cg_tasks_file = "tasks"
@@ -27,7 +28,7 @@ def cg_line_parse(ln):
return cname, cdir
def dump_hier(pid, img):
- print "\tSave CG for %d into %s" % (pid, img)
+ logging.info("\tSave CG for %d into %s", pid, img)
fd = open(img, "w")
cg = open("/proc/%d/cgroup" % pid)
for ln in cg:
@@ -60,7 +61,7 @@ def cpuset_allow_all(path):
def restore_one_controller(pid, ln):
cg_path = os.path.join(cg_root_dir, ln.strip())
- print "[%s]" % cg_path
+ logging.info("[%s]", cg_path)
if not os.access(cg_path, os.F_OK):
os.makedirs(cg_path)
if ln.startswith("cpuset"):
@@ -71,7 +72,7 @@ def restore_one_controller(pid, ln):
tf.close()
def restore_hier(pid, img):
- print "\tCreate hier for %d from %s" % (pid, img)
+ logging.info("\tCreate hier for %d from %s", pid, img)
fd = open(img)
for ln in fd:
restore_one_controller(pid, ln)
diff --git a/phaul/p_haul_iters.py b/phaul/p_haul_iters.py
index bca28de..f23e799 100644
--- a/phaul/p_haul_iters.py
+++ b/phaul/p_haul_iters.py
@@ -2,6 +2,7 @@
# The P.HAUL core -- the class that drives migration
#
+import logging
import images
import mstats
import xem_rpc
@@ -27,11 +28,11 @@ class phaul_iter_worker:
self.iteration = 0
self.prev_stats = None
- print "Connecting to target host"
+ logging.info("Connecting to target host")
self.th = xem_rpc.rpc_proxy(host)
self.data_sk = self.th.open_socket("datask")
- print "Setting up local"
+ logging.info("Setting up local")
self.img = images.phaul_images("dmp")
self.criu = criu_api.criu_conn(self.data_sk)
self.htype = p_haul_type.get_src(p_type)
@@ -45,7 +46,7 @@ class phaul_iter_worker:
self.pid = self.htype.root_task_pid()
self.fs.set_target_host(host[0])
- print "Setting up remote"
+ logging.info("Setting up remote")
self.th.setup(p_type)
def set_options(self, opts):
@@ -56,18 +57,18 @@ class phaul_iter_worker:
self.__force = opts["force"]
def validate_cpu(self):
- print "Checking CPU compatibility"
+ logging.info("Checking CPU compatibility")
- print " `- Dumping CPU info"
+ logging.info("\t`- Dumping CPU info")
req = criu_req.make_cpuinfo_dump_req(self.htype, self.img)
resp = self.criu.send_req(req)
if not resp.success:
raise Exception("Can't dump cpuinfo")
- print " `- Sending CPU info"
+ logging.info("\t`- Sending CPU info")
self.img.send_cpuinfo(self.th, self.data_sk)
- print " `- Checking CPU info"
+ logging.info("\t`- Checking CPU info")
if not self.th.check_cpuinfo():
raise Exception("CPUs mismatch")
@@ -77,19 +78,19 @@ class phaul_iter_worker:
if not self.__force:
self.validate_cpu()
- print "Preliminary FS migration"
+ logging.info("Preliminary FS migration")
self.fs.set_work_dir(self.img.work_dir())
self.fs.start_migration()
- print "Starting iterations"
+ logging.info("Starting iterations")
while True:
- print "* Iteration %d" % self.iteration
+ logging.info("* Iteration %d", self.iteration)
self.th.start_iter()
self.img.new_image_dir()
- print "\tIssuing pre-dump command to service"
+ logging.info("\tIssuing pre-dump command to service")
req = criu_req.make_predump_req(
self.pid, self.htype, self.img, self.criu, self.fs)
@@ -97,7 +98,7 @@ class phaul_iter_worker:
if not resp.success:
raise Exception("Pre-dump failed")
- print "\tPre-dump succeeded"
+ logging.info("\tPre-dump succeeded")
self.th.end_iter()
@@ -110,26 +111,26 @@ class phaul_iter_worker:
# and restore
#
- print "Checking iteration progress:"
+ logging.info("Checking iteration progress:")
if stats.pages_written <= phaul_iter_min_size:
- print "\t> Small dump"
+ logging.info("\t> Small dump")
break;
if self.prev_stats:
w_add = stats.pages_written - self.prev_stats.pages_written
w_add = w_add * 100 / self.prev_stats.pages_written
if w_add > phaul_iter_grow_max:
- print "\t> Iteration grows"
+ logging.info("\t> Iteration grows")
break
if self.iteration >= phaul_iter_max:
- print "\t> Too many iterations"
+ logging.info("\t> Too many iterations")
break
self.iteration += 1
self.prev_stats = stats
- print "\t> Proceed to next iteration"
+ logging.info("\t> Proceed to next iteration")
self.fs.next_iteration()
@@ -138,12 +139,12 @@ class phaul_iter_worker:
# to target host and restore from them there
#
- print "Final dump and restore"
+ logging.info("Final dump and restore")
self.th.start_iter()
self.img.new_image_dir()
- print "\tIssuing dump command to service"
+ logging.info("\tIssuing dump command to service")
req = criu_req.make_dump_req(
self.pid, self.htype, self.img, self.criu, self.fs)
@@ -165,10 +166,10 @@ class phaul_iter_worker:
elif resp.notify.script == "network-unlock":
self.htype.net_unlock()
- print "\t\tNotify (%s)" % resp.notify.script
+ logging.info("\t\tNotify (%s)", resp.notify.script)
resp = self.criu.ack_notify()
- print "Dump complete"
+ logging.info("Dump complete")
self.th.end_iter()
#
@@ -177,11 +178,11 @@ class phaul_iter_worker:
# tasks on source node
#
- print "Final FS and images sync"
+ logging.info("Final FS and images sync")
self.fs.stop_migration()
self.img.sync_imgs_to_target(self.th, self.htype, self.data_sk)
- print "Asking target host to restore"
+ logging.info("Asking target host to restore")
self.th.restore_from_images()
#
diff --git a/phaul/p_haul_lxc.py b/phaul/p_haul_lxc.py
index fbd26d2..47e9353 100644
--- a/phaul/p_haul_lxc.py
+++ b/phaul/p_haul_lxc.py
@@ -4,6 +4,7 @@
import os
import shutil
+import logging
import p_haul_cgroup
import p_haul_module
import util
@@ -29,7 +30,7 @@ class p_haul_type:
self._cfg = {}
def __load_ct_config(self):
- print "Loading config file from %s" % self.__ct_config()
+ logging.info("Loading config file from %s", self.__ct_config())
self._cfg = {}
self._veths = []
@@ -60,7 +61,7 @@ class p_haul_type:
ifd.close()
def __apply_cg_config(self):
- print "Applying CT configs"
+ logging.info("Applying CT configs")
# FIXME -- implement
pass
@@ -116,7 +117,7 @@ class p_haul_type:
(cg_img, cg_image_name) ]
def put_meta_images(self, dir):
- print "Putting config file into %s" % lxc_dir
+ logging.info("Putting config file into %s", lxc_dir)
shutil.copy(os.path.join(dir, "config"), self.__ct_config())
@@ -136,7 +137,7 @@ class p_haul_type:
def mount(self):
nroot = self.__ct_root()
- print "Mounting CT root to %s" % nroot
+ logging.info("Mounting CT root to %s", nroot)
if not os.access(nroot, os.F_OK):
os.makedirs(nroot)
os.system("mount --bind %s %s" % (self.__ct_rootfs(), nroot))
diff --git a/phaul/p_haul_module.py b/phaul/p_haul_module.py
index 31f7950..8fe4e8c 100644
--- a/phaul/p_haul_module.py
+++ b/phaul/p_haul_module.py
@@ -2,6 +2,7 @@
# Generic functionality for p.haul modules
#
+import logging
import pycriu.rpc
import criu_req
@@ -10,13 +11,13 @@ def final_restore(htype, img, connection):
nroot = htype.mount()
if nroot:
- print "Restore root set to %s" % nroot
+ logging.info("Restore root set to %s", nroot)
req = criu_req.make_restore_req(htype, img, nroot)
resp = connection.send_req(req)
while True:
if resp.type == pycriu.rpc.NOTIFY:
- print "\t\tNotify (%s.%d)" % (resp.notify.script, resp.notify.pid)
+ logging.info("\t\tNotify (%s.%d)", resp.notify.script, resp.notify.pid)
if resp.notify.script == "setup-namespaces":
#
# At that point we have only one task
diff --git a/phaul/p_haul_pid.py b/phaul/p_haul_pid.py
index 8b2bcc2..47cf651 100644
--- a/phaul/p_haul_pid.py
+++ b/phaul/p_haul_pid.py
@@ -2,6 +2,7 @@
# Individual process hauler
#
+import logging
import p_haul_module
import fs_haul_shared
@@ -71,7 +72,7 @@ class p_haul_type:
# Restoring done, the new top task has pid pid
def restored(self, pid):
if self._pidfile:
- print "Writing rst pidfile"
+ logging.info("Writing rst pidfile")
open(self._pidfile, "w").writelines(["%d" % pid])
#
diff --git a/phaul/p_haul_service.py b/phaul/p_haul_service.py
index ca2d5e1..f2cadb9 100644
--- a/phaul/p_haul_service.py
+++ b/phaul/p_haul_service.py
@@ -2,6 +2,7 @@
# P.HAUL code, that helps on the target node (rpyc service)
#
+import logging
import xem_rpc
import pycriu.rpc as cr_rpc
import images
@@ -11,7 +12,7 @@ import p_haul_type
class phaul_service:
def on_connect(self):
- print "Connected"
+ logging.info("Connected")
self.dump_iter = 0
self.restored = False
self.criu = None
@@ -20,7 +21,7 @@ class phaul_service:
self.htype = None
def on_disconnect(self):
- print "Disconnected"
+ logging.info("Disconnected")
if self.criu:
self.criu.close()
@@ -31,17 +32,17 @@ class phaul_service:
self.htype.umount()
if self.img:
- print "Closing images"
+ logging.info("Closing images")
if not self.restored:
self.img.save_images()
self.img.close()
def on_socket_open(self, sk, uname):
self.data_sk = sk
- print "Data socket (%s) accepted" % uname
+ logging.info("Data socket (%s) accepted", uname)
def rpc_setup(self, htype_id):
- print "Setting up service side", htype_id
+ logging.info("Setting up service side %s", htype_id)
self.img = images.phaul_images("rst")
self.criu = criu_api.criu_conn(self.data_sk)
self.htype = p_haul_type.get_dst(htype_id)
@@ -52,15 +53,15 @@ class phaul_service:
self.htype.set_options(opts)
def start_page_server(self):
- print "Starting page server for iter %d" % self.dump_iter
+ logging.info("Starting page server for iter %d", self.dump_iter)
- print "\tSending criu rpc req"
+ logging.info("\tSending criu rpc req")
req = criu_req.make_page_server_req(self.htype, self.img, self.criu)
resp = self.criu.send_req(req)
if not resp.success:
raise Exception("Failed to start page server")
- print "\tPage server started at %d" % resp.ps.pid
+ logging.info("\tPage server started at %d", resp.ps.pid)
def rpc_start_iter(self):
self.dump_iter += 1
@@ -77,17 +78,17 @@ class phaul_service:
self.img.stop_accept_images()
def rpc_check_cpuinfo(self):
- print "Checking cpuinfo"
+ logging.info("Checking cpuinfo")
req = criu_req.make_cpuinfo_check_req(self.htype, self.img)
resp = self.criu.send_req(req)
- print " `-", resp.success
+ logging.info("\t`- %s", resp.success)
return resp.success
def rpc_restore_from_images(self):
- print "Restoring from images"
+ logging.info("Restoring from images")
self.htype.put_meta_images(self.img.image_dir())
self.htype.final_restore(self.img, self.criu)
- print "Restore succeeded"
+ logging.info("Restore succeeded")
self.restored = True
def rpc_restore_time(self):
diff --git a/phaul/p_haul_type.py b/phaul/p_haul_type.py
index 1a9e984..4fa2833 100644
--- a/phaul/p_haul_type.py
+++ b/phaul/p_haul_type.py
@@ -4,6 +4,7 @@
# See p_haul_pid for comments of how a class should look like.
#
+import logging
import p_haul_vz
import p_haul_pid
import p_haul_lxc
@@ -19,7 +20,7 @@ def __get(id):
h_type = haul_types[id[0]]
return h_type.p_haul_type(id[1])
else:
- print "Unknown type. Try one of", haul_types.keys()
+ logging.info("Unknown type. Try one of %s", str(haul_types.keys()))
return None
def get_src(id):
diff --git a/phaul/p_haul_vz.py b/phaul/p_haul_vz.py
index 546a876..4d799e3 100644
--- a/phaul/p_haul_vz.py
+++ b/phaul/p_haul_vz.py
@@ -5,6 +5,7 @@
import os
import subprocess
import shlex
+import logging
import p_haul_cgroup
import p_haul_module
import util
@@ -33,7 +34,7 @@ class p_haul_type:
self._cfg = ""
def __load_ct_config(self, path):
- print "Loading config file from %s" % path
+ logging.info("Loading config file from %s", path)
# Read container config
with open(os.path.join(path, self.__ct_config())) as ifd:
@@ -57,7 +58,7 @@ class p_haul_type:
elif pa[0] == "bridge":
v_bridge = pa[1]
if v_in and v_out:
- print "\tCollect %s -> %s (%s) veth" % (v_in, v_out, v_bridge)
+ logging.info("\tCollect %s -> %s (%s) veth", v_in, v_out, v_bridge)
self._veths.append(util.net_dev(v_in, v_out, v_bridge))
# Extract private path from config
@@ -75,7 +76,7 @@ class p_haul_type:
self._ctid)
def __apply_cg_config(self):
- print "Applying CT configs"
+ logging.info("Applying CT configs")
# FIXME -- implement
pass
@@ -133,7 +134,7 @@ class p_haul_type:
(cg_img, cg_image_name) ]
def put_meta_images(self, path):
- print "Putting config file into %s" % vz_conf_dir
+ logging.info("Putting config file into %s", vz_conf_dir)
self.__load_ct_config(path)
with open(os.path.join(vz_conf_dir, self.__ct_config()), "w") as ofd:
@@ -163,6 +164,7 @@ class p_haul_type:
args_path = os.path.join(img.image_dir(), "restore-extra-args")
self.__setup_restore_extra_args(args_path, img, connection)
# Run vzctl restore
+ logging.info("Starting vzctl restore")
proc = subprocess.Popen([vzctl_bin, "restore", self._ctid,
"--dumpfile", img.image_dir()])
if proc.wait() != 0:
@@ -182,31 +184,32 @@ class p_haul_type:
p_haul_cgroup.restore_hier(pid, self.cg_img)
def mount(self):
- print "Mounting CT root to %s" % self._ct_root
+ logging.info("Mounting CT root to %s", self._ct_root)
os.system("vzctl mount {0}".format(self._ctid))
self._fs_mounted = True
return self._ct_root
def umount(self):
if self._fs_mounted:
- print "Umounting CT root"
+ logging.info("Umounting CT root")
+ logging.info("Starting vzctl umount")
os.system("vzctl umount {0}".format(self._ctid))
self._fs_mounted = False
def get_fs(self):
rootfs = util.path_to_fs(self._ct_priv)
if not rootfs:
- print "CT is on unknown FS"
+ logging.info("CT is on unknown FS")
return None
- print "CT is on %s" % rootfs
+ logging.info("CT is on %s", rootfs)
if rootfs == "nfs":
return fs_haul_shared.p_haul_fs()
if rootfs == "ext3" or rootfs == "ext4":
return fs_haul_subtree.p_haul_fs(self._ct_priv)
- print "Unknown CT FS"
+ logging.info("Unknown CT FS")
return None
def restored(self, pid):
diff --git a/phaul/util.py b/phaul/util.py
index 2f3ebb0..b15c75f 100644
--- a/phaul/util.py
+++ b/phaul/util.py
@@ -1,6 +1,7 @@
import os
import fcntl
import errno
+import logging
class net_dev:
def __init__(self, name=None, pair=None, link=None):
@@ -20,15 +21,15 @@ def path_to_fs(path):
return None
def ifup(ifname):
- print "\t\tUpping %s" % ifname
+ logging.info("\t\tUpping %s", ifname)
os.system("ip link set %s up" % ifname)
def ifdown(ifname):
- print "\t\tDowning %s" % ifname
+ logging.info("\t\tDowning %s", ifname)
os.system("ip link set %s down" % ifname)
def bridge_add(ifname, brname):
- print "\t\tAdd %s to %s" % (ifname, brname)
+ logging.info("\t\tAdd %s to %s", ifname, brname)
os.system("brctl addif %s %s" % (brname, ifname))
def set_cloexec(sk):
diff --git a/phaul/xem_rpc.py b/phaul/xem_rpc.py
index d3c196d..d320013 100644
--- a/phaul/xem_rpc.py
+++ b/phaul/xem_rpc.py
@@ -2,6 +2,7 @@ import socket
import select
import threading
import traceback
+import logging
import util
rpc_port = 12345
@@ -33,7 +34,7 @@ class _rpc_proxy_caller:
if resp[0] == RPC_RESP:
return resp[1]
elif resp[0] == RPC_EXC:
- print "Remote exception"
+ logging.info("Remote exception")
raise Exception(resp[1])
else:
raise Exception("Proto resp error")
@@ -180,7 +181,7 @@ class _rpc_server_manager:
for sk in r:
sk.work(self)
- print "RPC Service stops"
+ logging.info("RPC Service stops")
class rpc_threaded_srv(threading.Thread):
def __init__(self, srv_class, host):
--
1.7.1
More information about the CRIU
mailing list