]> code.ossystems Code Review - openembedded-core.git/commitdiff
runqemu: fix get portlock fail for multi users
authorChangqing Li <changqing.li@windriver.com>
Fri, 2 Aug 2019 02:43:59 +0000 (10:43 +0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sat, 3 Aug 2019 13:47:31 +0000 (14:47 +0100)
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 <changqing.li@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/runqemu

index 6fae3d8c5d8d08facff800cba5e358fb40a28afd..9d6a2e86d44fd73cedfb2f600039d8a36d1ab158 100755 (executable)
@@ -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