stdlib: Add CustomDiskImageResource
This CustomResource can be used to specify a custom, local disk image. It allows the user to specify the disk root partition parameter considerably easier than when setting a disk image through a CustomResource. Change-Id: I8189ad065124d028aea9fab1c7f07108aa4ce6d5 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/53844 Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Maintainer: Jason Lowe-Power <power.jg@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
committed by
Bobby Bruce
parent
69255abeb0
commit
5622560ce9
@@ -80,6 +80,36 @@ class CustomResource(AbstractResource):
|
||||
"""
|
||||
super().__init__(local_path=local_path, metadata=metadata)
|
||||
|
||||
class CustomDiskImageResource(CustomResource):
|
||||
"""
|
||||
A custom disk image gem5 resource. It can be used to specify a custom,
|
||||
local disk image.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
local_path: str,
|
||||
disk_root_partition: Optional[str] = None,
|
||||
metadata: Dict = {},
|
||||
):
|
||||
"""
|
||||
:param local_path: The path of the disk image on the host system.
|
||||
:param disk_root_partition: The root disk partition to use.
|
||||
:param metadata: Metadata for the resource.
|
||||
"""
|
||||
|
||||
# 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)
|
||||
|
||||
class Resource(AbstractResource):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user