qemurunner: Simplify binary data handling
I have concerns that bad timing of the flow of data from the logger might corrupt the output due to the way binary strings are handled in qemurunner. This simplifies the code to do the same thing it did before but much more safely. (From OE-Core rev: 20bc247316ab915465a4b1add6d09b48e07202ac) (From OE-Core rev: 84f801e44f4b5ba65489a3a418e5f699abccd003) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 1e87283e92a2765bb5d54d17138b208bc395953b) Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
66f536ad57
commit
9a2074b54a
|
@ -274,7 +274,7 @@ class QemuRunner:
|
|||
reachedlogin = False
|
||||
stopread = False
|
||||
qemusock = None
|
||||
bootlog = ''
|
||||
bootlog = b''
|
||||
data = b''
|
||||
while time.time() < endtime and not stopread:
|
||||
try:
|
||||
|
@ -291,17 +291,13 @@ class QemuRunner:
|
|||
else:
|
||||
data = data + sock.recv(1024)
|
||||
if data:
|
||||
try:
|
||||
data = data.decode("utf-8", errors="surrogateescape")
|
||||
bootlog += data
|
||||
data = b''
|
||||
if re.search(".* login:", bootlog):
|
||||
self.server_socket = qemusock
|
||||
stopread = True
|
||||
reachedlogin = True
|
||||
self.logger.debug("Reached login banner")
|
||||
except UnicodeDecodeError:
|
||||
continue
|
||||
bootlog += data
|
||||
data = b''
|
||||
if b' login:' in bootlog:
|
||||
self.server_socket = qemusock
|
||||
stopread = True
|
||||
reachedlogin = True
|
||||
self.logger.debug("Reached login banner")
|
||||
else:
|
||||
socklist.remove(sock)
|
||||
sock.close()
|
||||
|
|
Loading…
Reference in New Issue