]> code.ossystems Code Review - openembedded-core.git/commitdiff
scripts/runqemu: Improve lockfile handling for python with close_fd=True
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 28 Nov 2018 17:31:39 +0000 (17:31 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sat, 1 Dec 2018 11:37:49 +0000 (11:37 +0000)
On python versions with close_fds=True (python 3.2 onwards), the tap
device lockfile isn't passed to the child process.

Since this guards against use of an active interface, we really want this
here, so pass it in pass_fds. This means if the parent exits early, the child
still holds the lock, avoiding messages like:

runqemu - ERROR - Failed to run qemu: qemu-system-x86_64: could not configure /dev/net/tun (tap0): Device or resource busy

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/runqemu

index d25de42f27de4aea1e935db49009b86a7b6d1cb1..f661892aecfd87950c475d239ecc5bb8845f4414 100755 (executable)
@@ -1220,7 +1220,10 @@ class BaseConfig(object):
         cmd = "%s %s" % (self.qemu_opt, kernel_opts)
         cmds = shlex.split(cmd)
         logger.info('Running %s\n' % cmd)
-        process = subprocess.Popen(cmds, stderr=subprocess.PIPE)
+        pass_fds = []
+        if self.lock_descriptor:
+            pass_fds = [self.lock_descriptor.fileno()]
+        process = subprocess.Popen(cmds, stderr=subprocess.PIPE, pass_fds=pass_fds)
         self.qemupid = process.pid
         retcode = process.wait()
         if retcode: