summaryrefslogtreecommitdiff
path: root/emulators/qemu-riscv/pkg/README
diff options
context:
space:
mode:
Diffstat (limited to 'emulators/qemu-riscv/pkg/README')
-rw-r--r--emulators/qemu-riscv/pkg/README266
1 files changed, 0 insertions, 266 deletions
diff --git a/emulators/qemu-riscv/pkg/README b/emulators/qemu-riscv/pkg/README
deleted file mode 100644
index 09221d2..0000000
--- a/emulators/qemu-riscv/pkg/README
+++ /dev/null
@@ -1,266 +0,0 @@
1+-----------------------------------------------------------------------
2| Running ${PKGSTEM} on OpenBSD
3+-----------------------------------------------------------------------
4
5==> Quick Start
6
71. Get a bootable CDROM image:
8
9 $ ftp https://cdn.openbsd.org/pub/OpenBSD/snapshots/i386/cd70.iso
10
11 or to use a 64-bit client OS or SPARC, respectively:
12
13 $ ftp https://cdn.openbsd.org/pub/OpenBSD/snapshots/amd64/cd70.iso
14
15 $ ftp https://cdn.openbsd.org/pub/OpenBSD/snapshots/sparc/cd70.iso
16
172. Create a virtual disk image:
18
19 $ qemu-img create -f qcow2 virtual.img 10G
20
213. Install the OS:
22
23 $ qemu-system-i386 -m 32 -monitor stdio -no-fd-bootchk \
24 -hda virtual.img -cdrom cd70.iso -boot d
25
26 or:
27
28 $ qemu-system-x86_64 -m 32 -monitor stdio -no-fd-bootchk \
29 -hda virtual.img -cdrom cd70.iso -boot d
30
31 $ qemu-system-sparc -m 32 -monitor stdio \
32 -hda virtual.img -cdrom cd70.iso -boot d
33
34 NOTE: start this inside an xterm or equivalent.
35 NOTE: be sure to choose serial console during install.
36 NOTE: -no-fd-bootchk permits booting faster when no floppy is
37 in use, but is not supported for qemu-system-sparc.
38 NOTE: qemu-system-ppc* and qemu-system-sparc* currently fail with
39 J or S malloc flags
40
414. Compress the virtual disk:
42
43 $ qemu-img convert -c -O qcow2 virtual.img v.tmp && \
44 mv v.tmp virtual.img
45
46 NOTE: do not do this while QEMU is running / using this virtual
47 disk.
48
495. Boot normally from the virtual disk:
50
51 $ qemu-system-i386 -m 32 -nographic -no-fd-bootchk -hda virtual.img
52
53 or:
54
55 $ qemu-system-x86_64 -m 32 -nographic -no-fd-bootchk -hda virtual.img
56
57 $ qemu-system-sparc -m 32 -nographic -hda virtual.img
58
59==> Networking
60
611. Default Settings
62
63 By default, QEMU sets up the equivalent of the following networking:
64
65 -net nic,vlan=0,model=e1000,macaddr=52:54:00:12:34:56
66 -net user,vlan=0
67
68 Also, inside this virtual usermode network, it uses the 10.0.2.0/24
69 and serves DHCP from inside this virtual network. Static address
70 can be used if one cannot or does not want to do DHCP in the
71 guest OS:
72
73 Guest OS IP : 10.0.2.15
74 Default Gateway : 10.0.2.2
75 Nameserver : 10.0.2.3
76
77 It is sufficient for most operations, QEMU itself performs NAT
78 and then makes userland network calls for TCP/UDP operations.
79 ICMP and other things are not possible in this mode.
80
81 NOTE: If you use one '-net' cmdline argument, QEMU assumes you
82 know what you want and clears defaults for the rest of the
83 -net defaults.
84
85 NOTE: The guest mode networking does not currently support IPv6,
86 and QEMU will complain that it cannot find a DNS server
87 if /etc/resolv.conf contains only IPv6 DNS servers.
88
892. tap mode
90
91 Sometimes it is desirable to configure QEMU to access a network
92 via layer2 directly. One way of doing this without having to run
93 QEMU as root is to let root open /dev/tapN and pass the file
94 descriptor to QEMU. The tap(4) interface should preferrably be
95 configured before starting QEMU:
96
97 $ doas ifconfig tap0 192.168.0.254
98
99 The interface can also be configured as part of a bridge(4), in
100 which case the ip address can be omitted:
101
102 $ doas ifconfig bridge0 add tap0 add em0 up
103
104 The tunnel and bridge interfaces can also be configured at system
105 startup by editing /etc/hostname.tapN and /etc/hostname.bridgeN,
106 respectively (see hostname.if(5)).
107
108 After configuring the virtual network we can use doas to let
109 root open the tunnel device and then use doas again to drop
110 privileges and start QEMU:
111
112 $ doas sh -c "doas -u $USER qemu-system-i386 -nographic -net nic \
113 -net tap,fd=3 -no-fd-bootchk -hda virtual.img 3<>/dev/tap0"
114
115 NOTE: if you use sudo instead of doas, remember that sudo calls
116 closefrom(2). In order to have more than one fd passed tap
117 interface, a line to sudoers akin to:
118
119 Defaults closefrom_override
120
121 then calling sudo via 'sudo -C 5 -u $USER qemu-system-i386 ..'
122 is required. See sudoers(5) and sudo(8) for details.
123
124 An alternative to the procedure described above is to have QEMU
125 set up the network via ${SYSCONFDIR}/qemu-ifup. This is not
126 recommended however, since you would have to run QEMU as root,
127 and there is no way to drop from root privileges at this point.
128
129 ${SYSCONFDIR}/qemu-ifup contains some default settings that
130 permit one to do the following:
131
132 # qemu-system-i386 -net nic -net tap -no-fd-bootchk -hda virtual.img
133
134 It presumes you wish the tap(4) interface to talk to the interface
135 holding the default IPv4 route (falling back to trunk0 if no
136 route is found), and that you want 'bridge0' to be used to bridge
137 the two.
138
139 Setting the environment variables ETHER and BRIDGE will override
140 these settings, respectively.
141
142 When starting QEMU, the script attempts to output useful
143 information, but there are also error messages that occur as
144 well. On my laptop, I want to route / nat natively using PF and
145 also have layer2 access to the QEMU networks. I thus have this
146 as /etc/hostname.trunk101:
147
148 inet6 fe80::1c 64 lladdr 00:03:25:0d:7a:2c
149 inet 10.7.255.1 255.255.255.0
150 inet6 alias 2001:240:58a:45::1c
151
152 I have dhcpd configured to run on trunk101, and also run rad.
153 For QEMU, the startup looks like this:
154
155 # export ETHER=trunk101
156 # export BRIDGE=bridge101
157 # qemu-system-i386 -net nic,vlan=0,macaddr=52:54:00:12:35:00 \
158 -net tap,vlan=0 -vnc :0 -localtime -usb -usbdevice tablet \
159 -m 256 -no-fd-bootchk -hda virtual.img -monitor stdio
160 {tap0 (bridge101 <-> trunk101)ifconfig: bridge101: No such process
161 ifconfig: bridge101: No such process
162 }
163 (qemu)
164
165 The errors are normal and should be ignored. One can verify the
166 networking is properly configured by verifying the bridge
167 interface:
168
169 $ ifconfig bridge101
170 bridge101: flags=41<UP,RUNNING>
171 groups: bridge
172 priority 32768 hellotime 2 fwddelay 15 maxage 20 holdcnt 6 proto rstp
173 designated: id 00:00:00:00:00:00 priority 0
174 tap0 flags=3<LEARNING,DISCOVER>
175 port 16 ifpriority 0 ifcost 0
176 trunk101 flags=3<LEARNING,DISCOVER>
177 port 6 ifpriority 0 ifcost 0
178 Addresses (max cache: 100, timeout: 240):
179
180 NOTE: When running multiple QEMU sessions simultaneously on the
181 same bridge, care must be taken because the network MAC
182 address defaults to 52:54:00:12:34:56 for every QEMU
183 instance. To change this, observe the macaddr= syntax in
184 the above example and choose a unique lladdr per QEMU nic.
185
186==> Mice
187
188 NOTE: Certain OS's work much better with the USB tablet device
189 than the normal PS/2 mouse handling. See the above example
190 for usage.
191
192==> Serial Console
193
194 Installing OpenBSD via serial console is sometimes desirable.
195 X may not be available, and so on. There are two ways to
196 accomplish this, both in effect the same solution:
197
198 a. qemu-system-i386 -vnc :0 -serial stdio .. virtual.img \
199 -cdrom install52.iso -boot d
200
201 - this option permits you to use VNC from some system to
202 connect to the QEMU instance and 'set tty com0' at the
203 'boot>' prompt.
204 - you may then disconnect VNC and use the terminal from
205 which you started QEMU to do the install.
206
207 b. qemu-system-i386 -nographic .. virtual.img -fda floppy52.fs -boot a
208
209 - this maps both the serial port and the (qemu) monitor
210 prompt to the terminal QEMU was started on.
211 - to flip between them, Ctrl-a c; see the QEMU man page for
212 other commands that work in -nographic mode.
213 - preparation of the floppy image to force serial console
214 mode is straightforward:
215
216 vnconfig vnd0 floppy52.fs
217 mount /dev/vnd0c /mnt
218 mkdir /mnt/etc
219 echo set tty com0 > /mnt/etc/boot.conf
220 umount /mnt
221 vnconfig -u vnd0
222
223 .. be sure to choose 'yes' for setting com0 to be the serial
224 console.
225
226 NOTE: OpenBSD poweroff does work with QEMU, which actually causes
227 QEMU itself to exit. This is a good thing, as it is
228 currently not possible to set what block device is booted
229 from at runtime from QEMU. So if you start an installation
230 booting from a CD-ROM, you will always boot off a CD-ROM
231 every time you reboot that QEMU session until you exit and
232 start QEMU again booting off the virtual hard drive.
233
234==> daemonized QEMU
235
236 Sometimes you want QEMU to start as part of a system script.
237
238 Adding to some of the above, the -daemonize option comes in
239 handy, as well as the telnet: designator for -serial and monitor.
240 This is a complete example that may be cut-and-pasted into
241 rc.local:
242
243 hddir=/var/vm
244 USER=qemu
245 if [ -x ${TRUEPREFIX}/bin/qemu ]; then
246 echo -n 'Qemu: vmi386'
247 (
248 ifconfig bridge101 add trunk101 add tap0 up
249
250 sh -c "doas -u $USER \
251 ${TRUEPREFIX}/bin/qemu-system-i386 \
252 -daemonize \
253 -nographic \
254 -net nic,vlan=0,macaddr=52:54:00:4e:62:8f \
255 -net tap,vlan=0,fd=3 \
256 -m 128 \
257 -hda $hddir/virtual.img \
258 -serial telnet:127.0.0.1:1080,server,nowait \
259 -monitor telnet:127.0.0.1:1081,server,nowait \
260 -no-fd-bootchk 3<>/dev/tap0"
261 )
262 echo "."
263 fi
264
265 NOTE: this presumes the user `qemu' exists, create it or set
266 USER= to an existing user to use this example.