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