[CRIU] [PATCH] p.haul: images: create img_dir if it doesn't exist

Ruslan Kuprieiev kupruser at gmail.com
Mon Oct 13 02:37:56 PDT 2014


Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
---
 images.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/images.py b/images.py
index ef5691f..1fd9610 100644
--- a/images.py
+++ b/images.py
@@ -9,6 +9,7 @@ import time
 import shutil
 import time
 import threading
+import errno
 import util
 import criu_api
 
@@ -76,6 +77,13 @@ class phaul_images:
 		self._keep_on_close = opts["keep_images"]
 
 		suf = time.strftime("-%y.%m.%d-%H.%M", time.localtime())
+		try:
+			os.makedirs(opts["img_path"])
+		except OSError as er:
+			if er.errno == errno.EEXIST and os.path.isdir(opts["img_path"]):
+				pass
+			else:
+				raise
 		wdir = tempfile.mkdtemp(suf, "%s-" % self._typ, opts["img_path"])
 		self._wdir = opendir(wdir)
 		self._img_path = os.path.join(self._wdir.name(), "img")
-- 
1.9.3



More information about the CRIU mailing list