summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2019-12-09 16:13:17 +1300
committerPaul Eggleton <paul.eggleton@linux.intel.com>2019-12-09 23:54:56 +1300
commit464eb3ed38a95e03bd5906daff14439ae83eb953 (patch)
tree8726f9d906a283c641f32d600f65f48113bdbe94
parent4675d65dbb2c7e16283e3045c7ca90cec41ed0af (diff)
downloadopenembedded-core-contrib-paule/runqemu-fixes-oe.tar.gz
runqemu: handle tap device creation failure properlypaule/runqemu-fixes-oe
If we fail to run the command to generate the tap devices then we should show a reasonable message and then exit, without showing a traceback. "return 1" at this point in the code does nothing because the caller doesn't check the return, so just use sys.exit(). Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
-rwxr-xr-xscripts/runqemu8
1 files changed, 6 insertions, 2 deletions
diff --git a/scripts/runqemu b/scripts/runqemu
index f061917c4b..ef454d67ff 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -1121,7 +1121,11 @@ class BaseConfig(object):
uid = os.getuid()
logger.info("Setting up tap interface under sudo")
cmd = ('sudo', self.qemuifup, str(uid), str(gid), self.bindir_native)
- tap = subprocess.check_output(cmd).decode('utf-8').strip()
+ try:
+ tap = subprocess.check_output(cmd).decode('utf-8').strip()
+ except subprocess.CalledProcessError as e:
+ logger.error('Setting up tap device failed:\n%s\nRun runqemu-gen-tapdevs to manually create one.' % str(e))
+ sys.exit(1)
lockfile = os.path.join(lockdir, tap)
self.taplock = lockfile + '.lock'
self.acquire_taplock()
@@ -1130,7 +1134,7 @@ class BaseConfig(object):
if not tap:
logger.error("Failed to setup tap device. Run runqemu-gen-tapdevs to manually create.")
- return 1
+ sys.exit(1)
self.tap = tap
tapnum = int(tap[3:])
gateway = tapnum * 2 + 1