Bobby Bruce has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/53844 )

Change subject: stdlib: Add a 'disk_root_partition' param to CustomResource
......................................................................

stdlib: Add a 'disk_root_partition' param to CustomResource

Prior to this change the only way to set a CustomResource disk image was
to do so via specifying metadata. This patch makes it a bit easier and
more intuative.

Change-Id: I8189ad065124d028aea9fab1c7f07108aa4ce6d5
---
M configs/example/gem5_library/x86-spec-cpu2006-benchmarks.py
M src/python/gem5/resources/resource.py
M configs/example/gem5_library/x86-spec-cpu2017-benchmarks.py
3 files changed, 35 insertions(+), 19 deletions(-)



diff --git a/configs/example/gem5_library/x86-spec-cpu2006-benchmarks.py b/configs/example/gem5_library/x86-spec-cpu2006-benchmarks.py
index 0bd5320..0deb48f 100644
--- a/configs/example/gem5_library/x86-spec-cpu2006-benchmarks.py
+++ b/configs/example/gem5_library/x86-spec-cpu2006-benchmarks.py
@@ -227,15 +227,6 @@

 command = "{} {} {}".format(args.benchmark, args.size, output_dir)

-# For enabling CustomResource, we pass an additional parameter to mount the
-# correct partition.
-
-metadata = {
-    "additional_metadata" : {
-        "root_partition" : args.partition,
-    },
-}
-
 board.set_kernel_disk_workload(
     # The x86 linux kernel will be automatically downloaded to the
     # `~/.cache/gem5` directory if not already present.
@@ -247,7 +238,7 @@
     # The location of the x86 SPEC CPU 2017 image
     disk_image=CustomResource(
         args.image,
-        metadata=metadata
+        disk_root_partition=args.partition,
     ),
     readfile_contents=command,
 )
diff --git a/configs/example/gem5_library/x86-spec-cpu2017-benchmarks.py b/configs/example/gem5_library/x86-spec-cpu2017-benchmarks.py
index b4bb9ac..012867d 100644
--- a/configs/example/gem5_library/x86-spec-cpu2017-benchmarks.py
+++ b/configs/example/gem5_library/x86-spec-cpu2017-benchmarks.py
@@ -236,12 +236,6 @@
 # For enabling CustomResource, we pass an additional parameter to mount the
 # correct partition.

-metadata = {
-    "additional_metadata" : {
-        "root_partition" : args.partition,
-    },
-}
-
 board.set_kernel_disk_workload(
     # The x86 linux kernel will be automatically downloaded to the
     # `~/.cache/gem5` directory if not already present.
@@ -252,8 +246,8 @@
     # The location of the x86 SPEC CPU 2017 image
     disk_image=CustomResource(
         args.image,
-        metadata=metadata
-        ),
+        disk_root_partition=args.partition,
+    ),
     readfile_contents=command,
 )

diff --git a/src/python/gem5/resources/resource.py b/src/python/gem5/resources/resource.py
index 212ec5a..5767f2c 100644
--- a/src/python/gem5/resources/resource.py
+++ b/src/python/gem5/resources/resource.py
@@ -73,12 +73,30 @@
     repository.
     """

-    def __init__(self, local_path: str, metadata: Dict = {}):
+    def __init__(
+        self,
+        local_path: str,
+        metadata: Dict = {},
+        disk_root_partition: Optional[str] = None,
+    ):
         """
         :param local_path: The path of the resource on the host system.
         :param metadata: Add metadata for the custom resource.
+ :param disk_root_partition: If the resources is a disk image, the root
+        disk partition to use.
         """

+ # Behind the scenes, we set the the root partition via the metadata. + # For a traditional, non-custom, resource it is the metadata that is + # used to specify the disk image partition root. Therefore, when the + # root disk partition specified during the construction, we apply it as
+        # metadata.
+        if disk_root_partition:
+            disk_root_partition_dict = {
+ "additional_metadata": {"root_partition": disk_root_partition}
+            }
+            metadata.update(disk_root_partition_dict)
+
         super().__init__(local_path=local_path, metadata=metadata)



--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/53844
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I8189ad065124d028aea9fab1c7f07108aa4ce6d5
Gerrit-Change-Number: 53844
Gerrit-PatchSet: 1
Gerrit-Owner: Bobby Bruce <bbr...@ucdavis.edu>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to