]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
scripts/runqemu: Allow VNC use as a fallback when there is no DISPLAY set
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 10 Mar 2026 23:33:09 +0000 (23:33 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 12 Mar 2026 10:40:55 +0000 (10:40 +0000)
We would like to be able to fall back on QEMU's internal VNC server when
there is no DISPLAY available. Add code to do this, putting a socket for
VNC alongside the network interface tap lock files.

This won't work if tap networking isn't enabled but in most of our use
cases it will be and it avoids having to invent a new location for the
sockets. If there are needs outside this, that can be addressed in future.

Also move the other "publicvnc" code to be alongside the rest of the graphics
parameters for ease of reading the code. The publicvnc option doesn't
work for this use case as it can't handle multiple concurrent qemu istances.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/runqemu

index 5587d47865c2cf369c89a815f5c9c445a900e9ad..00ff77a0ed7a2db4a84d831cb32f466fbedff0f1 100755 (executable)
@@ -581,7 +581,6 @@ to your build configuration.
                 self.snapshot = True
             elif arg == 'publicvnc':
                 self.publicvnc = True
-                self.qemu_opt_script += ' -vnc :0'
             elif arg == 'guestagent':
                 self.guest_agent = True
             elif arg == "qmp":
@@ -1468,15 +1467,22 @@ to your build configuration.
         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.publicvnc:
+            self.qemu_opt += ' -vnc :0'
+
         # 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.publicvnc and not self.egl_headless == True:
             output = subprocess.check_output([self.qemu_bin, "--help"], universal_newlines=True, env=self.qemu_environ)
-            if "-display gtk" in output:
+            if "-display gtk" in output and "DISPLAY" in os.environ:
                 self.gtk = True
-            elif "-display sdl" in output:
+            elif "-display sdl" in output and "DISPLAY" in os.environ:
                 self.sdl = True
+            elif "-display vnc" in output and self.taplock_descriptor:
+                vncaddress = "unix:%s" % self.taplock.replace(".lock", ".vnc-socket")
+                logger.info("Using VNC server at %s for graphical output" % vncaddress)
+                self.qemu_opt += " -vnc %s" % vncaddress
             else:
                 self.qemu_opt += ' -display none'