summaryrefslogtreecommitdiffstats
path: root/scripts
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-16 14:31:32 +0000
commit7ad6069850af97a63397007069d146b0ff5cc14d (patch)
tree765281e547b10486fa193d3f4db912806934e783 /scripts
parentfecdb7c64a7c76beab6d8c68949edaf9cf2e7a63 (diff)
downloadpoky-7ad6069850af97a63397007069d146b0ff5cc14d.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: 2728394ed75526f338cc9cb6bc62fb0ed6dc605f) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/runqemu16
1 files changed, 9 insertions, 7 deletions
diff --git a/scripts/runqemu b/scripts/runqemu
index 1fc27e5069..1eeafa9f5b 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -218,7 +218,7 @@ class BaseConfig(object):
218 self.tcpserial_portnum = '' 218 self.tcpserial_portnum = ''
219 self.custombiosdir = '' 219 self.custombiosdir = ''
220 self.lock = '' 220 self.lock = ''
221 self.lock_descriptor = '' 221 self.lock_descriptor = None
222 self.bitbake_e = '' 222 self.bitbake_e = ''
223 self.snapshot = False 223 self.snapshot = False
224 self.fstypes = ('ext2', 'ext3', 'ext4', 'jffs2', 'nfs', 'btrfs', 224 self.fstypes = ('ext2', 'ext3', 'ext4', 'jffs2', 'nfs', 'btrfs',
@@ -252,13 +252,17 @@ class BaseConfig(object):
252 logger.info(msg) 252 logger.info(msg)
253 if self.lock_descriptor: 253 if self.lock_descriptor:
254 self.lock_descriptor.close() 254 self.lock_descriptor.close()
255 self.lock_descriptor = None
255 return False 256 return False
256 return True 257 return True
257 258
258 def release_lock(self): 259 def release_lock(self):
259 fcntl.flock(self.lock_descriptor, fcntl.LOCK_UN) 260 if self.lock_descriptor:
260 self.lock_descriptor.close() 261 logger.debug("Releasing lockfile for tap device '%s'" % self.tap)
261 os.remove(self.lock) 262 fcntl.flock(self.lock_descriptor, fcntl.LOCK_UN)
263 self.lock_descriptor.close()
264 os.remove(self.lock)
265 self.lock_descriptor = None
262 266
263 def get(self, key): 267 def get(self, key):
264 if key in self.d: 268 if key in self.d:
@@ -1235,9 +1239,7 @@ class BaseConfig(object):
1235 cmd = 'sudo %s %s %s' % (self.qemuifdown, self.tap, self.bindir_native) 1239 cmd = 'sudo %s %s %s' % (self.qemuifdown, self.tap, self.bindir_native)
1236 logger.debug('Running %s' % cmd) 1240 logger.debug('Running %s' % cmd)
1237 subprocess.check_call(cmd, shell=True) 1241 subprocess.check_call(cmd, shell=True)
1238 if self.lock_descriptor: 1242 self.release_lock()
1239 logger.info("Releasing lockfile for tap device '%s'" % self.tap)
1240 self.release_lock()
1241 1243
1242 if self.nfs_running: 1244 if self.nfs_running:
1243 logger.info("Shutting down the userspace NFS server...") 1245 logger.info("Shutting down the userspace NFS server...")