summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2018-11-28 17:30:10 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-12-01 11:38:36 +0000
commit2d0b794b03a391cd2d7873c0c35bcd360616dfc9 (patch)
tree08472f4eee93eec2996402480d7a4e50e72d424e
parent3ecf232ec07a071d4916f31ad9ba4bcff72dff8c (diff)
downloadpoky-2d0b794b03a391cd2d7873c0c35bcd360616dfc9.tar.gz
scripts/runqemu: Tidy up lock handling code
Various tweaks: - Balance up the aquire/release functions - Use debug messge for both acquiring and release message for consistency in logs - Use None instead of an empty string - Reset the value of the field if we don't have the lock any more (From OE-Core rev: 58e48211f7cb44d959b571d449a94291c27535a5) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xscripts/runqemu16
1 files changed, 9 insertions, 7 deletions
diff --git a/scripts/runqemu b/scripts/runqemu
index 3786646c5d..d25de42f27 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -220,7 +220,7 @@ class BaseConfig(object):
220 self.tcpserial_portnum = '' 220 self.tcpserial_portnum = ''
221 self.custombiosdir = '' 221 self.custombiosdir = ''
222 self.lock = '' 222 self.lock = ''
223 self.lock_descriptor = '' 223 self.lock_descriptor = None
224 self.bitbake_e = '' 224 self.bitbake_e = ''
225 self.snapshot = False 225 self.snapshot = False
226 self.fstypes = ('ext2', 'ext3', 'ext4', 'jffs2', 'nfs', 'btrfs', 226 self.fstypes = ('ext2', 'ext3', 'ext4', 'jffs2', 'nfs', 'btrfs',
@@ -254,13 +254,17 @@ class BaseConfig(object):
254 logger.info(msg) 254 logger.info(msg)
255 if self.lock_descriptor: 255 if self.lock_descriptor:
256 self.lock_descriptor.close() 256 self.lock_descriptor.close()
257 self.lock_descriptor = None
257 return False 258 return False
258 return True 259 return True
259 260
260 def release_lock(self): 261 def release_lock(self):
261 fcntl.flock(self.lock_descriptor, fcntl.LOCK_UN) 262 if self.lock_descriptor:
262 self.lock_descriptor.close() 263 logger.debug("Releasing lockfile for tap device '%s'" % self.tap)
263 os.remove(self.lock) 264 fcntl.flock(self.lock_descriptor, fcntl.LOCK_UN)
265 self.lock_descriptor.close()
266 os.remove(self.lock)
267 self.lock_descriptor = None
264 268
265 def get(self, key): 269 def get(self, key):
266 if key in self.d: 270 if key in self.d:
@@ -1237,9 +1241,7 @@ class BaseConfig(object):
1237 cmd = 'sudo %s %s %s' % (self.qemuifdown, self.tap, self.bindir_native) 1241 cmd = 'sudo %s %s %s' % (self.qemuifdown, self.tap, self.bindir_native)
1238 logger.debug('Running %s' % cmd) 1242 logger.debug('Running %s' % cmd)
1239 subprocess.check_call(cmd, shell=True) 1243 subprocess.check_call(cmd, shell=True)
1240 if self.lock_descriptor: 1244 self.release_lock()
1241 logger.info("Releasing lockfile for tap device '%s'" % self.tap)
1242 self.release_lock()
1243 1245
1244 if self.nfs_running: 1246 if self.nfs_running:
1245 logger.info("Shutting down the userspace NFS server...") 1247 logger.info("Shutting down the userspace NFS server...")