Skip to contentSkip to conversation

oeqa/qemurunner: Add newlines serial workaround

PATCH In review Richard Purdie 2 participants 3 messages Oct 9, 2023 – Oct 10, 2023 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 oeqa/qemurunner: Add newlines serial workaround

We're struggling with the 6.5 kernel as the serial port getty doesn't appears sometimes leading to failures in CI. Add a workaround of sending some newlines as a way of unblocking the kernel/release issues whilst we try and work out how to get to the bottom of the issue.

---
 meta/lib/oeqa/utils/qemurunner.py | 9 +++++++++
 1 file changed, 9 insertions(+)
meta/lib/oeqa/utils/qemurunner.py +9 -0
index 387addfcdfe..6c91570d1b5 100644
@@ -444,9 +444,11 @@ 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
+        newlinetime = time.time() + 120
         filelist = [self.server_socket, self.runqemu.stdout]
         reachedlogin = False
         stopread = False
+        sentnewlines = False
         qemusock = None
         bootlog = b''
         data = b''
@@ -455,6 +457,13 @@ class QemuRunner:
                 sread, swrite, serror = select.select(filelist, [], [], 5)
             except InterruptedError:
                 continue
+            # With the 6.5 kernel, the serial port getty sometimes fails to appear, the data
+            # appears lost in some buffer somewhere. Wait two minutes, then if we've not had a login,
+            # try and provoke one. This is a workaround until we can work out the root cause.
+            if time.time() > newlinetime and not sentnewlines:
+                self.logger.warning('Probing the serial port to wake it up!')
+                self.server_socket.sendall(bytes("\n\n", "utf-8"))
+                sentnewlines = True
             for file in sread:
                 if file is self.server_socket:
                     qemusock, addr = self.server_socket.accept()
Signature · 1 line
2.39.2
#1 lore raw

PATCH 2/2 runqemu/qemurunner: Use nodelay with tcp serial connections

This disables Nagle's algorithm for our tcp serial connections which may be causing data transfer issues.

---
 meta/conf/machine/include/loongarch/qemuloongarch.inc | 2 +-
 meta/conf/machine/include/riscv/qemuriscv.inc         | 2 +-
 meta/conf/machine/qemuarm.conf                        | 2 +-
 meta/conf/machine/qemuarm64.conf                      | 2 +-
 meta/lib/oeqa/utils/qemurunner.py                     | 1 +
 scripts/runqemu                                       | 4 ++--
 6 files changed, 7 insertions(+), 6 deletions(-)
meta/conf/machine/include/loongarch/qemuloongarch.inc +1 -1
index 30f560532e4..e1bcfabc430 100644
@@ -30,6 +30,6 @@ QB_TAP_OPT = "-netdev tap,id=net0,ifname=@TAP@,script=no,downscript=no"
 QB_NETWORK_DEVICE = "-device virtio-net-device,netdev=net0,mac=@MAC@"
 QB_ROOTFS_OPT = "-drive id=disk0,file=@ROOTFS@,if=none,format=raw -device virtio-blk-device,drive=disk0"
 QB_SERIAL_OPT = "-device virtio-serial-pci -chardev null,id=virtcon -device virtconsole,chardev=virtcon"
-QB_TCPSERIAL_OPT = " -device virtio-serial-pci -chardev socket,id=virtcon,port=@PORT@,host=127.0.0.1 -device virtconsole,chardev=virtcon"
+QB_TCPSERIAL_OPT = " -device virtio-serial-pci -chardev socket,id=virtcon,port=@PORT@,host=127.0.0.1,nodelay=on -device virtconsole,chardev=virtcon"
 # Add the 'virtio-rng-pci' device otherwise the guest may run out of entropy
 QB_OPT_APPEND = " -object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-device,rng=rng0"
meta/conf/machine/include/riscv/qemuriscv.inc +1 -1
index 325e7c514f8..46ae66b9e50 100644
@@ -33,6 +33,6 @@ QB_TAP_OPT = "-netdev tap,id=net0,ifname=@TAP@,script=no,downscript=no"
 QB_NETWORK_DEVICE = "-device virtio-net-device,netdev=net0,mac=@MAC@"
 QB_ROOTFS_OPT = "-drive id=disk0,file=@ROOTFS@,if=none,format=raw -device virtio-blk-device,drive=disk0"
 QB_SERIAL_OPT = "-device virtio-serial-device -chardev null,id=virtcon -device virtconsole,chardev=virtcon"
-QB_TCPSERIAL_OPT = " -device virtio-serial-device -chardev socket,id=virtcon,port=@PORT@,host=127.0.0.1 -device virtconsole,chardev=virtcon"
+QB_TCPSERIAL_OPT = " -device virtio-serial-device -chardev socket,id=virtcon,port=@PORT@,host=127.0.0.1,nodelay=on -device virtconsole,chardev=virtcon"
 QB_GRAPHICS = "-device bochs-display"
 QB_OPT_APPEND = "-device virtio-tablet-pci -device virtio-keyboard-pci"
meta/conf/machine/qemuarm.conf +1 -1
index 881733eb2da..943ce7c16a2 100644
@@ -26,6 +26,6 @@ QB_NETWORK_DEVICE = "-device virtio-net-device,netdev=net0,mac=@MAC@"
 QB_ROOTFS_OPT = "-drive id=disk0,file=@ROOTFS@,if=none,format=raw -device virtio-blk-device,drive=disk0"
 # Virtio serial console
 QB_SERIAL_OPT = "-device virtio-serial-device -chardev null,id=virtcon -device virtconsole,chardev=virtcon"
-QB_TCPSERIAL_OPT = "-device virtio-serial-device -chardev socket,id=virtcon,port=@PORT@,host=127.0.0.1 -device virtconsole,chardev=virtcon"
+QB_TCPSERIAL_OPT = "-device virtio-serial-device -chardev socket,id=virtcon,port=@PORT@,host=127.0.0.1,nodelay=on -device virtconsole,chardev=virtcon"
 
 KMACHINE:qemuarm = "qemuarma15"
meta/conf/machine/qemuarm64.conf +1 -1
index 226b86fa18a..a096d964db5 100644
@@ -27,4 +27,4 @@ QB_NETWORK_DEVICE = "-device virtio-net-pci,netdev=net0,mac=@MAC@"
 QB_ROOTFS_OPT = "-drive id=disk0,file=@ROOTFS@,if=none,format=raw -device virtio-blk-pci,drive=disk0"
 # Virtio serial console
 QB_SERIAL_OPT = "-device virtio-serial-pci -chardev null,id=virtcon -device virtconsole,chardev=virtcon"
-QB_TCPSERIAL_OPT = "-device virtio-serial-pci -chardev socket,id=virtcon,port=@PORT@,host=127.0.0.1 -device virtconsole,chardev=virtcon"
+QB_TCPSERIAL_OPT = "-device virtio-serial-pci -chardev socket,id=virtcon,port=@PORT@,host=127.0.0.1,nodelay=on -device virtconsole,chardev=virtcon"
meta/lib/oeqa/utils/qemurunner.py +1 -0
index 6c91570d1b5..bcc267c9820 100644
@@ -97,6 +97,7 @@ class QemuRunner:
         try:
             sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
             sock.setblocking(0)
+            sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
             sock.bind(("127.0.0.1",0))
             sock.listen(2)
             port = sock.getsockname()[1]
scripts/runqemu +2 -2
index 0668e12e616..6fca7439a1d 100755
@@ -842,11 +842,11 @@ to your build configuration.
             if self.get('QB_TCPSERIAL_OPT'):
                 self.qemu_opt_script += ' ' + self.get('QB_TCPSERIAL_OPT').replace('@PORT@', port)
             else:
-                self.qemu_opt_script += ' -serial tcp:127.0.0.1:%s' % port
+                self.qemu_opt_script += ' -serial tcp:127.0.0.1:%s,nodelay=on' % port
 
             if len(ports) > 1:
                 for port in ports[1:]:
-                    self.qemu_opt_script += ' -serial tcp:127.0.0.1:%s' % port
+                    self.qemu_opt_script += ' -serial tcp:127.0.0.1:%s,nodelay=on' % port
 
     def check_and_set(self):
         """Check configs sanity and set when needed"""
Signature · 1 line
2.39.2