Andrea Bolognani | 9ca019c | 2017-02-17 11:14:38 +0100 | [diff] [blame] | 1 | # q35 - VirtIO guest (serial console) |
| 2 | # ========================================================= |
| 3 | # |
| 4 | # Usage: |
| 5 | # |
| 6 | # $ qemu-system-x86_64 \ |
| 7 | # -nodefaults \ |
| 8 | # -readconfig q35-virtio-serial.cfg \ |
| 9 | # -display none -serial mon:stdio |
| 10 | # |
| 11 | # You will probably need to tweak the lines marked as |
| 12 | # CHANGE ME before being able to use this configuration! |
| 13 | # |
| 14 | # The guest will have a selection of VirtIO devices |
| 15 | # tailored towards optimal performance with modern guests, |
| 16 | # and will be accessed through the serial console. |
| 17 | # |
| 18 | # --------------------------------------------------------- |
| 19 | # |
| 20 | # Using -nodefaults is required to have full control over |
| 21 | # the virtual hardware: when it's specified, QEMU will |
| 22 | # populate the board with only the builtin peripherals |
| 23 | # plus a small selection of core PCI devices and |
| 24 | # controllers; the user will then have to explicitly add |
| 25 | # further devices. |
| 26 | # |
| 27 | # The core PCI devices show up in the guest as: |
| 28 | # |
| 29 | # 00:00.0 Host bridge |
| 30 | # 00:1f.0 ISA bridge / LPC |
| 31 | # 00:1f.2 SATA (AHCI) controller |
| 32 | # 00:1f.3 SMBus controller |
| 33 | # |
| 34 | # This configuration file adds a number of other useful |
| 35 | # devices, more specifically: |
| 36 | # |
| 37 | # 00.1c.* PCI bridge (PCI Express Root Ports) |
| 38 | # 01:00.0 SCSI storage controller |
| 39 | # 02:00.0 Ethernet controller |
| 40 | # |
| 41 | # More information about these devices is available below. |
| 42 | # |
| 43 | # We use '-display none' to prevent QEMU from creating a |
| 44 | # graphical display window, which would serve no use in |
| 45 | # this specific configuration, and '-serial mon:stdio' to |
| 46 | # multiplex the guest's serial console and the QEMU monitor |
| 47 | # to the host's stdio; use 'Ctrl+A h' to learn how to |
| 48 | # switch between the two and more. |
| 49 | |
| 50 | |
| 51 | # Machine options |
| 52 | # ========================================================= |
| 53 | # |
| 54 | # We use the q35 machine type and enable KVM acceleration |
| 55 | # for better performance. |
| 56 | # |
| 57 | # Using less than 1 GiB of memory is probably not going to |
| 58 | # yield good performance in the guest, and might even lead |
| 59 | # to obscure boot issues in some cases. |
| 60 | |
| 61 | [machine] |
| 62 | type = "q35" |
Thomas Huth | 4477035 | 2023-02-28 22:15:30 +0100 | [diff] [blame] | 63 | |
| 64 | [accel] |
Andrea Bolognani | 9ca019c | 2017-02-17 11:14:38 +0100 | [diff] [blame] | 65 | accel = "kvm" |
| 66 | |
| 67 | [memory] |
| 68 | size = "1024" |
| 69 | |
| 70 | |
| 71 | # PCI bridge (PCI Express Root Ports) |
| 72 | # ========================================================= |
| 73 | # |
| 74 | # We create eight PCI Express Root Ports, and we plug them |
| 75 | # all into separate functions of the same slot. Some of |
| 76 | # them will be used by devices, the rest will remain |
| 77 | # available for hotplug. |
| 78 | |
| 79 | [device "pcie.1"] |
| 80 | driver = "pcie-root-port" |
| 81 | bus = "pcie.0" |
| 82 | addr = "1c.0" |
| 83 | port = "1" |
| 84 | chassis = "1" |
| 85 | multifunction = "on" |
| 86 | |
| 87 | [device "pcie.2"] |
| 88 | driver = "pcie-root-port" |
| 89 | bus = "pcie.0" |
| 90 | addr = "1c.1" |
| 91 | port = "2" |
| 92 | chassis = "2" |
| 93 | |
| 94 | [device "pcie.3"] |
| 95 | driver = "pcie-root-port" |
| 96 | bus = "pcie.0" |
| 97 | addr = "1c.2" |
| 98 | port = "3" |
| 99 | chassis = "3" |
| 100 | |
| 101 | [device "pcie.4"] |
| 102 | driver = "pcie-root-port" |
| 103 | bus = "pcie.0" |
| 104 | addr = "1c.3" |
| 105 | port = "4" |
| 106 | chassis = "4" |
| 107 | |
| 108 | [device "pcie.5"] |
| 109 | driver = "pcie-root-port" |
| 110 | bus = "pcie.0" |
| 111 | addr = "1c.4" |
| 112 | port = "5" |
| 113 | chassis = "5" |
| 114 | |
| 115 | [device "pcie.6"] |
| 116 | driver = "pcie-root-port" |
| 117 | bus = "pcie.0" |
| 118 | addr = "1c.5" |
| 119 | port = "6" |
| 120 | chassis = "6" |
| 121 | |
| 122 | [device "pcie.7"] |
| 123 | driver = "pcie-root-port" |
| 124 | bus = "pcie.0" |
| 125 | addr = "1c.6" |
| 126 | port = "7" |
| 127 | chassis = "7" |
| 128 | |
| 129 | [device "pcie.8"] |
| 130 | driver = "pcie-root-port" |
| 131 | bus = "pcie.0" |
| 132 | addr = "1c.7" |
| 133 | port = "8" |
| 134 | chassis = "8" |
| 135 | |
| 136 | |
| 137 | # SCSI storage controller (and storage) |
| 138 | # ========================================================= |
| 139 | # |
| 140 | # We use virtio-scsi here so that we can (hot)plug a large |
| 141 | # number of disks without running into issues; a SCSI disk, |
| 142 | # backed by a qcow2 disk image on the host's filesystem, is |
| 143 | # attached to it. |
| 144 | # |
| 145 | # We also create an optical disk, mostly for installation |
Ville Skyttä | 9277d81 | 2018-06-12 09:51:50 +0300 | [diff] [blame] | 146 | # purposes: once the guest OS has been successfully |
Andrea Bolognani | 9ca019c | 2017-02-17 11:14:38 +0100 | [diff] [blame] | 147 | # installed, the guest will no longer boot from optical |
| 148 | # media. If you don't want, or no longer want, to have an |
| 149 | # optical disk in the guest you can safely comment out |
| 150 | # all relevant sections below. |
| 151 | |
| 152 | [device "scsi"] |
| 153 | driver = "virtio-scsi-pci" |
| 154 | bus = "pcie.1" |
| 155 | addr = "00.0" |
| 156 | |
| 157 | [device "scsi-disk"] |
| 158 | driver = "scsi-hd" |
| 159 | bus = "scsi.0" |
| 160 | drive = "disk" |
| 161 | bootindex = "1" |
| 162 | |
| 163 | [drive "disk"] |
| 164 | file = "guest.qcow2" # CHANGE ME |
| 165 | format = "qcow2" |
| 166 | if = "none" |
| 167 | |
| 168 | [device "scsi-optical-disk"] |
| 169 | driver = "scsi-cd" |
| 170 | bus = "scsi.0" |
| 171 | drive = "optical-disk" |
| 172 | bootindex = "2" |
| 173 | |
| 174 | [drive "optical-disk"] |
| 175 | file = "install.iso" # CHANGE ME |
| 176 | format = "raw" |
| 177 | if = "none" |
| 178 | |
| 179 | |
| 180 | # Ethernet controller |
| 181 | # ========================================================= |
| 182 | # |
| 183 | # We use virtio-net for improved performance over emulated |
| 184 | # hardware; on the host side, we take advantage of user |
| 185 | # networking so that the QEMU process doesn't require any |
| 186 | # additional privileges. |
| 187 | |
| 188 | [netdev "hostnet"] |
| 189 | type = "user" |
| 190 | |
| 191 | [device "net"] |
| 192 | driver = "virtio-net-pci" |
| 193 | netdev = "hostnet" |
| 194 | bus = "pcie.2" |
| 195 | addr = "00.0" |