summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorRandy Witt <randy.e.witt@linux.intel.com>2015-08-20 10:55:17 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-08-24 23:47:06 +0100
commit8d05d8a0c46564784463d2a39c68c467714f306d (patch)
tree5a2d79a38205c49cb1dfbb2b2ee01b7e92c223bd /meta/lib
parent62585cff0df20b33a4c4d02d6302f06098d363cb (diff)
downloadpoky-8d05d8a0c46564784463d2a39c68c467714f306d.tar.gz
qemurunner: Make create_socket() return data and use exceptions
So that create_socket() can be called more than once to create sockets, it now returns the socket and port rather than setting class variables directly. create_socket() now only uses exceptions for errors, not the return value from the function. (From OE-Core rev: b46d83a848cf23c7f639a6ebafbd0f2c1413584a) Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index c5bb13c878..c8d689900d 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -42,20 +42,18 @@ class QemuRunner:
42 self.runqemutime = 60 42 self.runqemutime = 60
43 43
44 def create_socket(self): 44 def create_socket(self):
45
46 try: 45 try:
47 self.server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 46 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
48 self.server_socket.setblocking(0) 47 sock.setblocking(0)
49 self.server_socket.bind(("127.0.0.1",0)) 48 sock.bind(("127.0.0.1",0))
50 self.server_socket.listen(2) 49 sock.listen(2)
51 self.serverport = self.server_socket.getsockname()[1] 50 port = sock.getsockname()[1]
52 logger.info("Created listening socket for qemu serial console on: 127.0.0.1:%s" % self.serverport) 51 logger.info("Created listening socket for qemu serial console on: 127.0.0.1:%s" % port)
53 return True 52 return (sock, port)
54 except socket.error, msg: 53
55 self.server_socket.close() 54 except socket.error:
56 logger.error("Failed to create listening socket: %s" % msg[1]) 55 sock.close()
57 return False 56 raise
58
59 57
60 def log(self, msg): 58 def log(self, msg):
61 if self.logfile: 59 if self.logfile:
@@ -82,7 +80,10 @@ class QemuRunner:
82 else: 80 else:
83 os.environ["DEPLOY_DIR_IMAGE"] = self.deploy_dir_image 81 os.environ["DEPLOY_DIR_IMAGE"] = self.deploy_dir_image
84 82
85 if not self.create_socket(): 83 try:
84 self.server_socket, self.serverport = self.create_socket()
85 except socket.error, msg:
86 logger.error("Failed to create listening socket: %s" % msg[1])
86 return False 87 return False
87 88
88 # Set this flag so that Qemu doesn't do any grabs as SDL grabs interact 89 # Set this flag so that Qemu doesn't do any grabs as SDL grabs interact