runqemu: add QB_GRAPHICS
PATCH 1/3 runqemu: add QB_GRAPHICS
Add a new runqemu field for VGA devices. Currently, these are being set in QB_OPT_APPEND, which can make them difficult to override if importing the config file into another one.
--- meta/classes/qemuboot.bbclass | 4 ++++ meta/conf/machine/include/qemuboot-mips.inc | 2 +- meta/conf/machine/qemuarm.conf | 4 ++-- meta/conf/machine/qemuarm64.conf | 4 ++-- scripts/runqemu | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-)
meta/classes/qemuboot.bbclass +4 -0
@@ -72,6 +72,9 @@ # Can be used to automatically determine the image from the other variables # but define things link 'bootindex' when booting from EFI or 'readonly' when using squashfs # without the need to specify a dedicated qemu configuration +# +# QB_GRAPHICS: QEMU video card type (e.g. "-vga std") +# # Usage: # IMAGE_CLASSES += "qemuboot" # See "runqemu help" for more info
@@ -86,6 +89,7 @@ QB_NETWORK_DEVICE ?= "-device virtio-net-pci,netdev=net0,mac=@MAC@" QB_CMDLINE_IP_SLIRP ?= "ip=dhcp" QB_CMDLINE_IP_TAP ?= "ip=192.168.7.@CLIENT@::192.168.7.@GATEWAY@:255.255.255.0" QB_ROOTFS_EXTRA_OPT ?= "" +QB_GRAPHICS ?= "" # This should be kept align with ROOT_VM QB_DRIVE_TYPE ?= "/dev/sd"
meta/conf/machine/include/qemuboot-mips.inc +1 -1
@@ -5,4 +5,4 @@ QB_KERNEL_CMDLINE_APPEND = "console=ttyS0 console=tty" QB_OPT_APPEND = "-usb -device usb-tablet" # For graphics to work we need to define the VGA device as well as the necessary USB devices -QB_OPT_APPEND += "-vga std" +QB_GRAPHICS = "-vga std"
meta/conf/machine/qemuarm.conf +2 -2
@@ -19,8 +19,8 @@ QB_CPU = "-cpu cortex-a15" # Standard Serial console QB_KERNEL_CMDLINE_APPEND = "console=ttyAMA0 vmalloc=256" # For graphics to work we need to define the VGA device as well as the necessary USB devices -QB_OPT_APPEND = "-device VGA,edid=on" -QB_OPT_APPEND += "-device qemu-xhci -device usb-tablet -device usb-kbd" +QB_GRAPHICS = "-device VGA,edid=on" +QB_OPT_APPEND = "-device qemu-xhci -device usb-tablet -device usb-kbd" # Virtio Networking support QB_TAP_OPT = "-netdev tap,id=net0,ifname=@TAP@,script=no,downscript=no" QB_NETWORK_DEVICE = "-device virtio-net-device,netdev=net0,mac=@MAC@"
meta/conf/machine/qemuarm64.conf +2 -2
@@ -20,8 +20,8 @@ QB_CPU_KVM = "-cpu host -machine gic-version=3" # Standard Serial console QB_KERNEL_CMDLINE_APPEND = "console=ttyAMA0" # For graphics to work we need to define the VGA device as well as the necessary USB devices -QB_OPT_APPEND = "-device VGA,edid=on" -QB_OPT_APPEND += "-device qemu-xhci -device usb-tablet -device usb-kbd" +QB_GRAPHICS = "-device VGA,edid=on" +QB_OPT_APPEND = "-device qemu-xhci -device usb-tablet -device usb-kbd" # Virtio Networking support QB_TAP_OPT = "-netdev tap,id=net0,ifname=@TAP@,script=no,downscript=no" QB_NETWORK_DEVICE = "-device virtio-net-device,netdev=net0,mac=@MAC@"
scripts/runqemu +1 -1
@@ -1341,7 +1341,7 @@ 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_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')) + self.qemu_opt = "%s %s %s %s %s %s" % (qemu_bin, self.get('NETWORK_CMD'), self.get('QB_RNG'), self.get('QB_GRAPHICS'), self.get('ROOTFS_OPTIONS'), self.get('QB_OPT_APPEND')) for ovmf in self.ovmf_bios: format = ovmf.rsplit('.', 1)[-1]
Signature · 1 line
2.20.1
PATCH 2/3 runqemu: correct forcing of ttyS0
Some platforms do not use ttyS* for their serial consoles (e.g., qemuarm and qemuarm64). The hardcoding of this can cause issues. Modify runqemu to use the serial consoles defined in SERIAL_CONSOLES instead of hardcoding.
--- meta/classes/qemuboot.bbclass | 2 +- meta/conf/machine/qemuarm.conf | 2 +- meta/conf/machine/qemuarm64.conf | 2 - meta/conf/machine/qemuarmv5.conf | 2 +- meta/lib/oeqa/utils/qemurunner.py | 2 +- scripts/runqemu | 61 ++++++++++++++----------------- 6 files changed, 31 insertions(+), 40 deletions(-)
meta/classes/qemuboot.bbclass +1 -1
@@ -103,7 +103,7 @@ def qemuboot_vars(d): build_vars = ['MACHINE', 'TUNE_ARCH', 'DEPLOY_DIR_IMAGE', 'KERNEL_IMAGETYPE', 'IMAGE_NAME', 'IMAGE_LINK_NAME', 'STAGING_DIR_NATIVE', 'STAGING_BINDIR_NATIVE', - 'STAGING_DIR_HOST'] + 'STAGING_DIR_HOST', 'SERIAL_CONSOLES'] return build_vars + [k for k in d.keys() if k.startswith('QB_')] do_write_qemuboot_conf[vardeps] += "${@' '.join(qemuboot_vars(d))}"
meta/conf/machine/qemuarm.conf +1 -1
@@ -17,7 +17,7 @@ QB_SYSTEM_NAME = "qemu-system-arm" QB_MACHINE = "-machine virt,highmem=off" QB_CPU = "-cpu cortex-a15" # Standard Serial console -QB_KERNEL_CMDLINE_APPEND = "console=ttyAMA0 vmalloc=256" +QB_KERNEL_CMDLINE_APPEND = "vmalloc=256" # For graphics to work we need to define the VGA device as well as the necessary USB devices QB_GRAPHICS = "-device VGA,edid=on" QB_OPT_APPEND = "-device qemu-xhci -device usb-tablet -device usb-kbd"
meta/conf/machine/qemuarm64.conf +0 -2
@@ -17,8 +17,6 @@ QB_SYSTEM_NAME = "qemu-system-aarch64" QB_MACHINE = "-machine virt" QB_CPU = "-cpu cortex-a57" QB_CPU_KVM = "-cpu host -machine gic-version=3" -# Standard Serial console -QB_KERNEL_CMDLINE_APPEND = "console=ttyAMA0" # For graphics to work we need to define the VGA device as well as the necessary USB devices QB_GRAPHICS = "-device VGA,edid=on" QB_OPT_APPEND = "-device qemu-xhci -device usb-tablet -device usb-kbd"
meta/conf/machine/qemuarmv5.conf +1 -1
@@ -12,7 +12,7 @@ SERIAL_CONSOLES ?= "115200;ttyAMA0 115200;ttyAMA1" # For runqemu QB_SYSTEM_NAME = "qemu-system-arm" QB_MACHINE = "-machine versatilepb" -QB_KERNEL_CMDLINE_APPEND = "console=ttyAMA0,115200 console=tty vmalloc=256" +QB_KERNEL_CMDLINE_APPEND = "vmalloc=256" QB_OPT_APPEND = "-usb -device usb-tablet" PREFERRED_VERSION_linux-yocto ??= "5.10%" QB_DTB = "${@oe.utils.version_less_or_equal('PREFERRED_VERSION_linux-yocto', '4.7', '', 'zImage-versatile-pb.dtb', d)}"
meta/lib/oeqa/utils/qemurunner.py +1 -1
@@ -176,7 +176,7 @@ class QemuRunner: self.logger.error("Failed to create listening socket: %s" % msg[1]) return False - bootparams = 'console=tty1 console=ttyS0,115200n8 printk.time=1' + bootparams = ' printk.time=1' if extra_bootparams: bootparams = bootparams + ' ' + extra_bootparams
scripts/runqemu +27 -34
93 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 3/3 runqemu: modify novga to conform to documentation
In reply to Jon MasonPassing 'novga' only adds '-vga none' to the qemu commandline and does not prevent other vga devices from being added, contrary to the documentation/help. Clean-up the vga logic and add the ability to prevent other vga devices from being added.
--- scripts/runqemu | 86 +++++++++++++++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 31 deletions(-)
scripts/runqemu +55 -31
@@ -174,6 +174,13 @@ class BaseConfig(object): self.nfs_running = False self.serialconsole = False self.serialstdio = False + self.nographic = False + self.sdl = False + self.gtk = False + self.gl = False + self.gl_es = False + self.egl_headless = False + self.novga = False self.cleantap = False self.saved_stty = '' self.audio_enabled = False
@@ -460,38 +467,19 @@ class BaseConfig(object): if arg in self.fstypes + self.vmtypes + self.wictypes: self.check_arg_fstype(arg) elif arg == 'nographic': - if ('sdl' in sys.argv): - raise RunQemuError('Option nographic makes no sense alongside the sdl option.' % (arg)) - if ('gtk' in sys.argv): - raise RunQemuError('Option nographic makes no sense alongside the gtk option.' % (arg)) - self.qemu_opt_script += ' -nographic' + self.nographic = True elif arg == 'sdl': - if 'gl' in sys.argv[1:]: - self.set_dri_path() - self.qemu_opt_script += ' -vga virtio -display sdl,gl=on,show-cursor=on' - elif 'gl-es' in sys.argv[1:]: - self.set_dri_path() - self.qemu_opt_script += ' -vga virtio -display sdl,gl=es,show-cursor=on' - else: - self.qemu_opt_script += ' -display sdl,show-cursor=on' + self.sdl = True elif arg == 'gtk': - if 'gl' in sys.argv[1:]: - self.set_dri_path() - self.qemu_opt_script += ' -vga virtio -display gtk,gl=on,show-cursor=on' - elif 'gl-es' in sys.argv[1:]: - self.set_dri_path() - self.qemu_opt_script += ' -vga virtio -display gtk,gl=es,show-cursor=on' - else: - self.qemu_opt_script += ' -display gtk,show-cursor=on' - elif arg == 'gl' or arg == 'gl-es': - # These args are handled inside sdl or gtk blocks above - if ('gtk' not in sys.argv) and ('sdl' not in sys.argv): - raise RunQemuError('Option %s also needs gtk or sdl option.' % (arg)) + self.gtk = True + elif arg == 'gl': + self.gl = True + elif 'gl-es' in sys.argv[1:]: + self.gl_es = True elif arg == 'egl-headless': - self.set_dri_path() - self.qemu_opt_script += ' -vga virtio -display egl-headless,show-cursor=on' + self.egl_headless = True elif arg == 'novga': - self.qemu_opt_script += ' -vga none' + self.novga = True elif arg == 'serial': self.serialconsole = True elif arg == "serialstdio":
@@ -1319,13 +1307,48 @@ class BaseConfig(object): raise RunQemuError("Failed to boot, QB_SYSTEM_NAME is NULL!") self.qemu_system = qemu_system + def setup_vga(self): + if self.nographic == True: + if self.sdl == True: + raise RunQemuError('Option nographic makes no sense alongside the sdl option.') + if self.gtk == True: + raise RunQemuError('Option nographic makes no sense alongside the gtk option.') + self.qemu_opt += ' -nographic' + return + + if self.novga == True: + self.qemu_opt += ' -vga none' + return + + 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: + self.set_dri_path() + self.qemu_opt += ' -vga virtio -display ' + if self.egl_headless == True: + self.qemu_opt += 'egl-headless,' + else: + if self.sdl == True: + self.qemu_opt += 'sdl,' + elif self.gtk == True: + self.qemu_opt += 'gtk,' + + if self.gl == True: + self.qemu_opt += 'gl=on,' + elif self.gl_es == True: + self.qemu_opt += 'gl=es,' + self.qemu_opt += 'show-cursor=on' + + self.qemu_opt += ' %s' %self.get('QB_GRAPHICS') + def setup_serial(self): # Setup correct kernel command line for serial - if self.serialstdio == True or self.serialconsole == True or re.search("-nographic", self.qemu_opt) or self.tcpserial_portnum: + if self.serialstdio == True or self.serialconsole == True or self.nographic == True or self.tcpserial_portnum: for entry in self.get('SERIAL_CONSOLES').split(' '): self.kernel_cmdline_script += ' console=%s' %entry.split(';')[1] - if self.serialstdio == True or re.search("-nographic", self.qemu_opt): + if self.serialstdio == True or self.nographic == True: self.qemu_opt += " -serial mon:stdio" else: self.qemu_opt += " -serial mon:vc"
@@ -1364,7 +1387,7 @@ 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_opt = "%s %s %s %s %s %s" % (qemu_bin, self.get('NETWORK_CMD'), self.get('QB_RNG'), self.get('QB_GRAPHICS'), self.get('ROOTFS_OPTIONS'), self.get('QB_OPT_APPEND')) + 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')) for ovmf in self.ovmf_bios: format = ovmf.rsplit('.', 1)[-1]
@@ -1389,6 +1412,7 @@ class BaseConfig(object): self.qemu_opt += " -snapshot" self.setup_serial() + self.setup_vga() def start_qemu(self): import shlex
Signature · 1 line
2.20.1
Re: [OE-core] [PATCH 3/3] runqemu: modify novga to conform to documentation
Quoted 6 lines · Jon Mason
Passing 'novga' only adds '-vga none' to the qemu commandline and does not prevent other vga devices from being added, contrary to the documentation/help. Clean-up the vga logic and add the ability to prevent other vga devices from being added.
I traced a weston image failure in -ctestimage to this commit. after this commit -vga none is passed when
runqemu nographic
is used. This means qemu won't be exporting any graphics devices and as a result weston wont start since it needs some graphics emulation. this use to work in past,
Quoted 146 lines
Signed-off-by Jon Mason <[email protected]>Change-Id I7ff8f9f3e419ce8bae3f3847d75f9275ca30406a--- scripts/runqemu | 86 +++++++++++++++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 31 deletions(-)scripts/runqemu +55
-32@@ -174,6 +174,13 @@ class BaseConfig(object): self.nfs_running = False self.serialconsole = False self.serialstdio = False + self.nographic = False + self.sdl = False + self.gtk = False + self.gl = False + self.gl_es = False + self.egl_headless = False + self.novga = False self.cleantap = False self.saved_stty = '' self.audio_enabled = False@@ -460,38 +467,19 @@ class BaseConfig(object): if arg in self.fstypes + self.vmtypes + self.wictypes: self.check_arg_fstype(arg) elif arg == 'nographic': - if ('sdl' in sys.argv): - raise RunQemuError('Option nographic makes no sense alongside the sdl option.' % (arg)) - if ('gtk' in sys.argv): - raise RunQemuError('Option nographic makes no sense alongside the gtk option.' % (arg)) - self.qemu_opt_script += ' -nographic' + self.nographic = True elif arg == 'sdl': - if 'gl' in sys.argv[1:]: - self.set_dri_path() - self.qemu_opt_script += ' -vga virtio -display sdl,gl=on,show-cursor=on' - elif 'gl-es' in sys.argv[1:]: - self.set_dri_path() - self.qemu_opt_script += ' -vga virtio -display sdl,gl=es,show-cursor=on' - else: - self.qemu_opt_script += ' -display sdl,show-cursor=on' + self.sdl = True elif arg == 'gtk': - if 'gl' in sys.argv[1:]: - self.set_dri_path() - self.qemu_opt_script += ' -vga virtio -display gtk,gl=on,show-cursor=on' - elif 'gl-es' in sys.argv[1:]: - self.set_dri_path() - self.qemu_opt_script += ' -vga virtio -display gtk,gl=es,show-cursor=on' - else: - self.qemu_opt_script += ' -display gtk,show-cursor=on' - elif arg == 'gl' or arg == 'gl-es': - # These args are handled inside sdl or gtk blocks above - if ('gtk' not in sys.argv) and ('sdl' not in sys.argv): - raise RunQemuError('Option %s also needs gtk or sdl option.' % (arg)) + self.gtk = True + elif arg == 'gl': + self.gl = True + elif 'gl-es' in sys.argv[1:]: + self.gl_es = True elif arg == 'egl-headless': - self.set_dri_path() - self.qemu_opt_script += ' -vga virtio -display egl-headless,show-cursor=on' + self.egl_headless = True elif arg == 'novga': - self.qemu_opt_script += ' -vga none' + self.novga = True elif arg == 'serial': self.serialconsole = True elif arg == "serialstdio":@@ -1319,13 +1307,48 @@ class BaseConfig(object): raise RunQemuError("Failed to boot, QB_SYSTEM_NAME is NULL!") self.qemu_system = qemu_system + def setup_vga(self): + if self.nographic == True: + if self.sdl == True: + raise RunQemuError('Option nographic makes no sense alongside the sdl option.') + if self.gtk == True: + raise RunQemuError('Option nographic makes no sense alongside the gtk option.') + self.qemu_opt += ' -nographic' + return + + if self.novga == True: + self.qemu_opt += ' -vga none' + return + + 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: + self.set_dri_path() + self.qemu_opt += ' -vga virtio -display ' + if self.egl_headless == True: + self.qemu_opt += 'egl-headless,' + else: + if self.sdl == True: + self.qemu_opt += 'sdl,' + elif self.gtk == True: + self.qemu_opt += 'gtk,' + + if self.gl == True: + self.qemu_opt += 'gl=on,' + elif self.gl_es == True: + self.qemu_opt += 'gl=es,' + self.qemu_opt += 'show-cursor=on' + + self.qemu_opt += ' %s' %self.get('QB_GRAPHICS') + def setup_serial(self): # Setup correct kernel command line for serial - if self.serialstdio == True or self.serialconsole == True or re.search("-nographic", self.qemu_opt) or self.tcpserial_portnum: + if self.serialstdio == True or self.serialconsole == True or self.nographic == True or self.tcpserial_portnum: for entry in self.get('SERIAL_CONSOLES').split(' '): self.kernel_cmdline_script += ' console=%s' %entry.split(';')[1] - if self.serialstdio == True or re.search("-nographic", self.qemu_opt): + if self.serialstdio == True or self.nographic == True: self.qemu_opt += " -serial mon:stdio" else: self.qemu_opt += " -serial mon:vc"@@ -1364,7 +1387,7 @@ 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_opt = "%s %s %s %s %s %s" % (qemu_bin, self.get('NETWORK_CMD'), self.get('QB_RNG'), self.get('QB_GRAPHICS'), self.get('ROOTFS_OPTIONS'), self.get('QB_OPT_APPEND')) + 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')) for ovmf in self.ovmf_bios: format = ovmf.rsplit('.', 1)[-1]@@ -1389,6 +1412,7 @@ class BaseConfig(object): self.qemu_opt += " -snapshot" self.setup_serial() + self.setup_vga() def start_qemu(self): import shlex --2.20.1