diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2019-12-09 23:59:09 +1300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-12-15 09:10:46 +0000 |
commit | c64c5e0eda98e667de22074d6ea606c655519dc0 (patch) | |
tree | e8eb0c03c46184b3f888467931f0edd51d5df9fd /scripts/runqemu | |
parent | 4955fe19abfde0fd9b4fe5e1f82fd2a148e5db01 (diff) | |
download | poky-c64c5e0eda98e667de22074d6ea606c655519dc0.tar.gz |
runqemu: handle tap device creation failure properly
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().
(From OE-Core rev: 47e40fdd7dd58bde4e017e2375c16450fcb14eca)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/runqemu')
-rwxr-xr-x | scripts/runqemu | 8 |
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): | |||
1121 | uid = os.getuid() | 1121 | uid = os.getuid() |
1122 | logger.info("Setting up tap interface under sudo") | 1122 | logger.info("Setting up tap interface under sudo") |
1123 | cmd = ('sudo', self.qemuifup, str(uid), str(gid), self.bindir_native) | 1123 | cmd = ('sudo', self.qemuifup, str(uid), str(gid), self.bindir_native) |
1124 | tap = subprocess.check_output(cmd).decode('utf-8').strip() | 1124 | try: |
1125 | tap = subprocess.check_output(cmd).decode('utf-8').strip() | ||
1126 | except subprocess.CalledProcessError as e: | ||
1127 | logger.error('Setting up tap device failed:\n%s\nRun runqemu-gen-tapdevs to manually create one.' % str(e)) | ||
1128 | sys.exit(1) | ||
1125 | lockfile = os.path.join(lockdir, tap) | 1129 | lockfile = os.path.join(lockdir, tap) |
1126 | self.taplock = lockfile + '.lock' | 1130 | self.taplock = lockfile + '.lock' |
1127 | self.acquire_taplock() | 1131 | self.acquire_taplock() |
@@ -1130,7 +1134,7 @@ class BaseConfig(object): | |||
1130 | 1134 | ||
1131 | if not tap: | 1135 | if not tap: |
1132 | logger.error("Failed to setup tap device. Run runqemu-gen-tapdevs to manually create.") | 1136 | logger.error("Failed to setup tap device. Run runqemu-gen-tapdevs to manually create.") |
1133 | return 1 | 1137 | sys.exit(1) |
1134 | self.tap = tap | 1138 | self.tap = tap |
1135 | tapnum = int(tap[3:]) | 1139 | tapnum = int(tap[3:]) |
1136 | gateway = tapnum * 2 + 1 | 1140 | gateway = tapnum * 2 + 1 |