xref: /qemu/docs/config/q35-virtio-graphical.cfg (revision 370ed600)
1# q35 - VirtIO guest (graphical console)
2# =========================================================
3#
4# Usage:
5#
6#   $ qemu-system-x86_64 \
7#     -nodefaults \
8#     -readconfig q35-virtio-graphical.cfg
9#
10# You will probably need to tweak the lines marked as
11# CHANGE ME before being able to use this configuration!
12#
13# The guest will have a selection of VirtIO devices
14# tailored towards optimal performance with modern guests,
15# and will be accessed through a graphical console.
16#
17# ---------------------------------------------------------
18#
19# Using -nodefaults is required to have full control over
20# the virtual hardware: when it's specified, QEMU will
21# populate the board with only the builtin peripherals
22# plus a small selection of core PCI devices and
23# controllers; the user will then have to explicitly add
24# further devices.
25#
26# The core PCI devices show up in the guest as:
27#
28#   00:00.0 Host bridge
29#   00:1f.0 ISA bridge / LPC
30#   00:1f.2 SATA (AHCI) controller
31#   00:1f.3 SMBus controller
32#
33# This configuration file adds a number of other useful
34# devices, more specifically:
35#
36#   00:01.0 VGA compatible controller
37#   00:1b.0 Audio device
38#   00.1c.* PCI bridge (PCI Express Root Ports)
39#   01:00.0 SCSI storage controller
40#   02:00.0 Ethernet controller
41#   03:00.0 USB controller
42#
43# More information about these devices is available below.
44
45
46# Machine options
47# =========================================================
48#
49# We use the q35 machine type and enable KVM acceleration
50# for better performance.
51#
52# Using less than 1 GiB of memory is probably not going to
53# yield good performance in the guest, and might even lead
54# to obscure boot issues in some cases.
55
56[machine]
57  type = "q35"
58
59[accel]
60  accel = "kvm"
61
62[memory]
63  size = "1024"
64
65
66# PCI bridge (PCI Express Root Ports)
67# =========================================================
68#
69# We create eight PCI Express Root Ports, and we plug them
70# all into separate functions of the same slot. Some of
71# them will be used by devices, the rest will remain
72# available for hotplug.
73
74[device "pcie.1"]
75  driver = "pcie-root-port"
76  bus = "pcie.0"
77  addr = "1c.0"
78  port = "1"
79  chassis = "1"
80  multifunction = "on"
81
82[device "pcie.2"]
83  driver = "pcie-root-port"
84  bus = "pcie.0"
85  addr = "1c.1"
86  port = "2"
87  chassis = "2"
88
89[device "pcie.3"]
90  driver = "pcie-root-port"
91  bus = "pcie.0"
92  addr = "1c.2"
93  port = "3"
94  chassis = "3"
95
96[device "pcie.4"]
97  driver = "pcie-root-port"
98  bus = "pcie.0"
99  addr = "1c.3"
100  port = "4"
101  chassis = "4"
102
103[device "pcie.5"]
104  driver = "pcie-root-port"
105  bus = "pcie.0"
106  addr = "1c.4"
107  port = "5"
108  chassis = "5"
109
110[device "pcie.6"]
111  driver = "pcie-root-port"
112  bus = "pcie.0"
113  addr = "1c.5"
114  port = "6"
115  chassis = "6"
116
117[device "pcie.7"]
118  driver = "pcie-root-port"
119  bus = "pcie.0"
120  addr = "1c.6"
121  port = "7"
122  chassis = "7"
123
124[device "pcie.8"]
125  driver = "pcie-root-port"
126  bus = "pcie.0"
127  addr = "1c.7"
128  port = "8"
129  chassis = "8"
130
131
132# SCSI storage controller (and storage)
133# =========================================================
134#
135# We use virtio-scsi here so that we can (hot)plug a large
136# number of disks without running into issues; a SCSI disk,
137# backed by a qcow2 disk image on the host's filesystem, is
138# attached to it.
139#
140# We also create an optical disk, mostly for installation
141# purposes: once the guest OS has been successfully
142# installed, the guest will no longer boot from optical
143# media. If you don't want, or no longer want, to have an
144# optical disk in the guest you can safely comment out
145# all relevant sections below.
146
147[device "scsi"]
148  driver = "virtio-scsi-pci"
149  bus = "pcie.1"
150  addr = "00.0"
151
152[device "scsi-disk"]
153  driver = "scsi-hd"
154  bus = "scsi.0"
155  drive = "disk"
156  bootindex = "1"
157
158[drive "disk"]
159  file = "guest.qcow2"                          # CHANGE ME
160  format = "qcow2"
161  if = "none"
162
163[device "scsi-optical-disk"]
164  driver = "scsi-cd"
165  bus = "scsi.0"
166  drive = "optical-disk"
167  bootindex = "2"
168
169[drive "optical-disk"]
170  file = "install.iso"                          # CHANGE ME
171  format = "raw"
172  if = "none"
173
174
175# Ethernet controller
176# =========================================================
177#
178# We use virtio-net for improved performance over emulated
179# hardware; on the host side, we take advantage of user
180# networking so that the QEMU process doesn't require any
181# additional privileges.
182
183[netdev "hostnet"]
184  type = "user"
185
186[device "net"]
187  driver = "virtio-net-pci"
188  netdev = "hostnet"
189  bus = "pcie.2"
190  addr = "00.0"
191
192
193# USB controller (and input devices)
194# =========================================================
195#
196# We add a virtualization-friendly USB 3.0 controller and
197# a USB tablet so that graphical guests can be controlled
198# appropriately. A USB keyboard is not needed, as q35
199# guests get a PS/2 one added automatically.
200
201[device "usb"]
202  driver = "nec-usb-xhci"
203  bus = "pcie.3"
204  addr = "00.0"
205
206[device "tablet"]
207  driver = "usb-tablet"
208  bus = "usb.0"
209
210
211# VGA compatible controller
212# =========================================================
213#
214# We plug the QXL video card directly into the PCI Express
215# Root Bus as it is a legacy PCI device; this way, we can
216# reduce the number of PCI Express controllers in the
217# guest.
218#
219# If you're running the guest on a remote, potentially
220# headless host, you will probably want to append something
221# like
222#
223#   -display vnc=127.0.0.1:0
224#
225# to the command line in order to prevent QEMU from
226# creating a graphical display window on the host and
227# enable remote access instead.
228
229[device "video"]
230  driver = "qxl-vga"
231  bus = "pcie.0"
232  addr = "01.0"
233
234
235# Audio device
236# =========================================================
237#
238# Like the video card, the sound card is a legacy PCI
239# device and as such can be plugged directly into the PCI
240# Express Root Bus.
241
242[device "sound"]
243  driver = "ich9-intel-hda"
244  bus = "pcie.0"
245  addr = "1b.0"
246
247[device "duplex"]
248  driver = "hda-duplex"
249  bus = "sound.0"
250  cad = "0"
251