All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] runqemu: Allow auto detection of the correct graphics options
@ 2022-04-14  8:20 Richard Purdie
  0 siblings, 0 replies; only message in thread
From: Richard Purdie @ 2022-04-14  8:20 UTC (permalink / raw)
  To: openembedded-core

Running "runqemu qemux86 kvm" when qemu is configured for sdl and/or gtk
display output currently leads to a poor user experience with no cursor
and corrupted fonts in the gtk case. This is due to no options being
passed to qemu which leads to the loss of the font envirornment variable
and the show-cursor option.

If the user hasn't specified a display type, grep the output of
"qemu-system-xxx --help" for the display types and pick the "best"
which ensures our config is passed in. That resolves the gtk font issue
and the cursor issue with both sdl and gtk.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
v2: Fix for non x86 which don't have the vga option, skip that there
    and avoid string whitespace concat issues

 scripts/runqemu | 33 ++++++++++++++++++++++++++-------
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/scripts/runqemu b/scripts/runqemu
index 2f77a7bd0f2..36af764b1b5 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -1363,13 +1363,27 @@ class BaseConfig(object):
         if (self.gl_es == True or self.gl == True) and (self.sdl == False and self.gtk == False):
             raise RunQemuError('Option gl/gl-es needs gtk or sdl option.')
 
-        if self.sdl == True or self.gtk == True or self.egl_headless == True:
-            if self.gl or self.gl_es or self.egl_headless:
-                self.qemu_opt += ' -device virtio-vga-gl '
+        # If we have no display option, we autodetect based upon what qemu supports. We
+        # need our font setup and show-cusor below so we need to see what qemu --help says
+        # is supported so we can pass our correct config in.
+        if not self.nographic and not self.sdl and not self.gtk and not self.egl_headless == True:
+            output = subprocess.check_output([self.qemu_bin, "--help"], universal_newlines=True)
+            if "-display gtk" in output:
+                self.gtk = True
+            elif "-display sdl" in output:
+                self.sdl = True
             else:
-                self.qemu_opt += ' -device virtio-vga '
+                self.qemu_opt += '-display none'
 
-            self.qemu_opt += '-display '
+        if self.sdl == True or self.gtk == True or self.egl_headless == True:
+
+            if self.qemu_system.endswith(('i386', 'x86_64')):
+                if self.gl or self.gl_es or self.egl_headless:
+                    self.qemu_opt += ' -device virtio-vga-gl '
+                else:
+                    self.qemu_opt += ' -device virtio-vga '
+
+            self.qemu_opt += ' -display '
             if self.egl_headless == True:
                 self.set_dri_path()
                 self.qemu_opt += 'egl-headless,'
@@ -1415,7 +1429,7 @@ class BaseConfig(object):
         if serial_num < 2:
             self.qemu_opt += " -serial null"
 
-    def setup_final(self):
+    def find_qemu(self):
         qemu_bin = os.path.join(self.bindir_native, self.qemu_system)
 
         # It is possible to have qemu-native in ASSUME_PROVIDED, and it won't
@@ -1434,8 +1448,13 @@ class BaseConfig(object):
 
         if not os.access(qemu_bin, os.X_OK):
             raise OEPathError("No QEMU binary '%s' could be found" % qemu_bin)
+        self.qemu_bin = qemu_bin
+
+    def setup_final(self):
+
+        self.find_qemu()
 
-        self.qemu_opt = "%s %s %s %s %s" % (qemu_bin, self.get('NETWORK_CMD'), self.get('QB_RNG'), self.get('ROOTFS_OPTIONS'), self.get('QB_OPT_APPEND').replace('@DEPLOY_DIR_IMAGE@', self.get('DEPLOY_DIR_IMAGE')))
+        self.qemu_opt = "%s %s %s %s %s" % (self.qemu_bin, self.get('NETWORK_CMD'), self.get('QB_RNG'), self.get('ROOTFS_OPTIONS'), self.get('QB_OPT_APPEND').replace('@DEPLOY_DIR_IMAGE@', self.get('DEPLOY_DIR_IMAGE')))
 
         for ovmf in self.ovmf_bios:
             format = ovmf.rsplit('.', 1)[-1]
-- 
2.32.0



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-14 16:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-14  8:20 [PATCH v2] runqemu: Allow auto detection of the correct graphics options Richard Purdie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.