[CRIU] [PATCH 1/3] p.haul: add helper function to get criu version
Nikita Spiridonov
nspiridonov at virtuozzo.com
Thu Apr 14 04:18:09 PDT 2016
Add helper function which exec criu with -V flag and parse its
output to obtain criu version.
Signed-off-by: Nikita Spiridonov <nspiridonov at virtuozzo.com>
---
phaul/criu_api.py | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/phaul/criu_api.py b/phaul/criu_api.py
index 72ed256..4926330 100644
--- a/phaul/criu_api.py
+++ b/phaul/criu_api.py
@@ -5,6 +5,7 @@
import socket
import os
+import re
import subprocess
import logging
import util
@@ -83,6 +84,15 @@ class criu_conn:
self._track_mem = value
+def get_criu_version():
+ proc = subprocess.Popen([criu_binary, "-V"],
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ proc_output = proc.communicate()[0]
+ if proc.returncode == 0:
+ match = re.match("Version:\s+(\S+)", proc_output)
+ return match.group(1) if match else None
+
+
#
# Helper to read CRIU-generated statistics
#
--
1.7.1
More information about the CRIU
mailing list