Skip to contentSkip to conversation

scripts/runqemu: Add serialstdio mode

PATCH New Michael Halstead 1 participant 3 messages Nov 8, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 scripts/runqemu: Add serialstdio mode

From: Richard Purdie <[email protected]>

Its currently not possible to have a console available whilst using qemu in graphics mode. This is causing some issues for testing autobuilder bringup so all a "serialstdio" mode to runqemu to accomodate this.

The existing serialstdio internal variable is renamed to allow the new user visible option.

---
 scripts/runqemu | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
scripts/runqemu +7 -2
index 087220ca0a..0c61253d6a 100755
@@ -75,6 +75,7 @@ of the following environment variables (in any order):
   Simplified QEMU command-line options can be passed with:
     nographic - disable video console
     serial - enable a serial console on /dev/ttyS0
+    serialstdio - enable a serial console on the console (regardless of graphics mode)
     slirp - enable user networking, no root privileges is required
     kvm - enable KVM when running x86/x86_64 (VT-capable CPU required)
     kvm-vhost - enable KVM with vhost when running x86/x86_64 (VT-capable CPU required)
@@ -211,6 +212,7 @@ class BaseConfig(object):
         self.slirp_enabled = False
         self.nfs_instance = 0
         self.nfs_running = False
+        self.serialconsole = False
         self.serialstdio = False
         self.cleantap = False
         self.saved_stty = ''
@@ -428,6 +430,9 @@ class BaseConfig(object):
                 self.qemu_opt_script += ' -nographic'
                 self.kernel_cmdline_script += ' console=ttyS0'
             elif arg == 'serial':
+                self.kernel_cmdline_script += ' console=ttyS0'
+                self.serialconsole = True
+            elif arg == "serialstdio":
                 self.kernel_cmdline_script += ' console=ttyS0'
                 self.serialstdio = True
             elif arg == 'audio':
@@ -1169,7 +1174,7 @@ class BaseConfig(object):
         if self.snapshot:
             self.qemu_opt += " -snapshot"
 
-        if self.serialstdio:
+        if self.serialconsole:
             if sys.stdin.isatty():
                 subprocess.check_call("stty intr ^]", shell=True)
                 logger.info("Interrupt character is '^]'")
@@ -1196,7 +1201,7 @@ class BaseConfig(object):
         #     INIT: Id "S1" respawning too fast: disabled for 5 minutes
         serial_num = len(re.findall("-serial", self.qemu_opt))
         if serial_num == 0:
-            if re.search("-nographic", self.qemu_opt):
+            if re.search("-nographic", self.qemu_opt) or self.serialstdio:
                 self.qemu_opt += " -serial mon:stdio -serial null"
             else:
                 self.qemu_opt += " -serial mon:vc -serial null"
Signature · 1 line
2.17.2
#1 lore raw

PATCH 2/3 scripts/runqemu: Replace subprocess.run() for compatibilty

subprocess.run() was introduced in Python 3.5. We currently support down to Python 3.4 so I've replaced it with subprocess.check_call() which is available in that version.

---
 scripts/runqemu | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/runqemu +2 -2
index 0c61253d6a..c79be9a846 100755
@@ -1321,7 +1321,7 @@ def main():
             logger.info("SIGTERM received")
             os.kill(config.qemupid, signal.SIGTERM)
             config.cleanup()
-            subprocess.run(["tput", "smam"])
+            subprocess.check_call(["tput", "smam"])
         signal.signal(signal.SIGTERM, sigterm_handler)
 
         config.check_args()
@@ -1343,7 +1343,7 @@ def main():
         return 1
     finally:
         config.cleanup()
-        subprocess.run(["tput", "smam"])
+        subprocess.check_call(["tput", "smam"])
 
 if __name__ == "__main__":
     sys.exit(main())
Signature · 1 line
2.17.2
#2 lore raw

PATCH 3/3 scripts/autobuilder-worker-prereq-tests: Shore up qemu testing

In reply to Michael Halstead

Check that yocto-autobuilder-helper has been cloned to the correct location. Check that vnc is running using the same script the autobuilder does. Set the DISPLAY enviroment variable to :1 the same way we do when building normally.
Make the VM's serial console available so we can log in and power off allowing the tests to continue.

---
 scripts/autobuilder-worker-prereq-tests | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
scripts/autobuilder-worker-prereq-tests +8 -2
index bb46c69135..358dd2beee 100755
@@ -15,6 +15,12 @@
 # test buildistory git repo works?
 #
 
+if [ ! -x $HOME/yocto-autobuilder-helper/scripts/checkvnc ]; then
+    echo "$HOME/yocto-autobuilder-helper should be created."
+    exit 1
+fi
+$HOME/yocto-autobuilder-helper/scripts/checkvnc
+
 . ./oe-init-build-env > /dev/null
 if [ "$?" != "0" ]; then
     exit 1
@@ -53,12 +59,12 @@ if [ ! -e bzImage-qemux86-64.bin ]; then
 fi
 popd
 bitbake qemu-helper-native
-runqemu qemux86-64
+DISPLAY=:1 runqemu serialstdio qemux86-64
 if [ "$?" != "0" ]; then
     echo "Unable to use runqemu"
     exit 1
 fi
-runqemu qemux86-64 kvm
+DISPLAY=:1 runqemu serialstdio qemux86-64 kvm
 if [ "$?" != "0" ]; then
     echo "Unable to use runqemu with kvm"
     exit 1
Signature · 1 line
2.17.2