Catch OSError exception for subprocess calls.

This commit is contained in:
Jeremy committed 2014-12-11 12:15:24 -07:00
1 parent acb5103119
commit 7f37f649da
6 files changed
+13 -13

No files matched your search

+5 -5
View File
@@ -678,7 +678,7 @@ class QemuVM(object):
priority = 0
try:
subprocess.call(['renice', '-n', str(priority), '-p', str(self._process.pid)])
except subprocess.SubprocessError as e:
except (OSError, subprocess.SubprocessError) as e:
log.error("could not change process priority for QEMU VM {}: {}".format(self._name, e))
def _stop_cpulimit(self):
@@ -710,7 +710,7 @@ class QemuVM(object):
log.info("CPU throttled to {}%".format(self._cpu_throttling))
except FileNotFoundError:
raise QemuError("cpulimit could not be found, please install it or deactivate CPU throttling")
except subprocess.SubprocessError as e:
except (OSError, subprocess.SubprocessError) as e:
raise QemuError("Could not throttle CPU: {}".format(e))
def start(self):
@@ -796,7 +796,7 @@ class QemuVM(object):
cwd=self._working_dir)
log.info("QEMU VM instance {} started PID={}".format(self._id, self._process.pid))
self._started = True
except subprocess.SubprocessError as e:
except (OSError, subprocess.SubprocessError) as e:
stdout = self.read_stdout()
log.error("could not start QEMU {}: {}\n{}".format(self._qemu_path, e, stdout))
raise QemuError("could not start QEMU {}: {}\n{}".format(self._qemu_path, e, stdout))
@@ -971,7 +971,7 @@ class QemuVM(object):
retcode = subprocess.call([qemu_img_path, "create", "-f", "qcow2", hda_disk, "128M"])
log.info("{} returned with {}".format(qemu_img_path, retcode))
except subprocess.SubprocessError as e:
except (OSError, subprocess.SubprocessError) as e:
raise QemuError("Could not create disk image {}".format(e))
options.extend(["-hda", hda_disk])
@@ -983,7 +983,7 @@ class QemuVM(object):
"backing_file={}".format(self._hdb_disk_image),
"-f", "qcow2", hdb_disk])
log.info("{} returned with {}".format(qemu_img_path, retcode))
except subprocess.SubprocessError as e:
except (OSError, subprocess.SubprocessError) as e:
raise QemuError("Could not create disk image {}".format(e))
options.extend(["-hdb", hdb_disk])