Skip to content

Commit

Permalink
qemurunner: more cleanups for output blocking
Browse files Browse the repository at this point in the history
If we are only tracking stdout and are not using self.readsock we end
up throwing an exception blocking further action from the thread. Fix
this by checking self.readsock is not None first.

While we are at it split even into fd, event to make things clearer
and handle the fail path of stringify_event by echoing the hex value
of the unknown flag.

(From OE-Core rev: 5e58737c66090fe009ec49296f3e7d687eb05766)

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Cc: Mikko Rapeli <mikko.rapeli@linaro.org>
Cc: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
  • Loading branch information
stsquad authored and rpurdie committed Dec 21, 2023
1 parent c270131 commit 4a5ef39
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions meta/lib/oeqa/utils/qemurunner.py
Expand Up @@ -785,19 +785,20 @@ def eventloop(self):
self.logger.debug("Starting thread event loop")
while not breakout:
events = poll.poll(2)
for event in events:
for fd, event in events:

# An error occurred, bail out
if event[1] & self.errorevents:
raise Exception(self.stringify_event(event[1]))
if event & self.errorevents:
raise Exception(self.stringify_event(event))

# Event to stop the thread
if self.readpipe == event[0]:
if self.readpipe == fd:
self.logger.debug("Stop event received")
breakout = True
break

# A connection request was received
elif self.serversock and self.serversock.fileno() == event[0]:
elif self.serversock and self.serversock.fileno() == fd:
self.logger.debug("Connection request received")
self.readsock, _ = self.serversock.accept()
self.readsock.setblocking(0)
Expand All @@ -808,14 +809,14 @@ def eventloop(self):
self.connection_established.set()

# Actual data to be logged
elif self.readsock.fileno() == event[0]:
elif self.readsock and self.readsock.fileno() == fd:
data = self.recv(1024, self.readsock)
self.logfunc(data)
elif self.qemuoutput.fileno() == event[0]:
elif self.qemuoutput.fileno() == fd:
data = self.qemuoutput.read()
self.logger.debug("Data received on qemu stdout %s" % data)
self.logfunc(data, ".stdout")
elif self.serialsock and self.serialsock.fileno() == event[0]:
elif self.serialsock and self.serialsock.fileno() == fd:
if self.serial_lock.acquire(blocking=False):
data = self.recv(1024, self.serialsock)
self.logger.debug("Data received serial thread %s" % data.decode('utf-8', 'replace'))
Expand Down Expand Up @@ -864,6 +865,9 @@ def stringify_event(self, event):
val = 'POLLHUP'
elif select.POLLNVAL == event:
val = 'POLLNVAL'
else:
val = "0x%x" % (event)

return val

def close_socket(self, sock):
Expand Down

0 comments on commit 4a5ef39

Please sign in to comment.