mirror of
https://git.yoctoproject.org/poky
synced 2026-03-19 13:49:41 +01:00
qemurunner: support serial console login via qemu stdout
runqemu script works with qemu machines which provide login and serial console to the qemu process stdout. Add the same support to qemurunner so that testing with testimage.bbclass is possible. Default qemu machines provide serial console boot logs and login via socket to qemu process but I don't see a reason why qemu process stdout should not be supported too since they work with runqemu as well. (From OE-Core rev: a3d4b80c5b4cce933c759d023c75b8671c56fe12) Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
cf8610beb7
commit
830f4cb0a6
@@ -451,7 +451,7 @@ class QemuRunner:
|
||||
self.logger.debug("Waiting at most %d seconds for login banner (%s)" %
|
||||
(self.boottime, time.strftime("%D %H:%M:%S")))
|
||||
endtime = time.time() + self.boottime
|
||||
socklist = [self.server_socket]
|
||||
filelist = [self.server_socket, self.runqemu.stdout]
|
||||
reachedlogin = False
|
||||
stopread = False
|
||||
qemusock = None
|
||||
@@ -459,24 +459,32 @@ class QemuRunner:
|
||||
data = b''
|
||||
while time.time() < endtime and not stopread:
|
||||
try:
|
||||
sread, swrite, serror = select.select(socklist, [], [], 5)
|
||||
sread, swrite, serror = select.select(filelist, [], [], 5)
|
||||
except InterruptedError:
|
||||
continue
|
||||
for sock in sread:
|
||||
if sock is self.server_socket:
|
||||
for file in sread:
|
||||
if file is self.server_socket:
|
||||
qemusock, addr = self.server_socket.accept()
|
||||
qemusock.setblocking(0)
|
||||
socklist.append(qemusock)
|
||||
socklist.remove(self.server_socket)
|
||||
qemusock.setblocking(False)
|
||||
filelist.append(qemusock)
|
||||
filelist.remove(self.server_socket)
|
||||
self.logger.debug("Connection from %s:%s" % addr)
|
||||
else:
|
||||
# try to avoid reading only a single character at a time
|
||||
time.sleep(0.1)
|
||||
data = data + sock.recv(1024)
|
||||
if hasattr(file, 'read'):
|
||||
read = file.read(1024)
|
||||
elif hasattr(file, 'recv'):
|
||||
read = file.recv(1024)
|
||||
else:
|
||||
self.logger.error('Invalid file type: %s\n%s' % (file))
|
||||
read = b''
|
||||
|
||||
data = data + read
|
||||
if data:
|
||||
bootlog += data
|
||||
if self.serial_ports < 2:
|
||||
# this socket has mixed console/kernel data, log it to logfile
|
||||
# this file has mixed console/kernel data, log it to logfile
|
||||
self.log(data)
|
||||
|
||||
data = b''
|
||||
@@ -493,8 +501,8 @@ class QemuRunner:
|
||||
# no need to check if reachedlogin unless we support multiple connections
|
||||
self.logger.debug("QEMU socket disconnected before login banner reached. (%s)" %
|
||||
time.strftime("%D %H:%M:%S"))
|
||||
socklist.remove(sock)
|
||||
sock.close()
|
||||
filelist.remove(file)
|
||||
file.close()
|
||||
stopread = True
|
||||
|
||||
if not reachedlogin:
|
||||
|
||||
Reference in New Issue
Block a user