宝石5 IOError:找不到系统文件的路径.完整的系统X86仿真设置 [英] Gem 5 IOError: Can't find a path to system files. Full System X86 simulation setup

查看:291
本文介绍了宝石5 IOError:找不到系统文件的路径.完整的系统X86仿真设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了Gem5. 我正在尝试进行完整的系统仿真. 我添加了M5_PATH

echo "export M5_PATH==/home/sam/security/gem5/full/" >> ~/.bashrc

我将所有系统映像和配置文件放在以下目录中:

  :~/security/gem5/full$ ls
binaries  configs  config-x86.tar.bz2  disks  x86-system.tar.bz2  x86-system.tar.bz2.1

我将SysPaths.py文件中的路径更改为以下内容:

                paths = [ '/dist/m5/system', 'full' ]

并更新了Benchmark.py中的以下行

            return env.get('LINUX_IMAGE', disk('linux-x86.img'))

Gem5已成功编译,我正在运行以下代码:

 ./build/X86/gem5.opt configs/example/fs.py  --disk-image=/home/sam/security/gem5/full/disks/linux-x86.img 

但是我收到一个错误,它找不到系统文件的路径.

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "build/X86/python/m5/main.py", line 438, in main
    exec(filecode, scope)
  File "configs/example/fs.py", line 335, in <module>
    test_sys = build_test_system(np)
  File "configs/example/fs.py", line 93, in build_test_system
    cmdline=cmdline)
  File "/home/sam/security/gem5/configs/common/FSConfig.py", line 614, in makeLinuxX86System
    makeX86System(mem_mode, numCPUs, mdesc, self, Ruby)
  File "/home/sam/security/gem5/configs/common/FSConfig.py", line 539, in makeX86System
    disk0.childImage(mdesc.disk())
  File "/home/sam/security/gem5/configs/common/Benchmarks.py", line 59, in disk
    return disk(self.diskname)
  File "/home/sam/security/gem5/configs/common/SysPaths.py", line 63, in __call__
    raise IOError("Can't find a path to system files.")
IOError: Can't find a path to system files.

解决方案

更新2020-01

截至82f6d6e90f36e400db1f38eef5fe17430313458e,已通过 https://gem5-进行了审查review.googlesource.com/c/public/gem5/+/23672/7 CLI的疯狂程度已大大降低:

    如果您明确指向所有必需的文件,则在X86上不再需要
  • M5_PATH:

    fs.py --kernel path/to/vmlinux --disk-image path/to/rootfs.ext2
    

    不再需要第二个名为linux-bigswap2.imgx86_64-vmlinux-2.6.22.9的磁盘,您可以使用多个--disk-image选项随意传递多个磁盘,请参阅:为什么在可执行文件或脚本名称之前需要./(点斜杠)才能在bash中运行它?

    旧答案

    gem5对某些路径名称有些挑剔,但您无需修补它即可实现不错的图像设置.

    例如,带有gem5 e2656006df442a995bf80ee03fa9700d6ec14537的正常工作设置实际上是在运行:

    M5_PATH=/full/path/to/system \
      build/X86/gem5.opt \
      configs/example/fs.py \
      --disk-image /any/path/to/rootfs.ext2 \
      --kernel /any/path/to/vmlinux
    

    /full/path/to/system包含:

    ./disks/linux-bigswap2.img
    ./binaries/x86_64-vmlinux-2.6.22.9
    

    这两个文件都是我生成的从这里与:

    dd if=/dev/zero of=./binaries/linux-bigswap2.img count=1 bs=16k
    touch disks/x86_64-vmlinux-2.6.22.9
    

    是的,这是gem5自以为是的图像搜索的一种可怕的解决方法...如果您自己通过--disk-image--kernel,某人应该真正修补gem5以便不查找那些图像.

    与往常一样,尝试使用打印和PDB对其进行调试:然后应该很容易弄清楚为什么某些东西对您不起作用.

    I've already got Gem5 installed. I'm trying to do a full system simulation. I added M5_PATH

    echo "export M5_PATH==/home/sam/security/gem5/full/" >> ~/.bashrc
    

    I put all the system image and config files under following directory:

      :~/security/gem5/full$ ls
    binaries  configs  config-x86.tar.bz2  disks  x86-system.tar.bz2  x86-system.tar.bz2.1
    

    I changed the path in the SysPaths.py file to following:

                    paths = [ '/dist/m5/system', 'full' ]
    

    And updated the following line in Benchmark.py

                return env.get('LINUX_IMAGE', disk('linux-x86.img'))
    

    Gem5 is compiled successfully and I'm running the following:

     ./build/X86/gem5.opt configs/example/fs.py  --disk-image=/home/sam/security/gem5/full/disks/linux-x86.img 
    

    But I get an error that it can't find a path to system files.

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "build/X86/python/m5/main.py", line 438, in main
        exec(filecode, scope)
      File "configs/example/fs.py", line 335, in <module>
        test_sys = build_test_system(np)
      File "configs/example/fs.py", line 93, in build_test_system
        cmdline=cmdline)
      File "/home/sam/security/gem5/configs/common/FSConfig.py", line 614, in makeLinuxX86System
        makeX86System(mem_mode, numCPUs, mdesc, self, Ruby)
      File "/home/sam/security/gem5/configs/common/FSConfig.py", line 539, in makeX86System
        disk0.childImage(mdesc.disk())
      File "/home/sam/security/gem5/configs/common/Benchmarks.py", line 59, in disk
        return disk(self.diskname)
      File "/home/sam/security/gem5/configs/common/SysPaths.py", line 63, in __call__
        raise IOError("Can't find a path to system files.")
    IOError: Can't find a path to system files.
    

    解决方案

    Update 2020-01

    As of 82f6d6e90f36e400db1f38eef5fe17430313458e reviewed at https://gem5-review.googlesource.com/c/public/gem5/+/23672/7 the CLI insanity has reduced substantially:

    • M5_PATH is not required anymore on X86 if you point to all required files explicitly:

      fs.py --kernel path/to/vmlinux --disk-image path/to/rootfs.ext2
      

      The second disk named linux-bigswap2.img and x86_64-vmlinux-2.6.22.9 are not needed anymore, and you can pass multiple disks at will with multiple --disk-image options, see: How to attach multiple disk images in a simulation with gem5 fs.py?

    • on ARM, M5_PATH can also be dispensed, but you also need to point the bootloader with:

      fs.py --bootloader ./system/arm/bootloader/arm64/boot.arm64
      

    If you miss any of those files, M5_PATH gets used.

    Note that just like the PATH search algorithm, paths without / are only searched under M5_PATH, so if you want to point to a file in the current directory you need to add ./ as in:

    fs.py --kernel ./vmlinux
    

    see also: Why do you need ./ (dot-slash) before executable or script name to run it in bash?

    Old answer

    gem5 is picky about some path names, but you don't need to patch it to achieve a decent image setup.

    For example, this working setup with gem5 e2656006df442a995bf80ee03fa9700d6ec14537 essentially runs:

    M5_PATH=/full/path/to/system \
      build/X86/gem5.opt \
      configs/example/fs.py \
      --disk-image /any/path/to/rootfs.ext2 \
      --kernel /any/path/to/vmlinux
    

    and /full/path/to/system contains:

    ./disks/linux-bigswap2.img
    ./binaries/x86_64-vmlinux-2.6.22.9
    

    Both of those files are dummies which I generated from here with:

    dd if=/dev/zero of=./binaries/linux-bigswap2.img count=1 bs=16k
    touch disks/x86_64-vmlinux-2.6.22.9
    

    Yes, this is a horrible workaround to gem5's opinionated image searching... someone should really patch gem5 to not look for those images if you pass --disk-image and --kernel yourself...

    As always, have a try at debugging it with prints and PDB: it should then be simple to figure out why something didn't work for you.

    这篇关于宝石5 IOError:找不到系统文件的路径.完整的系统X86仿真设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆