[2/2] scripts/runqemu: Improve lockfile handling for python with close_fd=True

Submitted by Richard Purdie on Nov. 28, 2018, 5:36 p.m. | Patch ID: 156701

Details

Message ID 20181128173631.18288-2-richard.purdie@linuxfoundation.org
State Master Next
Commit ec54395c66aed9d8e17f515736d4b646341dd3c8
Headers show

Commit Message

Richard Purdie Nov. 28, 2018, 5:36 p.m.
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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/scripts/runqemu b/scripts/runqemu
index d25de42f27d..b5afa5883aa 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -1220,7 +1220,7 @@  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)
+        process = subprocess.Popen(cmds, stderr=subprocess.PIPE, pass_fds=[self.lock_descriptor.fileno()])
         self.qemupid = process.pid
         retcode = process.wait()
         if retcode: