From 6dc0021bb16a1bc000fd0eb5cd7e6ac161a2fd58 Mon Sep 17 00:00:00 2001 From: Nathan Pemberton Date: Fri, 21 Dec 2018 00:01:49 +0000 Subject: [PATCH] Added firesim install script. not fully tested yet. --- README.md | 10 +++++++++- centos-requirements.txt | 3 +++ python-requirements.txt | 2 ++ sw_manager.py | 7 +++++++ wlutil/__init__.py | 1 + wlutil/install.py | 44 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 centos-requirements.txt create mode 100644 python-requirements.txt create mode 100644 wlutil/install.py diff --git a/README.md b/README.md index 408bcc64..4e380db1 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ firesim-software This builds base images for several linux-based distros that work with qemu, spike, and firesim. -## How to use: +# How to use: All builds are controlled through json files. For example, br-disk.json will build/run the disk-based buildroot distro. @@ -28,6 +28,13 @@ Tl;Dr: images built with build.py will work on firesim, you just need to update the symlinks in workloads/deploy/ and then run them as normal. This will be intergrated more completely in future releases. +## Requirements +This project was written for python 3.4 + +python-requirements.txt and centos-requirements.txt are incomplete lists of +required packages for python3. If you find that you need a package not in those +lists, please file an issue. + # Gotcha's and potentially unintuitive behavior ## Incremental Builds It can be very frustrating to accidentally rebuild a complex workload from @@ -42,3 +49,4 @@ This means that you can still *lose changes to files that were specified in your overlay of file list* if you rebuild the workload. You should also strive to make your guest-init script as idempotent as possible (to avoid long delays or destroying state on rebuild). + diff --git a/centos-requirements.txt b/centos-requirements.txt new file mode 100644 index 00000000..eef8ada9 --- /dev/null +++ b/centos-requirements.txt @@ -0,0 +1,3 @@ +python34 +python34-devel + diff --git a/python-requirements.txt b/python-requirements.txt new file mode 100644 index 00000000..5664f42c --- /dev/null +++ b/python-requirements.txt @@ -0,0 +1,2 @@ +psutil + diff --git a/sw_manager.py b/sw_manager.py index 36d70a45..87c91461 100755 --- a/sw_manager.py +++ b/sw_manager.py @@ -53,6 +53,11 @@ def main(): 'clean', help="Removes build outputs of the provided config (img and bin). Does not affect logs or runOutputs.") clean_parser.add_argument('config_files', metavar="config", nargs='+', help="Configuration file(s) to use.") + # Install Command + install_parser = subparsers.add_parser( + 'install', help="Install this workload to firesim (create configs in firesim/deploy/workloads)") + install_parser.add_argument('config_files', metavar="config", nargs='+', help="Configuration file(s) to use.") + args = parser.parse_args() # Load all the configs from the workload directory @@ -125,6 +130,8 @@ def main(): deleteSafe(jCfg['bin'] + '-initramfs') if 'img' in jCfg: deleteSafe(jCfg['img']) + elif args.command == 'install': + wlutil.installWorkload(cfgPath, cfgs) else: log.error("No subcommand specified") sys.exit(1) diff --git a/wlutil/__init__.py b/wlutil/__init__.py index 53150eba..5d1c5b94 100644 --- a/wlutil/__init__.py +++ b/wlutil/__init__.py @@ -6,4 +6,5 @@ from .build import buildWorkload from .launch import launchWorkload from .test import testWorkload,testResult +from .install import installWorkload from .config import ConfigManager diff --git a/wlutil/install.py b/wlutil/install.py new file mode 100644 index 00000000..7db1beb7 --- /dev/null +++ b/wlutil/install.py @@ -0,0 +1,44 @@ +""" Install firesim-software stuff into firesim """ + +import json +from pathlib import Path +from .wlutil import * + +# firesim workloads directory +fsWork = (Path(root_dir) / "../../deploy/workloads").resolve() + +readmeTxt="""This workload was generated using firesim-software. See the following config +and workload directory for details: +""" + +def installWorkload(cfgName, cfgs): + targetCfg = cfgs[cfgName] + if 'jobs' in targetCfg: + raise NotImplementedError("Jobs not currently supported by the install command") + if targetCfg['initramfs'] == True: + raise NotImplementedError("Initramfs-based builds not currently supported by the install command") + + fsTargetDir = fsWork / targetCfg['name'] + + # Firesim config + fsCfg = { + "benchmark_name" : targetCfg['name'], + "common_bootbinary" : os.path.relpath(targetCfg['bin'], start=str(fsTargetDir)), + "common_rootfs" : os.path.relpath(targetCfg['img'], start=str(fsTargetDir)), + "common_simulation_outputs" : ["uartlog"], + } + if 'outputs' in targetCfg: + fsCfg["common_outputs"] = targetCfg['outputs'] + if 'post_run_hook' in targetCfg: + fsCfg["post_run_hook"] = os.path.relpath(targetCfg['post_run_hook'], start=str(fsTargetDir)) + + if not fsTargetDir.exists(): + fsTargetDir.mkdir() + + with open(str(fsTargetDir / "README"), 'w') as readme: + readme.write(readmeTxt) + readme.write(os.path.relpath(targetCfg['cfg-file'], start=str(fsTargetDir)) + "\n") + readme.write(os.path.relpath(targetCfg['workdir'], start=str(fsTargetDir)) + "\n") + + with open(str(fsWork / (targetCfg['name'] + '.json')), 'w') as fsCfgFile: + json.dump(fsCfg, fsCfgFile, indent='\t')