Skip to content

Commit 65d33ab

Browse files
committed
run: actually rename ./run --busybox-init to --eval-after
Had just changed the CLI parameter but nothing else! Had half worked because Python argparse is insane and accepts substrings like --eval-a. Fix #43
1 parent 034bd36 commit 65d33ab

File tree

2 files changed

+52
-51
lines changed

2 files changed

+52
-51
lines changed

README.adoc

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ The safe way, is to fist quit QEMU, rebuild the modules, put them in the root fi
230230
....
231231
./build-modules
232232
./build-buildroot
233-
./run --eval-busybox 'insmod /hello.ko'
233+
./run --eval-after 'insmod /hello.ko'
234234
....
235235

236236
`./build-buildroot` is required after `./build-modules` because it generates the root filesystem with the modules that we compiled at `./build-modules`.
@@ -241,7 +241,7 @@ You can see that `./build` does that as well, by running:
241241
./build --dry-run
242242
....
243243

244-
`--eval-busybox` is optional: you could just type `insmod /hello.ko` in the terminal, but this makes it run automatically at the end of boot, and then drops you into a shell.
244+
`--eval-after` is optional: you could just type `insmod /hello.ko` in the terminal, but this makes it run automatically at the end of boot, and then drops you into a shell.
245245

246246
If the guest and host are the same arch, typically x86_64, you can speed up boot further with <<kvm>>:
247247

@@ -275,7 +275,7 @@ then as usual rebuild and re-run:
275275

276276
.....
277277
./build-qemu
278-
./run --eval-busybox 'grep "model name" /proc/cpuinfo'
278+
./run --eval-after 'grep "model name" /proc/cpuinfo'
279279
.....
280280

281281
and once again, there is your message: QEMU communicated it to the Linux kernel, which printed it out.
@@ -1081,7 +1081,7 @@ It is kind of random: if you just `insmod` manually and then immediately `./run-
10811081
But this fails most of the time: shell 1:
10821082

10831083
....
1084-
./run --arch arm --eval-busybox 'insmod /hello.ko'
1084+
./run --arch arm --eval-after 'insmod /hello.ko'
10851085
....
10861086

10871087
shell 2:
@@ -1170,7 +1170,7 @@ So once we find the address the first time, we can just reuse it afterwards, as
11701170
Do a fresh boot and get the module:
11711171

11721172
....
1173-
./run --eval-busybox '/pr_debug.sh;insmod /fops.ko;/poweroff.out'
1173+
./run --eval-after '/pr_debug.sh;insmod /fops.ko;/poweroff.out'
11741174
....
11751175

11761176
The boot must be fresh, because the load address changes every time we insert, even after removing previous modules.
@@ -1606,7 +1606,7 @@ The implementation is described at: https://stackoverflow.com/questions/46415059
16061606
We can set and get which cores the Linux kernel allows a program to run on with `sched_getaffinity` and `sched_setaffinity`:
16071607

16081608
....
1609-
./run --cpus 2 --eval-busybox '/sched_getaffinity.out'
1609+
./run --cpus 2 --eval-after '/sched_getaffinity.out'
16101610
....
16111611

16121612
Source: link:userland/sched_getaffinity.c[]
@@ -1636,7 +1636,7 @@ The number of cores is modified as explained at: <<number-of-cores>>
16361636
--config 'BR2_PACKAGE_UTIL_LINUX=y' \
16371637
--config 'BR2_PACKAGE_UTIL_LINUX_SCHEDUTILS=y' \
16381638
;
1639-
./run --eval-busybox 'taskset -c 1,1 /sched_getaffinity.out'
1639+
./run --eval-after 'taskset -c 1,1 /sched_getaffinity.out'
16401640
....
16411641

16421642
output:
@@ -1658,7 +1658,7 @@ We will run our `/sched_getaffinity.out` infinitely many time, on core 0 and cor
16581658
./run \
16591659
--cpus 2 \
16601660
--wait-gdb \
1661-
--eval-busybox 'i=0; while true; do taskset -c $i,$i /sched_getaffinity.out; i=$((! $i)); done' \
1661+
--eval-after 'i=0; while true; do taskset -c $i,$i /sched_getaffinity.out; i=$((! $i)); done' \
16621662
;
16631663
....
16641664

@@ -1690,7 +1690,7 @@ We should also try it out with kernel modules: https://stackoverflow.com/questio
16901690
TODO we then tried:
16911691

16921692
....
1693-
./run --cpus 2 --eval-busybox '/sched_getaffinity_threads.out'
1693+
./run --cpus 2 --eval-after '/sched_getaffinity_threads.out'
16941694
....
16951695

16961696
and:
@@ -2217,7 +2217,7 @@ I've tried:
22172217

22182218
....
22192219
./run-toolchain --arch aarch64 gcc -- -static ~/test/hello_world.c -o "$(./getvar p9_dir)/a.out"
2220-
./run --arch aarch64 --eval-busybox '/mnt/9p/data/a.out'
2220+
./run --arch aarch64 --eval-after '/mnt/9p/data/a.out'
22212221
....
22222222

22232223
but it fails with:
@@ -2373,7 +2373,7 @@ This executable is a convenient simple init that does not panic and sleeps inste
23732373
Get a reasonable answer to "how long does boot take?":
23742374

23752375
....
2376-
./run --eval-busybox '/time_boot.out'
2376+
./run --eval-after '/time_boot.out'
23772377
....
23782378

23792379
Dmesg contains a message of type:
@@ -2389,10 +2389,10 @@ Bibliography: https://stackoverflow.com/questions/12683169/measure-time-taken-fo
23892389
[[init-busybox]]
23902390
=== Run command at the end of BusyBox init
23912391

2392-
Use the `--eval-busybox` option is for you rely on something that BusyBox' init set up for you like `/etc/fstab`:
2392+
Use the `--eval-after` option is for you rely on something that BusyBox' init set up for you like `/etc/fstab`:
23932393

23942394
....
2395-
./run --eval-busybox 'echo asdf;ls /proc;ls /sys;echo qwer'
2395+
./run --eval-after 'echo asdf;ls /proc;ls /sys;echo qwer'
23962396
....
23972397

23982398
After the commands run, you are left on an interactive shell.
@@ -2405,7 +2405,7 @@ The above command is basically equivalent to:
24052405

24062406
where the `lkmc_eval` option gets evaled by our default link:rootfs_overlay/etc/init.d/S98[S98] startup script.
24072407

2408-
Except that `--eval-busybox` is smarter and uses `base64` encoding.
2408+
Except that `--eval-after` is smarter and uses `base64` encoding.
24092409

24102410
Alternatively, you can also add the comamdns to run to a new `init.d` entry to run at the end o the BusyBox init:
24112411

@@ -3059,7 +3059,7 @@ gem5 full system:
30593059
time \
30603060
./run \
30613061
--arch arm \
3062-
--eval-busybox '/gem5.sh' \
3062+
--eval-after '/gem5.sh' \
30633063
--gem5
30643064
--gem5-readfile 'dhrystone 100000' \
30653065
;
@@ -3077,7 +3077,7 @@ QEMU full system:
30773077
time \
30783078
./run \
30793079
--arch arm \
3080-
--eval-busybox 'time dhrystone 100000000;/poweroff.out' \
3080+
--eval-after 'time dhrystone 100000000;/poweroff.out' \
30813081
;
30823082
....
30833083

@@ -3095,7 +3095,7 @@ Result on <<p51>> at bad30f513c46c1b0995d3a10c0d9bc2a33dc4fa0:
30953095
link:https://git.busybox.net/busybox/tree/modutils/insmod.c?h=1_29_3[Provided by BusyBox]:
30963096

30973097
....
3098-
./run --eval-busybox 'insmod /hello.ko'
3098+
./run --eval-after 'insmod /hello.ko'
30993099
....
31003100

31013101
=== myinsmod
@@ -4271,8 +4271,8 @@ and so it is Read Only as shown by `ro`.
42714271
Disable userland address space randomization. Test it out by running <<rand_check-out>> twice:
42724272

42734273
....
4274-
./run --eval-busybox '/rand_check.out;/poweroff.out'
4275-
./run --eval-busybox '/rand_check.out;/poweroff.out'
4274+
./run --eval-after '/rand_check.out;/poweroff.out'
4275+
./run --eval-after '/rand_check.out;/poweroff.out'
42764276
....
42774277

42784278
If we remove it from our link:run[] script by hacking it up, the addresses shown by `rand_check.out` vary across boots.
@@ -5027,7 +5027,7 @@ If `CONFIG_KALLSYMS=n`, then addresses are shown on traces instead of symbol plu
50275027
In v4.16 it does not seem possible to configure that at runtime. GDB step debugging with:
50285028

50295029
....
5030-
./run --eval-busybox 'insmod /dump_stack.ko' --wait-gdb --tmux=dump_stack
5030+
./run --eval-after 'insmod /dump_stack.ko' --wait-gdb --tmux=dump_stack
50315031
....
50325032

50335033
shows that traces are printed at `arch/x86/kernel/dumpstack.c`:
@@ -5759,7 +5759,7 @@ Source: link:kernel_modules/work_from_work.c[]
57595759
Let's block the entire kernel! Yay:
57605760

57615761
.....
5762-
./run --eval-busybox 'dmesg -n 1;insmod /schedule.ko schedule=0'
5762+
./run --eval-after 'dmesg -n 1;insmod /schedule.ko schedule=0'
57635763
.....
57645764

57655765
Outcome: the system hangs, the only way out is to kill the VM.
@@ -5773,7 +5773,7 @@ Sleep functions like `usleep_range` also end up calling schedule.
57735773
If we allow `schedule()` to be called, then the system becomes responsive:
57745774

57755775
.....
5776-
./run --eval-busybox 'dmesg -n 1;insmod /schedule.ko schedule=1'
5776+
./run --eval-after 'dmesg -n 1;insmod /schedule.ko schedule=1'
57775777
.....
57785778

57795779

@@ -5786,7 +5786,7 @@ dmesg -w
57865786
The system also responds if we <<number-of-cores,add another core>>:
57875787

57885788
....
5789-
./run --cpus 2 --eval-busybox 'dmesg -n 1;insmod /schedule.ko schedule=0'
5789+
./run --cpus 2 --eval-after 'dmesg -n 1;insmod /schedule.ko schedule=0'
57905790
....
57915791

57925792
==== Wait queues
@@ -5866,7 +5866,7 @@ Bibliography:
58665866
Brute force monitor every shared interrupt that will accept us:
58675867

58685868
....
5869-
./run --eval-busybox 'insmod /irq.ko' --graphic
5869+
./run --eval-after 'insmod /irq.ko' --graphic
58705870
....
58715871

58725872
Source: link:kernel_modules/irq.c[].
@@ -6678,7 +6678,7 @@ Detects buffer overflows for us:
66786678
./build-modules --clean
66796679
./build-modules
66806680
./build-buildroot
6681-
./run --eval-busybox 'insmod /strlen_overflow.ko' --linux-build-id fortify
6681+
./run --eval-after 'insmod /strlen_overflow.ko' --linux-build-id fortify
66826682
....
66836683

66846684
Possible dmesg output:
@@ -7186,7 +7186,7 @@ DRM / DRI is the new interface that supersedes `fbdev`:
71867186
....
71877187
./build-buildroot --config 'BR2_PACKAGE_LIBDRM=y'
71887188
./build-userland --has-package libdrm -- libdrm_modeset
7189-
./run --eval-busybox '/libdrm_modeset.out' --graphic
7189+
./run --eval-after '/libdrm_modeset.out' --graphic
71907190
....
71917191

71927192
Source: link:userland/libdrm_modeset.c[]
@@ -7199,7 +7199,7 @@ TODO not working for `aarch64`, it takes over the screen for a few seconds and t
71997199
./build-buildroot --config 'BR2_PACKAGE_LIBDRM=y'
72007200
./build-userland --has-package libdrm
72017201
./build-buildroot
7202-
./run --eval-busybox '/libdrm_modeset.out' --graphic
7202+
./run --eval-after '/libdrm_modeset.out' --graphic
72037203
....
72047204

72057205
<<kmscube>> however worked, which means that it must be a bug with this demo?
@@ -7224,7 +7224,7 @@ Try creating new displays:
72247224
to see multiple `/dev/dri/cardN`, and then use a different display with:
72257225

72267226
....
7227-
./run --eval-busybox '/libdrm_modeset.out' --graphic
7227+
./run --eval-after '/libdrm_modeset.out' --graphic
72287228
....
72297229

72307230
Bibliography:
@@ -7412,14 +7412,14 @@ For QEMU, this is done by passing the `snapshot` option to `-drive`, and for gem
74127412
If you hack up our link:run[] script to remove that option, then:
74137413

74147414
....
7415-
./run --eval-busybox 'date >f;poweroff'
7415+
./run --eval-after 'date >f;poweroff'
74167416
74177417
....
74187418

74197419
followed by:
74207420

74217421
....
7422-
./run --eval-busybox 'cat f'
7422+
./run --eval-after 'cat f'
74237423
....
74247424

74257425
gives the date, because `poweroff` without `-n` syncs before shutdown.
@@ -7485,7 +7485,7 @@ qcow2 filesystems must be used for that to work.
74857485
To test it out, login into the VM with and run:
74867486

74877487
....
7488-
./run --eval-busybox 'umount /mnt/9p/*;/count.sh'
7488+
./run --eval-after 'umount /mnt/9p/*;/count.sh'
74897489
....
74907490

74917491
On another shell, take a snapshot:
@@ -8279,15 +8279,15 @@ This awesome feature allows you to examine a single run as many times as you wou
82798279

82808280
....
82818281
# Record a run.
8282-
./run --eval-busybox '/rand_check.out;/poweroff.out;' --record
8282+
./run --eval-after '/rand_check.out;/poweroff.out;' --record
82838283
# Replay the run.
8284-
./run --eval-busybox '/rand_check.out;/poweroff.out;' --replay
8284+
./run --eval-after '/rand_check.out;/poweroff.out;' --replay
82858285
....
82868286

82878287
A convenient shortcut to do both at once to test the feature is:
82888288

82898289
....
8290-
./qemu-rr --eval-busybox '/rand_check.out;/poweroff.out;'
8290+
./qemu-rr --eval-after '/rand_check.out;/poweroff.out;'
82918291
....
82928292

82938293
By comparing the terminal output of both runs, we can see that they are the exact same, including things which normally differ across runs:
@@ -8314,7 +8314,7 @@ EXT4-fs (sda): re-mounted. Opts: block_validity,barrier,user_xattr
83148314
TODO replay with network gets stuck:
83158315

83168316
....
8317-
./qemu-rr --eval-busybox 'ifup -a;wget -S google.com;/poweroff.out;'
8317+
./qemu-rr --eval-after 'ifup -a;wget -S google.com;/poweroff.out;'
83188318
....
83198319

83208320
after the message:
@@ -8333,7 +8333,7 @@ Then, when I tried with <<initrd>> and no disk:
83338333

83348334
....
83358335
./build-buildroot --arch aarch64 -i
8336-
./qemu-rr --arch aarch64 --eval-busybox '/rand_check.out;/poweroff.out;' -i
8336+
./qemu-rr --arch aarch64 --eval-after '/rand_check.out;/poweroff.out;' -i
83378337
....
83388338

83398339
QEMU crashes with:
@@ -8353,8 +8353,8 @@ TODO get working.
83538353
QEMU replays support checkpointing, and this allows for a simplistic "reverse debugging" implementation proposed at https://lists.gnu.org/archive/html/qemu-devel/2018-06/msg00478.html on the unmerged link:https://github.com/ispras/qemu/tree/rr-180725[]:
83548354

83558355
....
8356-
./run --eval-busybox '/rand_check.out;/poweroff.out;' --record
8357-
./run --eval-busybox '/rand_check.out;/poweroff.out;' --replay --wait-gdb
8356+
./run --eval-after '/rand_check.out;/poweroff.out;' --record
8357+
./run --eval-after '/rand_check.out;/poweroff.out;' --replay --wait-gdb
83588358
....
83598359

83608360
On another shell:
@@ -8827,7 +8827,7 @@ Usage:
88278827
....
88288828
./run \
88298829
--arch aarch64 \
8830-
--eval-busybox '/gem5.sh' \
8830+
--eval-after '/gem5.sh' \
88318831
--gem5 \
88328832
--gem5-readfile '/bst_vs_heap.out' \
88338833
;
@@ -8858,7 +8858,7 @@ Buildroot supports it, which makes everything just trivial:
88588858
....
88598859
./build-buildroot --config 'BR2_PACKAGE_OPENBLAS=y'
88608860
./build-userland --has-package openblas -- openblas_hello
8861-
./run --eval-busybox '/openblas_hello.out; echo $?'
8861+
./run --eval-after '/openblas_hello.out; echo $?'
88628862
....
88638863

88648864
Outcome: the test passes:
@@ -8903,7 +8903,7 @@ Header only linear algebra library with a mainline Buildroot package:
89038903
Just create an array and print it:
89048904

89058905
....
8906-
./run --eval-busybox '/eigen_hello.out'
8906+
./run --eval-after '/eigen_hello.out'
89078907
....
89088908

89098909
Output:
@@ -10921,10 +10921,10 @@ It does not work if you just download the `.zip` with the sources for this repos
1092110921

1092210922
=== Run command after boot
1092310923

10924-
If you just want to run a command after boot ends without thinking much about it, just use the `--eval-busybox` option, e.g.:
10924+
If you just want to run a command after boot ends without thinking much about it, just use the `--eval-after` option, e.g.:
1092510925

1092610926
....
10927-
./run --eval-busybox 'echo hello'
10927+
./run --eval-after 'echo hello'
1092810928
....
1092910929

1093010930
This option passes the command to our init scripts through <<kernel-command-line-parameters>>, and uses a few clever tricks along the way to make it just work.
@@ -11409,7 +11409,7 @@ Those packages get automatically added to Buildroot's `BR2_EXTERNAL`, so all you
1140911409
then test it out with:
1141011410

1141111411
....
11412-
./run --eval-busybox '/sample_package.out'
11412+
./run --eval-after '/sample_package.out'
1141311413
....
1141411414

1141511415
and you should see:
@@ -11451,7 +11451,7 @@ Usage:
1145111451
Then test one of the modules with:
1145211452

1145311453
....
11454-
./run --buildroot-linux --eval-busybox 'modprobe buildroot_hello'
11454+
./run --buildroot-linux --eval-after 'modprobe buildroot_hello'
1145511455
....
1145611456

1145711457
Source: link:buildroot_packages/kernel_modules/buildroot_hello.c[]
@@ -11686,7 +11686,7 @@ Sources:
1168611686
Print out several parameters that normally change randomly from boot to boot:
1168711687

1168811688
....
11689-
./run --eval-busybox '/rand_check.out;/poweroff.out'
11689+
./run --eval-after '/rand_check.out;/poweroff.out'
1169011690
....
1169111691

1169211692
Source: link:userland/rand_check.c[]

0 commit comments

Comments
 (0)