New function to kernel_disk_workload to allow new disk device location (#151)
Added a parameter (_disk_device) to kernel_disk_workload which allows users to change the disk device location. get_disk_device() now chooses between the parameter and, if no parameter was passed, it calls a new function _get_default_disk_device() which is implemented by each board and has a default disk device according to each board, eg /dev/hda in the x86_board. The previous way of setting a disk device still exists as a default, however, with the new function users can now override this default
This commit is contained in:
@@ -386,6 +386,7 @@ class ArmBoard(ArmSystem, AbstractBoard, KernelDiskWorkload):
|
||||
"lpj=19988480",
|
||||
"norandmaps",
|
||||
"root={root_value}",
|
||||
"disk_device={disk_device}",
|
||||
"rw",
|
||||
f"mem={self.get_memory().get_size()}",
|
||||
]
|
||||
|
||||
@@ -534,14 +534,19 @@ class LupvBoard(AbstractSystemBoard, KernelDiskWorkload):
|
||||
fdt.writeDtsFile(os.path.join(outdir, "device.dts"))
|
||||
fdt.writeDtbFile(os.path.join(outdir, "device.dtb"))
|
||||
|
||||
@overrides(KernelDiskWorkload)
|
||||
def get_default_kernel_args(self) -> List[str]:
|
||||
return ["console=ttyLIO0", "root={root_value}", "rw"]
|
||||
|
||||
@overrides(KernelDiskWorkload)
|
||||
def get_disk_device(self) -> str:
|
||||
return "/dev/lda"
|
||||
|
||||
@overrides(KernelDiskWorkload)
|
||||
def get_default_kernel_args(self) -> List[str]:
|
||||
return [
|
||||
"console=ttyLIO0",
|
||||
"root={root_value}",
|
||||
"disk_device={disk_device}",
|
||||
"rw",
|
||||
]
|
||||
|
||||
@overrides(KernelDiskWorkload)
|
||||
def _add_disk_to_board(self, disk_image: AbstractResource) -> None:
|
||||
# Note: This must be called after set_workload because it looks for an
|
||||
|
||||
@@ -87,7 +87,7 @@ class KernelDiskWorkload:
|
||||
@abstractmethod
|
||||
def get_disk_device(self) -> str:
|
||||
"""
|
||||
Get the disk device, e.g., "/dev/sda", where the disk image is placed.
|
||||
Set a default disk device, in case user does not specify a disk device.
|
||||
|
||||
:returns: The disk device.
|
||||
"""
|
||||
@@ -139,6 +139,7 @@ class KernelDiskWorkload:
|
||||
kernel: KernelResource,
|
||||
disk_image: DiskImageResource,
|
||||
bootloader: Optional[BootloaderResource] = None,
|
||||
disk_device: Optional[str] = None,
|
||||
readfile: Optional[str] = None,
|
||||
readfile_contents: Optional[str] = None,
|
||||
kernel_args: Optional[List[str]] = None,
|
||||
@@ -171,6 +172,9 @@ class KernelDiskWorkload:
|
||||
# Abstract board. This function will not work otherwise.
|
||||
assert isinstance(self, AbstractBoard)
|
||||
|
||||
# Set the disk device
|
||||
self._disk_device = disk_device
|
||||
|
||||
# If we are setting a workload of this type, we need to run as a
|
||||
# full-system simulation.
|
||||
self._set_fullsystem(True)
|
||||
@@ -182,7 +186,12 @@ class KernelDiskWorkload:
|
||||
self.workload.command_line = (
|
||||
" ".join(kernel_args or self.get_default_kernel_args())
|
||||
).format(
|
||||
root_value=self.get_default_kernel_root_val(disk_image=disk_image)
|
||||
root_value=self.get_default_kernel_root_val(disk_image=disk_image),
|
||||
disk_device=(
|
||||
self._disk_device
|
||||
if self._disk_device
|
||||
else self.get_disk_device()
|
||||
),
|
||||
)
|
||||
|
||||
# Setting the bootloader information for ARM board. The current
|
||||
|
||||
@@ -494,4 +494,9 @@ class RiscvBoard(AbstractSystemBoard, KernelDiskWorkload):
|
||||
|
||||
@overrides(KernelDiskWorkload)
|
||||
def get_default_kernel_args(self) -> List[str]:
|
||||
return ["console=ttyS0", "root={root_value}", "rw"]
|
||||
return [
|
||||
"console=ttyS0",
|
||||
"root={root_value}",
|
||||
"disk_device={disk_device}",
|
||||
"rw",
|
||||
]
|
||||
|
||||
@@ -318,4 +318,5 @@ class X86Board(AbstractSystemBoard, KernelDiskWorkload):
|
||||
"console=ttyS0",
|
||||
"lpj=7999923",
|
||||
"root={root_value}",
|
||||
"disk_device={disk_device}",
|
||||
]
|
||||
|
||||
@@ -566,7 +566,12 @@ class RISCVMatchedBoard(
|
||||
|
||||
@overrides(KernelDiskWorkload)
|
||||
def get_default_kernel_args(self) -> List[str]:
|
||||
return ["console=ttyS0", "root={root_value}", "rw"]
|
||||
return [
|
||||
"console=ttyS0",
|
||||
"root={root_value}",
|
||||
"disk_device={disk_device}",
|
||||
"rw",
|
||||
]
|
||||
|
||||
@overrides(KernelDiskWorkload)
|
||||
def set_kernel_disk_workload(
|
||||
|
||||
Reference in New Issue
Block a user