Skip to content

Commit

Permalink
driver/qemudriver: Allow the BIOS filename to be changed
Browse files Browse the repository at this point in the history
The U-Boot strategy will need to provide the filename of the BIOS
directly when booting U-Boot on QEMU. Add a method to support this.

Signed-off-by: Simon Glass <[email protected]>
  • Loading branch information
sjg20 committed Jan 20, 2025
1 parent ab86f15 commit d386477
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions labgrid/driver/qemudriver.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""The QEMUDriver implements a driver to use a QEMU target"""
import atexit
import os
import select
import shlex
import shutil
Expand Down Expand Up @@ -133,6 +134,17 @@ def get_qemu_version(self, qemu_bin):

return (int(m.group('major')), int(m.group('minor')), int(m.group('micro')))

def set_bios(self, bios):
"""Set the filename of the bios
This can be used by strategies to set the bios filename, overriding the
value provided in the environment.
Args:
bios (str): New bios filename
"""
self.bios = bios

def get_qemu_base_args(self):
"""Returns the base command line used for Qemu without the options
related to QMP. These options can be used to start an interactive
Expand Down Expand Up @@ -193,8 +205,10 @@ def get_qemu_base_args(self):
f"if=pflash,format=raw,file={self.target.env.config.get_image_path(self.flash)},id=nor0") # pylint: disable=line-too-long
if self.bios is not None:
cmd.append("-bios")
cmd.append(
self.target.env.config.get_image_path(self.bios))
if os.path.exists(self.bios):
cmd.append(self.bios)
else:
cmd.append(self.target.env.config.get_image_path(self.bios))
if self.extra_args:
if "-append" in shlex.split(self.extra_args):
raise ExecutionError("-append in extra_args not allowed, use boot_args instead")
Expand Down

0 comments on commit d386477

Please sign in to comment.