diff options
Diffstat (limited to 'scripts/runqemu')
-rwxr-xr-x | scripts/runqemu | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/scripts/runqemu b/scripts/runqemu index edd17d09c4..c985f4e75a 100755 --- a/scripts/runqemu +++ b/scripts/runqemu | |||
@@ -232,9 +232,12 @@ class BaseConfig(object): | |||
232 | def release_taplock(self): | 232 | def release_taplock(self): |
233 | if self.taplock_descriptor: | 233 | if self.taplock_descriptor: |
234 | logger.debug("Releasing lockfile for tap device '%s'" % self.tap) | 234 | logger.debug("Releasing lockfile for tap device '%s'" % self.tap) |
235 | fcntl.flock(self.taplock_descriptor, fcntl.LOCK_UN) | 235 | # We pass the fd to the qemu process and if we unlock here, it would unlock for |
236 | # that too. Therefore don't unlock, just close | ||
237 | # fcntl.flock(self.taplock_descriptor, fcntl.LOCK_UN) | ||
236 | self.taplock_descriptor.close() | 238 | self.taplock_descriptor.close() |
237 | os.remove(self.taplock) | 239 | # Removing the file is a potential race, don't do that either |
240 | # os.remove(self.taplock) | ||
238 | self.taplock_descriptor = None | 241 | self.taplock_descriptor = None |
239 | 242 | ||
240 | def check_free_port(self, host, port, lockdir): | 243 | def check_free_port(self, host, port, lockdir): |
@@ -272,17 +275,23 @@ class BaseConfig(object): | |||
272 | 275 | ||
273 | def release_portlock(self, lockfile=None): | 276 | def release_portlock(self, lockfile=None): |
274 | if lockfile != None: | 277 | if lockfile != None: |
275 | logger.debug("Releasing lockfile '%s'" % lockfile) | 278 | logger.debug("Releasing lockfile '%s'" % lockfile) |
276 | fcntl.flock(self.portlocks[lockfile], fcntl.LOCK_UN) | 279 | # We pass the fd to the qemu process and if we unlock here, it would unlock for |
277 | self.portlocks[lockfile].close() | 280 | # that too. Therefore don't unlock, just close |
278 | os.remove(lockfile) | 281 | # fcntl.flock(self.portlocks[lockfile], fcntl.LOCK_UN) |
279 | del self.portlocks[lockfile] | 282 | self.portlocks[lockfile].close() |
283 | # Removing the file is a potential race, don't do that either | ||
284 | # os.remove(lockfile) | ||
285 | del self.portlocks[lockfile] | ||
280 | elif len(self.portlocks): | 286 | elif len(self.portlocks): |
281 | for lockfile, descriptor in self.portlocks.items(): | 287 | for lockfile, descriptor in self.portlocks.items(): |
282 | logger.debug("Releasing lockfile '%s'" % lockfile) | 288 | logger.debug("Releasing lockfile '%s'" % lockfile) |
283 | fcntl.flock(descriptor, fcntl.LOCK_UN) | 289 | # We pass the fd to the qemu process and if we unlock here, it would unlock for |
290 | # that too. Therefore don't unlock, just close | ||
291 | # fcntl.flock(descriptor, fcntl.LOCK_UN) | ||
284 | descriptor.close() | 292 | descriptor.close() |
285 | os.remove(lockfile) | 293 | # Removing the file is a potential race, don't do that either |
294 | # os.remove(lockfile) | ||
286 | self.portlocks = {} | 295 | self.portlocks = {} |
287 | 296 | ||
288 | def get(self, key): | 297 | def get(self, key): |