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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
|
# mach-virt - VirtIO guest (graphical console)
# =========================================================
#
# Usage:
#
# $ qemu-system-aarch64 \
# -nodefaults \
# -readconfig mach-virt-graphical.cfg \
# -cpu host
#
# You will probably need to tweak the lines marked as
# CHANGE ME before being able to use this configuration!
#
# The guest will have a selection of VirtIO devices
# tailored towards optimal performance with modern guests,
# and will be accessed through a graphical console.
#
# ---------------------------------------------------------
#
# Using -nodefaults is required to have full control over
# the virtual hardware: when it's specified, QEMU will
# populate the board with only the builtin peripherals,
# such as the PL011 UART, plus a PCI Express Root Bus; the
# user will then have to explicitly add further devices.
#
# The PCI Express Root Bus shows up in the guest as:
#
# 00:00.0 Host bridge
#
# This configuration file adds a number of other useful
# devices, more specifically:
#
# 00:01.0 Display controller
# 00.1c.* PCI bridge (PCI Express Root Ports)
# 01:00.0 SCSI storage controller
# 02:00.0 Ethernet controller
# 03:00.0 USB controller
#
# More information about these devices is available below.
# Machine options
# =========================================================
#
# We use the virt machine type and enable KVM acceleration
# for better performance.
#
# Using less than 1 GiB of memory is probably not going to
# yield good performance in the guest, and might even lead
# to obscure boot issues in some cases.
#
# Unfortunately, there is no way to configure the CPU model
# in this file, so it will have to be provided on the
# command line, but we can configure the guest to use the
# same GIC version as the host.
[machine]
type = "virt"
accel = "kvm"
gic-version = "host"
[memory]
size = "1024"
# Firmware configuration
# =========================================================
#
# There are two parts to the firmware: a read-only image
# containing the executable code, which is shared between
# guests, and a read/write variable store that is owned
# by one specific guest, exclusively, and is used to
# record information such as the UEFI boot order.
#
# For any new guest, its permanent, private variable store
# should initially be copied from the template file
# provided along with the firmware binary.
#
# Depending on the OS distribution you're using on the
# host, the name of the package containing the firmware
# binary and variable store template, as well as the paths
# to the files themselves, will be different. For example:
#
# Fedora
# edk2-aarch64 (pkg)
# /usr/share/edk2/aarch64/QEMU_EFI-pflash.raw (bin)
# /usr/share/edk2/aarch64/vars-template-pflash.raw (var)
#
# RHEL
# AAVMF (pkg)
# /usr/share/AAVMF/AAVMF_CODE.fd (bin)
# /usr/share/AAVMF/AAVMF_VARS.fd (var)
#
# Debian/Ubuntu
# qemu-efi (pkg)
# /usr/share/AAVMF/AAVMF_CODE.fd (bin)
# /usr/share/AAVMF/AAVMF_VARS.fd (var)
[drive "uefi-binary"]
file = "/usr/share/AAVMF/AAVMF_CODE.fd" # CHANGE ME
format = "raw"
if = "pflash"
unit = "0"
readonly = "on"
[drive "uefi-varstore"]
file = "guest_VARS.fd" # CHANGE ME
format = "raw"
if = "pflash"
unit = "1"
# PCI bridge (PCI Express Root Ports)
# =========================================================
#
# We create eight PCI Express Root Ports, and we plug them
# all into separate functions of the same slot. Some of
# them will be used by devices, the rest will remain
# available for hotplug.
[device "pcie.1"]
driver = "pcie-root-port"
bus = "pcie.0"
addr = "1c.0"
port = "1"
chassis = "1"
multifunction = "on"
[device "pcie.2"]
driver = "pcie-root-port"
bus = "pcie.0"
addr = "1c.1"
port = "2"
chassis = "2"
[device "pcie.3"]
driver = "pcie-root-port"
bus = "pcie.0"
addr = "1c.2"
port = "3"
chassis = "3"
[device "pcie.4"]
driver = "pcie-root-port"
bus = "pcie.0"
addr = "1c.3"
port = "4"
chassis = "4"
[device "pcie.5"]
driver = "pcie-root-port"
bus = "pcie.0"
addr = "1c.4"
port = "5"
chassis = "5"
[device "pcie.6"]
driver = "pcie-root-port"
bus = "pcie.0"
addr = "1c.5"
port = "6"
chassis = "6"
[device "pcie.7"]
driver = "pcie-root-port"
bus = "pcie.0"
addr = "1c.6"
port = "7"
chassis = "7"
[device "pcie.8"]
driver = "pcie-root-port"
bus = "pcie.0"
addr = "1c.7"
port = "8"
chassis = "8"
# SCSI storage controller (and storage)
# =========================================================
#
# We use virtio-scsi here so that we can (hot)plug a large
# number of disks without running into issues; a SCSI disk,
# backed by a qcow2 disk image on the host's filesystem, is
# attached to it.
#
# We also create an optical disk, mostly for installation
# purposes: once the guest OS has been successfully
# installed, the guest will no longer boot from optical
# media. If you don't want, or no longer want, to have an
# optical disk in the guest you can safely comment out
# all relevant sections below.
[device "scsi"]
driver = "virtio-scsi-pci"
bus = "pcie.1"
addr = "00.0"
[device "scsi-disk"]
driver = "scsi-hd"
bus = "scsi.0"
drive = "disk"
bootindex = "1"
[drive "disk"]
file = "guest.qcow2" # CHANGE ME
format = "qcow2"
if = "none"
[device "scsi-optical-disk"]
driver = "scsi-cd"
bus = "scsi.0"
drive = "optical-disk"
bootindex = "2"
[drive "optical-disk"]
file = "install.iso" # CHANGE ME
format = "raw"
if = "none"
# Ethernet controller
# =========================================================
#
# We use virtio-net for improved performance over emulated
# hardware; on the host side, we take advantage of user
# networking so that the QEMU process doesn't require any
# additional privileges.
[netdev "hostnet"]
type = "user"
[device "net"]
driver = "virtio-net-pci"
netdev = "hostnet"
bus = "pcie.2"
addr = "00.0"
# USB controller (and input devices)
# =========================================================
#
# We add a virtualization-friendly USB 3.0 controller and
# a USB keyboard / USB tablet combo so that graphical
# guests can be controlled appropriately.
[device "usb"]
driver = "nec-usb-xhci"
bus = "pcie.3"
addr = "00.0"
[device "keyboard"]
driver = "usb-kbd"
bus = "usb.0"
[device "tablet"]
driver = "usb-tablet"
bus = "usb.0"
# Display controller
# =========================================================
#
# We use virtio-gpu because the legacy VGA framebuffer is
# very troublesome on aarch64, and virtio-gpu is the only
# video device that doesn't implement it.
#
# If you're running the guest on a remote, potentially
# headless host, you will probably want to append something
# like
#
# -display vnc=127.0.0.1:0
#
# to the command line in order to prevent QEMU from
# creating a graphical display window on the host and
# enable remote access instead.
[device "video"]
driver = "virtio-gpu"
bus = "pcie.0"
addr = "01.0"
|