summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2016-09-19 00:20:08 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-09-20 15:11:07 +0100
commit6a5bd99bfc334756752e091445ddf46d6b44aa8d (patch)
treec23984b9875a8f18d11bd9795d4be79e051ab9be
parent286db044c3da9565f5a0d79d7ab801d6624feaca (diff)
downloadpoky-6a5bd99bfc334756752e091445ddf46d6b44aa8d.tar.gz
runqemu: acquire_lock() should fail when failed to open the file
The open(self.lock, 'w') may fail when the lock is created by other users, return false for this case to let it try other devices. Fixed: runqemu - INFO - Running /sbin/ip link... runqemu - INFO - Acquiring lockfile /tmp/qemu-tap-locks/tap0.lock... Traceback (most recent call last): File "/buildarea/lyang1/poky/scripts/runqemu", line 972, in <module> ret = main() File "/buildarea/lyang1/poky/scripts/runqemu", line 963, in main config.setup_network() File "/buildarea/lyang1/poky/scripts/runqemu", line 810, in setup_network self.setup_tap() File "/buildarea/lyang1/poky/scripts/runqemu", line 761, in setup_tap if self.acquire_lock(): File "/buildarea/lyang1/poky/scripts/runqemu", line 182, in acquire_lock lock_descriptor = open(self.lock, 'w') PermissionError: [Errno 13] Permission denied: '/tmp/qemu-tap-locks/tap0.lock' (From OE-Core rev: f364f773a0381a75b5992c8c8a1d63a81dbd4422) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xscripts/runqemu8
1 files changed, 4 insertions, 4 deletions
diff --git a/scripts/runqemu b/scripts/runqemu
index b6bc0ba734..380568560b 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -168,14 +168,14 @@ class BaseConfig(object):
168 168
169 def acquire_lock(self): 169 def acquire_lock(self):
170 logger.info("Acquiring lockfile %s..." % self.lock) 170 logger.info("Acquiring lockfile %s..." % self.lock)
171 lock_descriptor = open(self.lock, 'w')
172 try: 171 try:
173 fcntl.flock(lock_descriptor, fcntl.LOCK_EX|fcntl.LOCK_NB) 172 self.lock_descriptor = open(self.lock, 'w')
173 fcntl.flock(self.lock_descriptor, fcntl.LOCK_EX|fcntl.LOCK_NB)
174 except Exception as e: 174 except Exception as e:
175 logger.info("Acquiring lockfile %s failed: %s" % (self.lock, e)) 175 logger.info("Acquiring lockfile %s failed: %s" % (self.lock, e))
176 lock_descriptor.close() 176 if self.lock_descriptor:
177 self.lock_descriptor.close()
177 return False 178 return False
178 self.lock_descriptor = lock_descriptor
179 return True 179 return True
180 180
181 def release_lock(self): 181 def release_lock(self):