From: Changqing Li Date: Fri, 2 Aug 2019 02:43:59 +0000 (+0800) Subject: runqemu: fix get portlock fail for multi users X-Git-Tag: uninative-2.7~601 X-Git-Url: https://code.ossystems.io/gitweb?a=commitdiff_plain;h=56f30e5377ebe5cc4544f081e001934706a0d8d3;p=openembedded-core.git runqemu: fix get portlock fail for multi users when runqemu with slirp option on same host with different users, it will report PermissionError: [Errno 13] Permission denied: '/tmp/qemu-port-locks/2222.lock' and during handle this exception, another exception happened since key not exist. Fix by check if key exist first Signed-off-by: Changqing Li Signed-off-by: Richard Purdie --- diff --git a/scripts/runqemu b/scripts/runqemu index 6fae3d8c5d..9d6a2e86d4 100755 --- a/scripts/runqemu +++ b/scripts/runqemu @@ -235,7 +235,7 @@ class BaseConfig(object): else: return False - def acquire_portlock(self, lockfile, error=True): + def acquire_portlock(self, lockfile): logger.debug("Acquiring lockfile %s..." % lockfile) try: portlock_descriptor = open(lockfile, 'w') @@ -243,11 +243,8 @@ class BaseConfig(object): fcntl.flock(self.portlocks[lockfile], fcntl.LOCK_EX|fcntl.LOCK_NB) except Exception as e: msg = "Acquiring lockfile %s failed: %s" % (lockfile, e) - if error: - logger.error(msg) - else: - logger.info(msg) - if self.portlocks[lockfile]: + logger.info(msg) + if lockfile in self.portlocks.keys() and self.portlocks[lockfile]: self.portlocks[lockfile].close() del self.portlocks[lockfile] return False