From af4fd2f2c6027db97243313a7cf5b836ea7d6596 Mon Sep 17 00:00:00 2001 From: "Bobby R. Bruce" Date: Wed, 24 Aug 2022 14:07:45 -0700 Subject: [PATCH] tests,configs: Update x86 boot tests/examples with Workload As of this commit: https://gem5-review.googlesource.com/c/public/gem5-resources/+/62658 there is an x86-ubuntu-18.04-boot workload. Where appropriate tests and example scripts have been updated to use this workload. Change-Id: I7c9dc8e0e53b1d3f4c365f0382b5f5d4224436f7 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/62663 Tested-by: kokoro Maintainer: Bobby Bruce Reviewed-by: Jason Lowe-Power --- .../gem5_library/x86-ubuntu-run-with-kvm.py | 14 ++++--------- .../example/gem5_library/x86-ubuntu-run.py | 13 +++++------- tests/gem5/configs/x86_boot_exit_run.py | 21 +++++++++---------- 3 files changed, 19 insertions(+), 29 deletions(-) diff --git a/configs/example/gem5_library/x86-ubuntu-run-with-kvm.py b/configs/example/gem5_library/x86-ubuntu-run-with-kvm.py index 3387e75eb1..f55ec60f21 100644 --- a/configs/example/gem5_library/x86-ubuntu-run-with-kvm.py +++ b/configs/example/gem5_library/x86-ubuntu-run-with-kvm.py @@ -49,9 +49,9 @@ from gem5.components.processors.simple_switchable_processor import ( from gem5.components.processors.cpu_types import CPUTypes from gem5.isas import ISA from gem5.coherence_protocol import CoherenceProtocol -from gem5.resources.resource import Resource from gem5.simulate.simulator import Simulator from gem5.simulate.exit_event import ExitEvent +from gem5.resources.workload import Workload # This runs a check to ensure the gem5 binary is compiled to X86 and to the # MESI Two Level coherence protocol. @@ -117,15 +117,9 @@ command = ( + "m5 exit;" ) -board.set_kernel_disk_workload( - # The x86 linux kernel will be automatically downloaded to the if not - # already present. - kernel=Resource("x86-linux-kernel-5.4.49"), - # The x86 ubuntu image will be automatically downloaded to the if not - # already present. - disk_image=Resource("x86-ubuntu-18.04-img"), - readfile_contents=command, -) +workload = Workload("x86-ubuntu-18.04-boot") +workload.set_parameter("readfile_contents", command) +board.set_workload(workload) simulator = Simulator( board=board, diff --git a/configs/example/gem5_library/x86-ubuntu-run.py b/configs/example/gem5_library/x86-ubuntu-run.py index 2aee8c73df..50b52e6e3c 100644 --- a/configs/example/gem5_library/x86-ubuntu-run.py +++ b/configs/example/gem5_library/x86-ubuntu-run.py @@ -45,7 +45,7 @@ scons build/X86/gem5.opt """ from gem5.prebuilt.demo.x86_demo_board import X86DemoBoard -from gem5.resources.resource import Resource +from gem5.resources.workload import Workload from gem5.simulate.simulator import Simulator @@ -53,13 +53,10 @@ from gem5.simulate.simulator import Simulator # simulation. board = X86DemoBoard() -# We then set the workload. Here we use the 5.4.49 Linux kernel with an X86 -# Ubuntu OS. If these cannot be found locally they will be automatically -# downloaded. -board.set_kernel_disk_workload( - kernel=Resource("x86-linux-kernel-5.4.49"), - disk_image=Resource("x86-ubuntu-18.04-img"), -) +# We then set the workload. Here we use the "x86-ubuntu-18.04-boot" workload. +# This boots Ubuntu 18.04 with Linux 5.4.49. If the required resources are not +# found locally, they will be downloaded. +board.set_workload(Workload("x86-ubuntu-18.04-boot")) simulator = Simulator(board=board) simulator.run() diff --git a/tests/gem5/configs/x86_boot_exit_run.py b/tests/gem5/configs/x86_boot_exit_run.py index 523a650182..b1cbc647b2 100644 --- a/tests/gem5/configs/x86_boot_exit_run.py +++ b/tests/gem5/configs/x86_boot_exit_run.py @@ -33,7 +33,6 @@ import m5 from gem5.runtime import get_runtime_coherence_protocol from gem5.isas import ISA from gem5.utils.requires import requires -from gem5.resources.resource import Resource from gem5.coherence_protocol import CoherenceProtocol from gem5.components.boards.x86_board import X86Board from gem5.components.processors.cpu_types import ( @@ -42,10 +41,15 @@ from gem5.components.processors.cpu_types import ( ) from gem5.components.processors.simple_processor import SimpleProcessor from gem5.simulate.simulator import Simulator +from gem5.resources.workload import Workload import argparse import importlib +from python.gem5.components.boards.kernel_disk_workload import ( + KernelDiskWorkload, +) + parser = argparse.ArgumentParser( description="A script to run the gem5 boot test. This test boots the " "linux kernel." @@ -184,17 +188,12 @@ kernal_args = motherboard.get_default_kernel_args() if args.boot_type == "init": kernal_args.append("init=/root/exit.sh") -# Set the Full System workload. -motherboard.set_kernel_disk_workload( - kernel=Resource( - "x86-linux-kernel-5.4.49", resource_directory=args.resource_directory - ), - disk_image=Resource( - "x86-ubuntu-18.04-img", resource_directory=args.resource_directory - ), - kernel_args=kernal_args, +# Set the workload. +workload = Workload( + "x86-ubuntu-18.04-boot", resource_directory=args.resource_directory ) - +workload.set_parameter("kernel_args", kernal_args) +motherboard.set_workload(workload) # Begin running of the simulation. This will exit once the Linux system boot # is complete.