-
Notifications
You must be signed in to change notification settings - Fork 29
/
TESTCPU
executable file
·69 lines (58 loc) · 2.46 KB
/
TESTCPU
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
set -e
UROOT=${UROOT:=$HOME/go/src/github.com/u-root/u-root}
KERNEL=${KERNEL:=$HOME/linuxboot/mainboards/intel/generic/kernel-noinitramfs}
VMN=${VMN:=42}
KEY=${KEY:=$HOME/.ssh/cpu_rsa.pub}
echo NOTE: WE USED TO RUN CPUD AUTOMAGICALLY
echo That turned out to be inconvenient for testing
echo Once the VM is up, you need to run cpud manually
echo If you want to test cpud as the init, add this line
echo to the u-root command, along with the other switches.
echo -initcmd=/bbin/cpud \
# error our early for simple things
ls ${KEY}
ls -d ${UROOT}
ls ${KERNEL}
# You will need to put your host key and private key somewhere. They will be placed in the proper place in the image.
#
# $* is positioned where it is so you can use extra switches like -h or add files via, e.g., -files whatever
# you can also add non-switch args too.
# it allows you to configure the initramfs a bit more, with or without switches
# The day when u-root was superconvenient to use is gone, done in by modules.
# goanywhere makes it much less hard.
go install github.com/u-root/gobusybox/src/cmd/goanywhere@latest
goanywhere ${UROOT}/cmds/core/* ./cmds/cpu ./cmds/cpud -- u-root -files $KEY
echo NOT adding a host key at -files ssh_host_rsa_key:etc/ssh/ssh_host_rsa_key
set +e
sudo /usr/bin/qemu-system-x86_64 -kernel \
$KERNEL \
-cpu max \
-s \
-m 1024m \
-machine q35 \
-initrd /tmp/initramfs.linux_amd64.cpio \
-object rng-random,filename=/dev/urandom,id=rng0 \
-device virtio-rng-pci,rng=rng0 \
-serial mon:stdio \
-append earlyprintk=ttyS0,115200\ console=ttyS0 \
-device vhost-vsock-pci,guest-cid=42 \
-monitor /dev/null \
-device virtio-net-pci,netdev=n1 \
-netdev user,id=n1,hostfwd=tcp:127.0.0.1:17010-:17010,net=192.168.1.0/24,host=192.168.1.1 \
-debugcon file:debug.log -global isa-debugcon.iobase=0x402 \
-nographic
reset
# note we will exit here so the trash below is not a problem
exit 0
# two handy utils for testing vsock
-files vsock-server \
-files vsock-cat \
-device e1000,netdev=n1 \
-device virtio-net-pci,netdev=n1 \
-device virtio-net-pci,netdev=mynet0 \
-netdev user,id=mynet0,hostfwd=tcp::${VMN}0022-:22,hostfwd=tcp::${VMN}1024-:1024,hostfwd=tcp::${VMN}1234-:1234 \
# junk
/home/rminnich/projects/linuxboot/linux/arch/x86/boot/bzImage \
# add the following line to qemu if you want to snoop packets.
-object filter-dump,id=f1,netdev=n1,file=/tmp/vm0.pcap \