From: Randy Witt <randy.e.witt@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH V2 2/3] qemurunner: Make create_socket() return data and use exceptions
Date: Thu, 20 Aug 2015 16:46:12 -0700 [thread overview]
Message-ID: <1440114373-4317-3-git-send-email-randy.e.witt@linux.intel.com> (raw)
In-Reply-To: <1440114373-4317-1-git-send-email-randy.e.witt@linux.intel.com>
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.
Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com>
---
meta/lib/oeqa/utils/qemurunner.py | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index c5bb13c..c8d6899 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -42,20 +42,18 @@ class QemuRunner:
self.runqemutime = 60
def create_socket(self):
-
try:
- self.server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.server_socket.setblocking(0)
- self.server_socket.bind(("127.0.0.1",0))
- self.server_socket.listen(2)
- self.serverport = self.server_socket.getsockname()[1]
- logger.info("Created listening socket for qemu serial console on: 127.0.0.1:%s" % self.serverport)
- return True
- except socket.error, msg:
- self.server_socket.close()
- logger.error("Failed to create listening socket: %s" % msg[1])
- return False
-
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ sock.setblocking(0)
+ sock.bind(("127.0.0.1",0))
+ sock.listen(2)
+ port = sock.getsockname()[1]
+ logger.info("Created listening socket for qemu serial console on: 127.0.0.1:%s" % port)
+ return (sock, port)
+
+ except socket.error:
+ sock.close()
+ raise
def log(self, msg):
if self.logfile:
@@ -82,7 +80,10 @@ class QemuRunner:
else:
os.environ["DEPLOY_DIR_IMAGE"] = self.deploy_dir_image
- if not self.create_socket():
+ try:
+ self.server_socket, self.serverport = self.create_socket()
+ except socket.error, msg:
+ logger.error("Failed to create listening socket: %s" % msg[1])
return False
# Set this flag so that Qemu doesn't do any grabs as SDL grabs interact
--
2.4.3
next prev parent reply other threads:[~2015-08-20 23:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-20 22:24 Try to fix qemu freezing due to full socket buffers Randy Witt
2015-08-20 22:24 ` [PATCH 1/3] qemurunner.py: Move some class variables that should only be local Randy Witt
2015-08-20 22:24 ` [PATCH 2/3] qemurunner: Make create_socket() return data and use exceptions Randy Witt
2015-08-20 22:24 ` [PATCH 3/3] qemurunner: Use two serial ports and log console with a thread Randy Witt
2015-08-20 23:46 ` [PATCH V2 0/3] Try to fix qemu freezing due to full socket buffers Randy Witt
2015-08-20 23:46 ` [PATCH V2 1/3] qemurunner.py: Move some class variables that should only be local Randy Witt
2015-08-20 23:46 ` Randy Witt [this message]
2015-08-20 23:46 ` [PATCH V2 3/3] qemurunner: Use two serial ports and log console with a thread Randy Witt
2015-08-21 13:36 ` Try to fix qemu freezing due to full socket buffers Burton, Ross
2015-08-21 13:41 ` Richard Purdie
2015-08-21 14:23 ` Burton, Ross
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1440114373-4317-3-git-send-email-randy.e.witt@linux.intel.com \
--to=randy.e.witt@linux.intel.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox