Reputation: 4073
I expect m5 readfile
will read a file from the host, and m5 execfile
will execute a file from host, but the documentation is scarce and I couldn't get them to work.
Maybe the path is determined by readfile=
in m5out/config.ini
, but I don't know how to modify that setting when using fs.py
; when I relaunch gem5 it overwrites that file.
I was able to use the related m5 writefile
however with:
Guest:
echo mycontent > myfileguest
m5 writefile myfileguest myfilehost
Host:
cat m5out/myfilehost
Upvotes: 1
Views: 1193
Reputation: 4073
readfile
As of gem5 68af229490fc811aebddf68b3e2e09e63a5fa475 you can set the readfile
path with:
fs.py --script=myfile
Unlike writefile
, the path is relative to the current directory on the host, not m5out
.
Then when you run m5 readfile
in the guest, it outputs the contents of the file to stdout.
This does in the fs.py
script:
if options.script is not None:
test_sys.readfile = options.script
which seems to inherit from class System
, which ends up serializing configurations to config.ini
only for debugging purposes.
execfile
execfile
is just a very light wrapper over readfile
, that instead of writing the input file to stdout, writes it to /tmp/execfile
, and runs the exec
syscall on it from C.
However, as of 68af229490fc811aebddf68b3e2e09e63a5fa475, m5
does not:
O_CREAT
so you must do on guest:
touch /tmp/execfile
chmod +x /tmp/execfile
m5 execfile
I'd just rather do this with m5 readfile
and some scripting.
m5 execfile
could be useful as an init
program however, but I find argument passing to init programs too clumsy and unrealiable.
Upvotes: 1