phaul: use stats image from images dir instead of workdir

Submitted by Pavel Tikhomirov on March 26, 2018, 8:32 a.m.

Details

Message ID 20180326083217.14282-1-ptikhomirov@virtuozzo.com
State Rejected
Series "phaul: use stats image from images dir instead of workdir"
Headers show

Commit Message

Pavel Tikhomirov March 26, 2018, 8:32 a.m.
After patch "stats/pid-reuse: put stats to image directory instead of
cwd", stats images will move to images dir, switch p.haul to use it from
the right place and also preserve compatibility with older criu.

https://jira.sw.ru/browse/PSBM-82864
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
---
 phaul/criu_api.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/phaul/criu_api.py b/phaul/criu_api.py
index 73c642a..2dedfc6 100644
--- a/phaul/criu_api.py
+++ b/phaul/criu_api.py
@@ -104,7 +104,12 @@  def_verb = 2
 
 
 def criu_get_stats(img, file_name):
-	with open(os.path.join(img.work_dir(), file_name)) as f:
+	stats_path = os.path.join(img.image_dir(), file_name)
+	# Fallback to old stats location in working dir
+	if not os.path.exists(stats_path):
+		stats_path = os.path.join(img.work_dir(), file_name)
+
+	with open(stats_path) as f:
 		stats_dict = pycriu.images.load(f)
 		stats = pycriu.images.stats_pb2.stats_entry()
 		pycriu.images.pb2dict.dict2pb(stats_dict['entries'][0], stats)