Skip to content
Snippets Groups Projects
Commit d85494a5 authored by Tomasz Grabiec's avatar Tomasz Grabiec Committed by Pekka Enberg
Browse files

imgedit: fix hang in case qemu terminates before nbd client connects


To make it work self._closed needs to be initialized early because
even though exception is thrown from __init__(), __exit__() still will
be called and that one expects self._closed to be defined.

Signed-off-by: default avatarTomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent 5e3605f5
No related branches found
No related tags found
No related merge requests found
......@@ -52,6 +52,7 @@ class nbd_file(object):
self._filename = filename
self._offset = 0
self._buf = None
self._closed = True
self._process = subprocess.Popen("qemu-nbd %s" % filename,
shell = True, stdout=_devnull)
# wait for qemu-nbd to start: this thing doesn't tell anything on stdout
......@@ -60,6 +61,8 @@ class nbd_file(object):
self._client = nbd_client("localhost")
break
except:
if self._process.poll() != None:
raise Exception('Qemu terminated with exit code %d' % self._process.returncode)
time.sleep(0.1)
self._closed = False
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment