diff options
Diffstat (limited to 'poky/scripts')
-rwxr-xr-x | poky/scripts/runqemu | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/poky/scripts/runqemu b/poky/scripts/runqemu index bd3aee0c2..c6b7580dd 100755 --- a/poky/scripts/runqemu +++ b/poky/scripts/runqemu @@ -218,7 +218,7 @@ class BaseConfig(object): self.tcpserial_portnum = '' self.custombiosdir = '' self.lock = '' - self.lock_descriptor = '' + self.lock_descriptor = None self.bitbake_e = '' self.snapshot = False self.fstypes = ('ext2', 'ext3', 'ext4', 'jffs2', 'nfs', 'btrfs', @@ -252,13 +252,17 @@ class BaseConfig(object): logger.info(msg) if self.lock_descriptor: self.lock_descriptor.close() + self.lock_descriptor = None return False return True def release_lock(self): - fcntl.flock(self.lock_descriptor, fcntl.LOCK_UN) - self.lock_descriptor.close() - os.remove(self.lock) + if self.lock_descriptor: + logger.debug("Releasing lockfile for tap device '%s'" % self.tap) + fcntl.flock(self.lock_descriptor, fcntl.LOCK_UN) + self.lock_descriptor.close() + os.remove(self.lock) + self.lock_descriptor = None def get(self, key): if key in self.d: @@ -1211,7 +1215,10 @@ class BaseConfig(object): cmd = "%s %s" % (self.qemu_opt, kernel_opts) cmds = shlex.split(cmd) logger.info('Running %s\n' % cmd) - process = subprocess.Popen(cmds, stderr=subprocess.PIPE) + pass_fds = [] + if self.lock_descriptor: + pass_fds = [self.lock_descriptor.fileno()] + process = subprocess.Popen(cmds, stderr=subprocess.PIPE, pass_fds=pass_fds) self.qemupid = process.pid retcode = process.wait() if retcode: @@ -1232,9 +1239,7 @@ class BaseConfig(object): cmd = 'sudo %s %s %s' % (self.qemuifdown, self.tap, self.bindir_native) logger.debug('Running %s' % cmd) subprocess.check_call(cmd, shell=True) - if self.lock_descriptor: - logger.info("Releasing lockfile for tap device '%s'" % self.tap) - self.release_lock() + self.release_lock() if self.nfs_running: logger.info("Shutting down the userspace NFS server...") @@ -1313,7 +1318,7 @@ def main(): logger.info("SIGTERM received") os.kill(config.qemupid, signal.SIGTERM) config.cleanup() - subprocess.run(["tput", "smam"]) + subprocess.check_call(["tput", "smam"]) signal.signal(signal.SIGTERM, sigterm_handler) config.check_args() @@ -1335,7 +1340,7 @@ def main(): return 1 finally: config.cleanup() - subprocess.run(["tput", "smam"]) + subprocess.check_call(["tput", "smam"]) if __name__ == "__main__": sys.exit(main()) |