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
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:
open the file with O_CREAT
set the appropriate executable permissions
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.
Related
I'm trying to use the full system to do some experiments.
I used the boot-exit image and vmlinux-5.4.49 provided by this website(https://gem5art.readthedocs.io/en/latest/tutorials/boot-tutorial.html)
I first tried using the terminal script that comes with gem5.
In one of the terminals I execute:
/build/X86/gem5.opt
configs/example/fs.py \
--kernel=../../full_system_image/binaries/vmlinux-4.19.83 \
--disk-image=../../full_system_image/disks/boot-exit.img "
I execute in another terminal:
util/term/m5term localhost 3456
After that, I successfully entered, although I waited for dozens of minutes.
I can enter commands normally.
.
But i want to run my program. I don't want to have to enter the terminal every time, that would be too slow.
For boot-exit images:
I added/root/init.sh instruction at the end of /root/.bashrc file. In this way, the init.sh script will be executed every time the system is entered.
The content of the init.sh file is:
m5 readfile > /tmp/run.sh
/bin/sh /tmp/run.sh
m5 exit
I added run_hello.sh and hello executable files (output hello, world) in the /root directory.
The content of the run_hello.sh file is:
m5 resetstats
/root/hello > /tmp/hello.out
m5 dumpstats
I executed the following command:
/usr/local/src/gem5/build/X86/gem5.opt --debug-flags=CacheAll --debug-file=/usr/local/src/gem5/runScripts/attack_spectre/trace2.out /usr/local/src/gem5/configs/example/fs.py --kernel=../../full_system_image/binaries/vmlinux-4.19.83 --disk-image=../../full_system_image/disks/boot-exit.img --l1d_replacement=LRU --mem-size=4GB --l1d_size=32kB --l1d_assoc=8 --l1i_size=32kB --l1i_assoc=4 --l2_assoc=16 --l2_size=2MB --caches --l2cache --cpu-type=DerivO3CPU --script=/root/run_hello.sh
The process will always be stuck here.
It seems to keep waiting for a terminal connection.
If I don't connect, it just waits until. When I connect( util/term/m5term localhost 3456), it will show that there is a terminal connected.
When I type m5 exit in the connected terminal, it ends on both sides.
What should I do to run my code without connecting to a terminal?
thank you very much! ! !
Hi I am looking to automate my file transfering to my Jailbroken iPhone over USB with a bash file. Which will launch the relay then do the file transfers
With this here I installed and successfully transfered files to my iPhone with cygwin but now I want to automate the file transfer.
First I need to start the relay with cygwin and those commands are required
cd pyusbmux/python-client/
chmod +x *
./tclrelay.py -t 22:2222
so I created a .sh file that does it but when I launch it cygwin gives me those errors
This is what should happen on the left and the result of the script on the right
How can I make cygwin open with thoses commands
In addition to be sure that tcpON.sh has proper line termination with d2u of dos2unix package:
d2u tcpON.sh
You should add a proper SHEBANG on the first line of your script
https://linuxize.com/post/bash-shebang/
#!/bin/bash
cd /cygdrive/e/Grez/Desktop
cd pyusbmux/python-client/
chmod +x *
./tclrelay.py -t 22:2222
You can use as base the Cygwin.bat and make a tcpON.bat batch file like:
C:
chdir c:\cygwin64\bin
bash --login /cygdrive/e/Grez/Desktop/tcpON.sh
Verify the proper cd command to be sure that you are always in the expected directory.
It is not the only way but probably the most flexible (IMHO)
I'm getting this error while Ansible (1.9.2) is trying to unpack the file.
19:06:38 TASK: [jmeter | unpack jmeter] ************************************************
19:06:38 fatal: [jmeter01.veryfast.server.jenkins] => input file not found at /tmp/apache-jmeter-2.13.tgz or /tmp/apache-jmeter-2.13.tgz
19:06:38
19:06:38 FATAL: all hosts have already failed -- aborting
19:06:38
I checked on the target server, /tmp/apache-jmeter-2.13.tgz file exists and it has valid permissions (for testing I also gave 777 even though not reqd but still got the above error mesg).
I also checked md5sum of this file (compared it with what's there on the apache jmeter site) -- It matches!
# md5sum apache-jmeter-2.13.tgz|grep 53dc44a6379b7b4a57976936f3a65e03
53dc44a6379b7b4a57976936f3a65e03 apache-jmeter-2.13.tgz
When I'm using tar -xvzf on this file, tar is able to show/extract it's contents in the .tgz file.
What could I be missing? At this point, I'm wondering unarchive method/module in Ansible must have some bug.
My last resort (if I can't get unarchive in Ansible to work) would be to use Command: "tar -xzvf /tmp/....." but I don't want to do that as my first preference.
The default behavior for Unarchive is to find the file on your local system, copy it to the remote, and unpack it. I suspect if you're getting a file not found error then you need to specify copy=no in your task.
I just finished writing my very first command-line tool in Objective-C, compiled it, and now I'm curious about how one would go about making it executable as a command.
For example, right now to use the program I have to type in ./filename -args into Terminal. I'd like to be able to only type in filename and execute the program.
I tried using sudo chmod a+x filename but no go.
sudo cp filename /usr/local/bin/
Or add the directory containing filename into $PATH. Like as all other UNIX-derived OSs.
I'm having trouble running a simple bash script from Java. Specifically:
...
try{
ProcessBuilder pb = new ProcessBuilder("/bin/bash", "-c", command);
pb.directory(new File(dir));
Process shell = pb.start();
int exitVal = shell.waitFor();
...
where 'command' the absolute path to a bash script that is executable by all and 'dir' is the working directory.
When I run my program I get an exit code 127 ("command not found"). I've tried using the Java Runtime class and the process.exec method but neither have worked for me. Any suggestions?
If "command" is a bash script, then instead of passing "/bin/bash" (and the erroneous "-c" like you're doing) to ProcessBuilder, just make sure that command is executable (chmod +x command), that the first line is #!/bin/bash, and then pass the full path to it into ProcessBuilder.
No -c. That means the script is the argument to -c. You are passing it a pathname, and you don't use -c for that.