diff options
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/runqemu | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/scripts/runqemu b/scripts/runqemu index cb36c2007b..bd3aee0c2f 100755 --- a/scripts/runqemu +++ b/scripts/runqemu | |||
| @@ -1199,6 +1199,7 @@ class BaseConfig(object): | |||
| 1199 | self.qemu_opt += " -serial mon:vc -serial null" | 1199 | self.qemu_opt += " -serial mon:vc -serial null" |
| 1200 | 1200 | ||
| 1201 | def start_qemu(self): | 1201 | def start_qemu(self): |
| 1202 | import shlex | ||
| 1202 | if self.kernel: | 1203 | if self.kernel: |
| 1203 | kernel_opts = "-kernel %s -append '%s %s %s %s'" % (self.kernel, self.kernel_cmdline, | 1204 | kernel_opts = "-kernel %s -append '%s %s %s %s'" % (self.kernel, self.kernel_cmdline, |
| 1204 | self.kernel_cmdline_script, self.get('QB_KERNEL_CMDLINE_APPEND'), | 1205 | self.kernel_cmdline_script, self.get('QB_KERNEL_CMDLINE_APPEND'), |
| @@ -1208,11 +1209,16 @@ class BaseConfig(object): | |||
| 1208 | else: | 1209 | else: |
| 1209 | kernel_opts = "" | 1210 | kernel_opts = "" |
| 1210 | cmd = "%s %s" % (self.qemu_opt, kernel_opts) | 1211 | cmd = "%s %s" % (self.qemu_opt, kernel_opts) |
| 1212 | cmds = shlex.split(cmd) | ||
| 1211 | logger.info('Running %s\n' % cmd) | 1213 | logger.info('Running %s\n' % cmd) |
| 1212 | process = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE) | 1214 | process = subprocess.Popen(cmds, stderr=subprocess.PIPE) |
| 1213 | self.qemupid = process.pid | 1215 | self.qemupid = process.pid |
| 1214 | if process.wait(): | 1216 | retcode = process.wait() |
| 1215 | logger.error("Failed to run qemu: %s", process.stderr.read().decode()) | 1217 | if retcode: |
| 1218 | if retcode == -signal.SIGTERM: | ||
| 1219 | logger.info("Qemu terminated by SIGTERM") | ||
| 1220 | else: | ||
| 1221 | logger.error("Failed to run qemu: %s", process.stderr.read().decode()) | ||
| 1216 | 1222 | ||
| 1217 | def cleanup(self): | 1223 | def cleanup(self): |
| 1218 | if self.cleaned: | 1224 | if self.cleaned: |
| @@ -1307,6 +1313,7 @@ def main(): | |||
| 1307 | logger.info("SIGTERM received") | 1313 | logger.info("SIGTERM received") |
| 1308 | os.kill(config.qemupid, signal.SIGTERM) | 1314 | os.kill(config.qemupid, signal.SIGTERM) |
| 1309 | config.cleanup() | 1315 | config.cleanup() |
| 1316 | subprocess.run(["tput", "smam"]) | ||
| 1310 | signal.signal(signal.SIGTERM, sigterm_handler) | 1317 | signal.signal(signal.SIGTERM, sigterm_handler) |
| 1311 | 1318 | ||
| 1312 | config.check_args() | 1319 | config.check_args() |
| @@ -1328,6 +1335,7 @@ def main(): | |||
| 1328 | return 1 | 1335 | return 1 |
| 1329 | finally: | 1336 | finally: |
| 1330 | config.cleanup() | 1337 | config.cleanup() |
| 1338 | subprocess.run(["tput", "smam"]) | ||
| 1331 | 1339 | ||
| 1332 | if __name__ == "__main__": | 1340 | if __name__ == "__main__": |
| 1333 | sys.exit(main()) | 1341 | sys.exit(main()) |
