summaryrefslogtreecommitdiffstats
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-16 14:31:32 +0000
commit5e12af758777c4c87fd8dfa1721f7c673817e133 (patch)
tree54be9c6bdf48c8aa9a45577b7a775b48cde71c18
parent1cd8b3b7897b62a80d744ba7828b01a13519347a (diff)
downloadpoky-5e12af758777c4c87fd8dfa1721f7c673817e133.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) (From OE-Core rev: 81ce67fb1274faafb9e7386c5982aeaf4c74294d) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-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 8d320bec6e..03f46ffb1c 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -135,7 +135,7 @@ class QemuRunner:
135 135
136 def launch(self, launch_cmd, get_ip = True, qemuparams = None, extra_bootparams = None, env = None): 136 def launch(self, launch_cmd, get_ip = True, qemuparams = None, extra_bootparams = None, env = None):
137 try: 137 try:
138 threadsock, threadport = self.create_socket() 138 self.threadsock, threadport = self.create_socket()
139 self.server_socket, self.serverport = self.create_socket() 139 self.server_socket, self.serverport = self.create_socket()
140 except socket.error as msg: 140 except socket.error as msg:
141 self.logger.error("Failed to create listening socket: %s" % msg[1]) 141 self.logger.error("Failed to create listening socket: %s" % msg[1])
@@ -263,7 +263,7 @@ class QemuRunner:
263 self.logger.debug("Target IP: %s" % self.ip) 263 self.logger.debug("Target IP: %s" % self.ip)
264 self.logger.debug("Server IP: %s" % self.server_ip) 264 self.logger.debug("Server IP: %s" % self.server_ip)
265 265
266 self.thread = LoggingThread(self.log, threadsock, self.logger) 266 self.thread = LoggingThread(self.log, self.threadsock, self.logger)
267 self.thread.start() 267 self.thread.start()
268 if not self.thread.connection_established.wait(self.boottime): 268 if not self.thread.connection_established.wait(self.boottime):
269 self.logger.error("Didn't receive a console connection from qemu. " 269 self.logger.error("Didn't receive a console connection from qemu. "
@@ -372,13 +372,19 @@ class QemuRunner:
372 self.runqemu.stdin.close() 372 self.runqemu.stdin.close()
373 self.runqemu.stdout.close() 373 self.runqemu.stdout.close()
374 self.runqemu = None 374 self.runqemu = None
375
375 if hasattr(self, 'server_socket') and self.server_socket: 376 if hasattr(self, 'server_socket') and self.server_socket:
376 self.server_socket.close() 377 self.server_socket.close()
377 self.server_socket = None 378 self.server_socket = None
379 if hasattr(self, 'threadsock') and self.threadsock:
380 self.threadsock.close()
381 self.threadsock = None
378 self.qemupid = None 382 self.qemupid = None
379 self.ip = None 383 self.ip = None
380 if os.path.exists(self.qemu_pidfile): 384 if os.path.exists(self.qemu_pidfile):
381 os.remove(self.qemu_pidfile) 385 os.remove(self.qemu_pidfile)
386 if self.monitorpipe:
387 self.monitorpipe.close()
382 388
383 def stop_qemu_system(self): 389 def stop_qemu_system(self):
384 if self.qemupid: 390 if self.qemupid: