summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2018-11-28 16:12:51 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-12-01 11:38:36 +0000
commit3ecf232ec07a071d4916f31ad9ba4bcff72dff8c (patch)
tree64f857ffd55c38190263d14d687b1cbf8c96b9ee /meta
parent1eaf3631a63dab882ef3aee28d97ff216d981db3 (diff)
downloadpoky-3ecf232ec07a071d4916f31ad9ba4bcff72dff8c.tar.gz
oeqa/qemurunner: Remove resource python warnings
If runqemu fails it would leak an unclosed socket and file. Ensure we close these in all cases to remove the resource warning. (From OE-Core rev: ed80e46ccbc8fe8e9148d80723152066fa00ba28) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index 241d1eced8..409e86d4bc 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -139,7 +139,7 @@ class QemuRunner:
139 139
140 def launch(self, launch_cmd, get_ip = True, qemuparams = None, extra_bootparams = None, env = None): 140 def launch(self, launch_cmd, get_ip = True, qemuparams = None, extra_bootparams = None, env = None):
141 try: 141 try:
142 threadsock, threadport = self.create_socket() 142 self.threadsock, threadport = self.create_socket()
143 self.server_socket, self.serverport = self.create_socket() 143 self.server_socket, self.serverport = self.create_socket()
144 except socket.error as msg: 144 except socket.error as msg:
145 self.logger.error("Failed to create listening socket: %s" % msg[1]) 145 self.logger.error("Failed to create listening socket: %s" % msg[1])
@@ -272,7 +272,7 @@ class QemuRunner:
272 self.logger.debug("Target IP: %s" % self.ip) 272 self.logger.debug("Target IP: %s" % self.ip)
273 self.logger.debug("Server IP: %s" % self.server_ip) 273 self.logger.debug("Server IP: %s" % self.server_ip)
274 274
275 self.thread = LoggingThread(self.log, threadsock, self.logger) 275 self.thread = LoggingThread(self.log, self.threadsock, self.logger)
276 self.thread.start() 276 self.thread.start()
277 if not self.thread.connection_established.wait(self.boottime): 277 if not self.thread.connection_established.wait(self.boottime):
278 self.logger.error("Didn't receive a console connection from qemu. " 278 self.logger.error("Didn't receive a console connection from qemu. "
@@ -381,13 +381,19 @@ class QemuRunner:
381 self.runqemu.stdin.close() 381 self.runqemu.stdin.close()
382 self.runqemu.stdout.close() 382 self.runqemu.stdout.close()
383 self.runqemu = None 383 self.runqemu = None
384
384 if hasattr(self, 'server_socket') and self.server_socket: 385 if hasattr(self, 'server_socket') and self.server_socket:
385 self.server_socket.close() 386 self.server_socket.close()
386 self.server_socket = None 387 self.server_socket = None
388 if hasattr(self, 'threadsock') and self.threadsock:
389 self.threadsock.close()
390 self.threadsock = None
387 self.qemupid = None 391 self.qemupid = None
388 self.ip = None 392 self.ip = None
389 if os.path.exists(self.qemu_pidfile): 393 if os.path.exists(self.qemu_pidfile):
390 os.remove(self.qemu_pidfile) 394 os.remove(self.qemu_pidfile)
395 if self.monitorpipe:
396 self.monitorpipe.close()
391 397
392 def stop_qemu_system(self): 398 def stop_qemu_system(self):
393 if self.qemupid: 399 if self.qemupid: