Skip to contentSkip to conversation

docs: Improve sample configuration files

PATCH Superseded Andrea Bolognani 3 participants 6 messages Feb 10, 2017 – Feb 13, 2017

v6 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v6 cover docs: Improve sample configuration files

Changes since [v5]

* Address review comments:
- use the native serial console rather than the VirtIO based one, and enable monitor multiplexing so that the user can switch between the two;
- add GIC version configuration;
- improve wording all over the place.

* Improvements:
- add information about Debian/Ubuntu firmware packages.

Changes since [v4]

* Improvements:
- move storage configuration from the command line to the configuration files so that the command line is shorter and we can provide better documentation for the various parts;
- configure the amount of memory for the guest in the file too;
- document the fact that you might want/need to use '-serial stdio' and '-display vnc=...' in some situations;
- fix the value of 'port' for one of the pcie-root-port devices;
- fix some inaccurate comments.

* Arguably the opposite:
- remove the sample command line for running a live OS from the file header. I could be convinced to add it back as a (commented) section about it, if people think it's useful enough.

Changes since [v3]

* Address review comments:
- place VGA at 00:01.0;
- use pcie-root-port instead of ioh3420 in q35-virtio-*.cfg;
- add a comment to let users know that PCI Express devices should not be placed on the legacy PCI bridge.

Changes since [v2]

* Address review comments:
- use -nodefaults in q35-emulated.cfg too;
- add explicit VGA and Ethernet.

* Improvements:
- use virtconsole and virtio-serial instead of isa-serial in q35-virtio-serial.cfg.

* Possibily controversial:
- get rid of q35-virtio-common.cfg and add the PCIe Root Ports back into q35-virtio-*.cfg: while this leads to having some duplicated content, I feel like the sample configurations are much more useful when they can stand entirely on their own, especially now that they start with a detailed hardware listing.

* Cosmetic stuff:
- hardware listing looks like the output of lspci;
- section names match what's used in the hardware listing so it's faster to jump to the section;
- PCI addresses also match the output of lspci;
- PCI Express is used instead of PCIe.

Changes since [v1]

* Address review comments:
- improve the existing configuration file instead of removing it;
- split off the common part for VirtIO guests;
- plug all ioh3420 devices in a single slot;
- use slot 1c for ioh3420 devices;
- remove useless USB keyboard.

* Improve usage description:
- make sure the OS disk actually uses the VirtIO SCSI controller, as intended, rather than the built-in SATA one;
- provide a command line for running live CDs.

* Document more devices:
- the video card is added by default;
- so is the Ethernet adapter, apparently.

[v1] http://lists.nongnu.org/archive/html/qemu-devel/2017-01/msg06342.html
[v2] http://lists.nongnu.org/archive/html/qemu-devel/2017-02/msg00184.html
[v3] http://lists.nongnu.org/archive/html/qemu-devel/2017-02/msg00461.html
[v4] http://lists.nongnu.org/archive/html/qemu-devel/2017-02/msg00672.html
[v5] http://lists.nongnu.org/archive/html/qemu-devel/2017-02/msg01714.html

Andrea Bolognani (2):
q35: Improve sample configuration files
mach-virt: Provide sample configuration files

 docs/mach-virt-graphical.cfg  | 262 ++++++++++++++++++++++++++++++++++++++++
 docs/mach-virt-serial.cfg     | 224 +++++++++++++++++++++++++++++++++++
 docs/q35-chipset.cfg          | 152 ------------------------
 docs/q35-emulated.cfg         | 269 ++++++++++++++++++++++++++++++++++++++++++
 docs/q35-virtio-graphical.cfg | 229 +++++++++++++++++++++++++++++++++++
 docs/q35-virtio-serial.cfg    | 174 +++++++++++++++++++++++++++
 6 files changed, 1158 insertions(+), 152 deletions(-)
 create mode 100644 docs/mach-virt-graphical.cfg
 create mode 100644 docs/mach-virt-serial.cfg
 delete mode 100644 docs/q35-chipset.cfg
 create mode 100644 docs/q35-emulated.cfg
 create mode 100644 docs/q35-virtio-graphical.cfg
 create mode 100644 docs/q35-virtio-serial.cfg
Signature · 1 line
2.7.4
#1 lore raw

PATCH v6 1/2 q35: Improve sample configuration files

Instead of having a single sample configuration file, we now have several:

* q35-emulated.cfg documents the default devices QEMU adds to a q35 guest and the additional devices that are pretty much guaranteed to be present in a physical q35-based machine;

* q35-virtio-graphical.cfg can be used to start a fully-featured (USB, graphical console, audio, etc.) guest that uses VirtIO instead of emulated devices;

* q35-virtio-serial.cfg is similar but has a minimal set of devices and uses the serial console.

All configuration files are fully commented and neatly organized.

---
 docs/q35-chipset.cfg          | 152 ------------------------
 docs/q35-emulated.cfg         | 269 ++++++++++++++++++++++++++++++++++++++++++
 docs/q35-virtio-graphical.cfg | 229 +++++++++++++++++++++++++++++++++++
 docs/q35-virtio-serial.cfg    | 174 +++++++++++++++++++++++++++
 4 files changed, 672 insertions(+), 152 deletions(-)
 delete mode 100644 docs/q35-chipset.cfg
 create mode 100644 docs/q35-emulated.cfg
 create mode 100644 docs/q35-virtio-graphical.cfg
 create mode 100644 docs/q35-virtio-serial.cfg
docs/q35-chipset.cfg deleted +0 -152
deleted file mode 100644
index e4ddb7d..0000000
@@ -1,152 +0,0 @@
-################################################################
-#
-# qemu -M q35 creates a bare machine with just the very essential
-# chipset devices being present:
-#
-#     00.0 - Host bridge
-#     1f.0 - ISA bridge / LPC
-#     1f.2 - SATA (AHCI) controller
-#     1f.3 - SMBus controller
-#
-# This config file documents the other devices and how they are
-# created.  You can simply use "-readconfig $thisfile" to create
-# them all.  Here is a overview:
-#
-#     19.0 - Ethernet controller (not created, our e1000 emulation
-#                                 doesn't emulate the ich9 device).
-#     1a.* - USB Controller #2 (ehci + uhci companions)
-#     1b.0 - HD Audio Controller
-#     1c.* - PCI Express Ports
-#     1d.* - USB Controller #1 (ehci + uhci companions,
-#                               "qemu -M q35 -usb" creates these too)
-#     1e.0 - PCI Bridge
-#
-
-[device "ich9-ehci-2"]
-  driver = "ich9-usb-ehci2"
-  multifunction = "on"
-  bus = "pcie.0"
-  addr = "1a.7"
-
-[device "ich9-uhci-4"]
-  driver = "ich9-usb-uhci4"
-  multifunction = "on"
-  bus = "pcie.0"
-  addr = "1a.0"
-  masterbus = "ich9-ehci-2.0"
-  firstport = "0"
-
-[device "ich9-uhci-5"]
-  driver = "ich9-usb-uhci5"
-  multifunction = "on"
-  bus = "pcie.0"
-  addr = "1a.1"
-  masterbus = "ich9-ehci-2.0"
-  firstport = "2"
-
-[device "ich9-uhci-6"]
-  driver = "ich9-usb-uhci6"
-  multifunction = "on"
-  bus = "pcie.0"
-  addr = "1a.2"
-  masterbus = "ich9-ehci-2.0"
-  firstport = "4"
-
-
-[device "ich9-hda-audio"]
-  driver = "ich9-intel-hda"
-  bus = "pcie.0"
-  addr = "1b.0"
-
-
-[device "ich9-pcie-port-1"]
-  driver = "ioh3420"
-  multifunction = "on"
-  bus = "pcie.0"
-  addr = "1c.0"
-  port = "1"
-  chassis = "1"
-
-[device "ich9-pcie-port-2"]
-  driver = "ioh3420"
-  multifunction = "on"
-  bus = "pcie.0"
-  addr = "1c.1"
-  port = "2"
-  chassis = "2"
-
-[device "ich9-pcie-port-3"]
-  driver = "ioh3420"
-  multifunction = "on"
-  bus = "pcie.0"
-  addr = "1c.2"
-  port = "3"
-  chassis = "3"
-
-[device "ich9-pcie-port-4"]
-  driver = "ioh3420"
-  multifunction = "on"
-  bus = "pcie.0"
-  addr = "1c.3"
-  port = "4"
-  chassis = "4"
-
-##
-# Example PCIe switch with two downstream ports
-#
-#[device "pcie-switch-upstream-port-1"]
-#  driver = "x3130-upstream"
-#  bus = "ich9-pcie-port-4"
-#  addr = "00.0"
-#
-#[device "pcie-switch-downstream-port-1-1"]
-#  driver = "xio3130-downstream"
-#  multifunction = "on"
-#  bus = "pcie-switch-upstream-port-1"
-#  addr = "00.0"
-#  port = "1"
-#  chassis = "5"
-#
-#[device "pcie-switch-downstream-port-1-2"]
-#  driver = "xio3130-downstream"
-#  multifunction = "on"
-#  bus = "pcie-switch-upstream-port-1"
-#  addr = "00.1"
-#  port = "1"
-#  chassis = "6"
-
-[device "ich9-ehci-1"]
-  driver = "ich9-usb-ehci1"
-  multifunction = "on"
-  bus = "pcie.0"
-  addr = "1d.7"
-
-[device "ich9-uhci-1"]
-  driver = "ich9-usb-uhci1"
-  multifunction = "on"
-  bus = "pcie.0"
-  addr = "1d.0"
-  masterbus = "ich9-ehci-1.0"
-  firstport = "0"
-
-[device "ich9-uhci-2"]
-  driver = "ich9-usb-uhci2"
-  multifunction = "on"
-  bus = "pcie.0"
-  addr = "1d.1"
-  masterbus = "ich9-ehci-1.0"
-  firstport = "2"
-
-[device "ich9-uhci-3"]
-  driver = "ich9-usb-uhci3"
-  multifunction = "on"
-  bus = "pcie.0"
-  addr = "1d.2"
-  masterbus = "ich9-ehci-1.0"
-  firstport = "4"
-
-
-[device "ich9-pci-bridge"]
-  driver = "i82801b11-bridge"
-  bus = "pcie.0"
-  addr = "1e.0"
docs/q35-emulated.cfg new file +269 -0

269 lines not on this page · raw message

docs/q35-virtio-graphical.cfg new file +229 -0

229 lines not on this page · raw message

docs/q35-virtio-serial.cfg new file +174 -0

174 lines not on this page · raw message

Signature · 1 line
2.7.4
#2 lore raw

PATCH v6 2/2 mach-virt: Provide sample configuration files

These are very much like the sample configuration files for q35, and can be used both as documentation and as a starting point for creating your own guest.

Two sample configuration files are provided:

* mach-virt-graphical.cfg can be used to start a fully-featured (USB, graphical console, etc.) guest that uses VirtIO devices;

* mach-virt-serial.cfg is similar but has a minimal set of devices and uses the serial console.

All configuration files are fully commented and neatly organized.

---
 docs/mach-virt-graphical.cfg | 262 +++++++++++++++++++++++++++++++++++++++++++
 docs/mach-virt-serial.cfg    | 224 ++++++++++++++++++++++++++++++++++++
 2 files changed, 486 insertions(+)
 create mode 100644 docs/mach-virt-graphical.cfg
 create mode 100644 docs/mach-virt-serial.cfg
docs/mach-virt-graphical.cfg new file +262 -0
new file mode 100644
index 0000000..2dab3af
@@ -0,0 +1,262 @@
+# 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 "pci.1"]
+  driver = "pcie-root-port"
+  bus = "pcie.0"
+  addr = "1c.0"
+  port = "1"
+  chassis = "1"
+  multifunction = "on"
+
+[device "pci.2"]
+  driver = "pcie-root-port"
+  bus = "pcie.0"
+  addr = "1c.1"
+  port = "2"
+  chassis = "2"
+
+[device "pci.3"]
+  driver = "pcie-root-port"
+  bus = "pcie.0"
+  addr = "1c.2"
+  port = "3"
+  chassis = "3"
+
+[device "pci.4"]
+  driver = "pcie-root-port"
+  bus = "pcie.0"
+  addr = "1c.3"
+  port = "4"
+  chassis = "4"
+
+[device "pci.5"]
+  driver = "pcie-root-port"
+  bus = "pcie.0"
+  addr = "1c.4"
+  port = "5"
+  chassis = "5"
+
+[device "pci.6"]
+  driver = "pcie-root-port"
+  bus = "pcie.0"
+  addr = "1c.5"
+  port = "6"
+  chassis = "6"
+
+[device "pci.7"]
+  driver = "pcie-root-port"
+  bus = "pcie.0"
+  addr = "1c.6"
+  port = "7"
+  chassis = "7"
+
+[device "pci.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.
+
+[device "scsi"]
+  driver = "virtio-scsi-pci"
+  bus = "pci.1"
+  addr = "00.0"
+
+[device "scsi-disk"]
+  driver = "scsi-hd"
+  bus = "scsi.0"
+  drive = "disk"
+
+[drive "disk"]
+  file = "guest.qcow2"                          # CHANGE ME
+  format = "qcow2"
+  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 = "pci.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 = "pci.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 trying
+# to display a GTK+ window on the host and enable remote
+# access instead.
+
+[device "video"]
+  driver = "virtio-gpu"
+  bus = "pcie.0"
+  addr = "01.0"
docs/mach-virt-serial.cfg new file +224 -0

224 lines not on this page · raw message

Signature · 1 line
2.7.4
Reviewed-by on v6 2/2
#3 lore raw

Re: [Qemu-devel] [PATCH v6 2/2] mach-virt: Provide sample configuration files

Quoted 13 lines · Andrea Bolognani

These are very much like the sample configuration files for q35, and can be used both as documentation and as a starting point for creating your own guest.

Two sample configuration files are provided:

* mach-virt-graphical.cfg can be used to start a fully-featured (USB, graphical console, etc.) guest that uses VirtIO devices;

* mach-virt-serial.cfg is similar but has a minimal set of devices and uses the serial console.

Quoted 8 lines

All configuration files are fully commented and neatly organized.

---
 docs/mach-virt-graphical.cfg | 262 +++++++++++++++++++++++++++++++++++++++++++
 docs/mach-virt-serial.cfg    | 224 ++++++++++++++++++++++++++++++++++++
 2 files changed, 486 insertions(+)
 create mode 100644 docs/mach-virt-graphical.cfg
 create mode 100644 docs/mach-virt-serial.cfg

This looks awesome. I have some easy comments. (I likely could have made them earlier, but didn't have time/energy to read the patch in full. Sorry!)

Quoted 7 lines
docs/mach-virt-graphical.cfg new file +0 -0
new file mode 100644
index 0000000..2dab3af

docs/mach-virt-graphical.cfg line 9

Quoted 9 lines
docs/mach-virt-graphical.cfg new file +9 -0
@@ -0,0 +1,262 @@
+# mach-virt - VirtIO guest (graphical console)
+# =========================================================
+#
+# Usage:
+#
+#   $ qemu-system-aarch64 \
+#     -nodefaults \
+#     -readconfig mach-virt-graphical.cfg \
+#     -cpu host

Clearly, for reviewing both files, I applied your patches, and then diffed the two files created by this patch. :)

So, what speaks against adding "-serial mon:stdio" here too? Even with a graphical guest, the monitor is useful. And, if you care about firmware logs (who doesn't? ;)), seeing serial output is good. (Same applies to the guest kernel -- sooner or later everyone enables serial output for grub2 and kernel, for reporting bugs.)

Just my two cents, you're welcome to disagree.

docs/mach-virt-graphical.cfg line 16

Quoted 7 lines
docs/mach-virt-graphical.cfg new file +7 -0
+#
+# 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.

("will 'mainly' be accessed through a graphical console", if you agree with the above)

Quoted 95 lines
docs/mach-virt-graphical.cfg new file +95 -0
+#
+# ---------------------------------------------------------
+#
+# 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"
+

docs/mach-virt-graphical.cfg line 121

Quoted 10 lines
docs/mach-virt-graphical.cfg new file +10 -0
+
+# 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 "pci.1"]

I suggest to call these devices "pcie.x" (and update the references).

Quoted 69 lines
docs/mach-virt-graphical.cfg new file +69 -0
+  driver = "pcie-root-port"
+  bus = "pcie.0"
+  addr = "1c.0"
+  port = "1"
+  chassis = "1"
+  multifunction = "on"
+
+[device "pci.2"]
+  driver = "pcie-root-port"
+  bus = "pcie.0"
+  addr = "1c.1"
+  port = "2"
+  chassis = "2"
+
+[device "pci.3"]
+  driver = "pcie-root-port"
+  bus = "pcie.0"
+  addr = "1c.2"
+  port = "3"
+  chassis = "3"
+
+[device "pci.4"]
+  driver = "pcie-root-port"
+  bus = "pcie.0"
+  addr = "1c.3"
+  port = "4"
+  chassis = "4"
+
+[device "pci.5"]
+  driver = "pcie-root-port"
+  bus = "pcie.0"
+  addr = "1c.4"
+  port = "5"
+  chassis = "5"
+
+[device "pci.6"]
+  driver = "pcie-root-port"
+  bus = "pcie.0"
+  addr = "1c.5"
+  port = "6"
+  chassis = "6"
+
+[device "pci.7"]
+  driver = "pcie-root-port"
+  bus = "pcie.0"
+  addr = "1c.6"
+  port = "7"
+  chassis = "7"
+
+[device "pci.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.
+
+[device "scsi"]
+  driver = "virtio-scsi-pci"
+  bus = "pci.1"
+  addr = "00.0"

docs/mach-virt-graphical.cfg line 200

Quoted 10 lines
docs/mach-virt-graphical.cfg new file +10 -0
+
+[device "scsi-disk"]
+  driver = "scsi-hd"
+  bus = "scsi.0"
+  drive = "disk"
+
+[drive "disk"]
+  file = "guest.qcow2"                          # CHANGE ME
+  format = "qcow2"
+  if = "none"

A number of suggestions. If you think they are beyond the scope of these examples, or plain disagree, that's fine. :)

* please add a CD-ROM too (scsi-cd), and point its drive to some installer ISO. (remember # CHANGE ME for the pathname)

* please spell out the "bootindex" property for both the disk and the CD-ROM device. If you set booindex=1 for the disk and bootindex=2 for the CD-ROM, then that configuration is permanently suitable for first installing the guest from the ISO, then booting it all subsequent times from the disk. ArmVirtQemu is king like that! ;)

* I'm a *huge* fan of saving disk space on the host. So, thin provisioning FTW! Virtio-scsi is definitely a step in the right direction, but for the disk drive, please add these wo properties:

discard = "unmap"
werror = "enospc"

The first property will release host filesystem blocks when the guest runs "fstrim". The second option lets you over-provision the host filesystem, and if a guest runs out of room mid-flight, it will be paused. You can free up more disk space and unpause the guest then.

(There's also "detect-zeroes", but I've never tried that. I very vaguely recall reading bad things about its CPU demand. I could be wrong, but I certainly don't feel comfortable enough to actively recommend it.)

Quoted 47 lines
docs/mach-virt-graphical.cfg new file +47 -0
+
+
+# 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 = "pci.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 = "pci.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.

docs/mach-virt-graphical.cfg line 257

Quoted 10 lines
docs/mach-virt-graphical.cfg new file +10 -0
+#
+# 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 trying
+# to display a GTK+ window on the host and enable remote
+# access instead.

Haha, someone prefers GTK+ to SDL? :) Last time I checked the GTK+ window, it was painful. (It was a very long time ago.)

Maybe that's to blame on GTK+ *in RHEL-7* specifically, I'm uncertain. But, I digress; no need to do anything about this.

docs/mach-virt-serial.cfg

Quoted 10 lines
docs/mach-virt-graphical.cfg new file +5 -0
+
+[device "video"]
+  driver = "virtio-gpu"
+  bus = "pcie.0"
+  addr = "01.0"
docs/mach-virt-serial.cfg new file +0 -0
new file mode 100644
index 0000000..4a9126a

[snipping this, I diffed graphical & serial between each other]

Looks very nice.

Pick anything from the above that you like (or even pick nothing, that's fine too):

Thanks!
Laszlo

#4 lore raw

Re: [Qemu-devel] [PATCH v6 2/2] mach-virt: Provide sample configuration files

Quoted 7 lines · Laszlo Ersek

So, what speaks against adding "-serial mon:stdio" here too? Even with a graphical guest, the monitor is useful. And, if you care about firmware logs (who doesn't? ;)), seeing serial output is good. (Same applies to the guest kernel -- sooner or later everyone enables serial output for grub2 and kernel, for reporting bugs.)

Just my two cents, you're welcome to disagree.

The sample configurations are opinionated, that's why there are both a graphical and a serial variant and not a single configuration with everything but the kitchen sink. Users are of course more than welcome to mix and match :)

Quoted 8 lines

docs/mach-virt-graphical.cfg line 121

Quoted 6 lines
docs/mach-virt-graphical.cfg new file +6 -0
+# 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 "pci.1"]


I suggest to call these devices "pcie.x" (and update the references).

Makes sense. I followed libvirt's naming here, but there is no reason not to highlight the fact that these controllers are, indeed, PCI Express rather than legacy PCI.

[...]

Quoted 11 lines

A number of suggestions. If you think they are beyond the scope of these examples, or plain disagree, that's fine. :)

* please add a CD-ROM too (scsi-cd), and point its drive to some installer ISO. (remember # CHANGE ME for the pathname)

* please spell out the "bootindex" property for both the disk and the CD-ROM device. If you set booindex=1 for the disk and bootindex=2 for the CD-ROM, then that configuration is permanently suitable for first installing the guest from the ISO, then booting it all subsequent times from the disk. ArmVirtQemu is king like that! ;)

So it does! And the same trick works for SeaBIOS as well, I just tested with the q35 sample configurations :)

I'll include this.

Quoted 7 lines

* I'm a *huge* fan of saving disk space on the host. So, thin provisioning FTW! Virtio-scsi is definitely a step in the right direction, but for the disk drive, please add these wo properties:

   discard = "unmap"
   werror = "enospc"

Quoted 8 lines

The first property will release host filesystem blocks when the guest runs "fstrim". The second option lets you over-provision the host filesystem, and if a guest runs out of room mid-flight, it will be paused. You can free up more disk space and unpause the guest then.
(There's also "detect-zeroes", but I've never tried that. I very vaguely recall reading bad things about its CPU demand. I could be wrong, but I certainly don't feel comfortable enough to actively recommend it.)

I think such tweaks, while definitely useful, fall beyond the scope of these sample configuration files.

[...]

Quoted 7 lines
Quoted 7 lines
docs/mach-virt-graphical.cfg new file +7 -0
+# 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 trying
Quoted 8 lines

docs/mach-virt-graphical.cfg line 257

Quoted 2 lines
docs/mach-virt-graphical.cfg new file +2 -0
+# to display a GTK+ window on the host and enable remote
+# access instead.


Haha, someone prefers GTK+ to SDL? :) Last time I checked the GTK+ window, it was painful. (It was a very long time ago.)

Maybe that's to blame on GTK+ *in RHEL-7* specifically, I'm uncertain. But, I digress; no need to do anything about this.

GTK+ just seems to be the default display mode, so no preference of my own really - although I have no problem admitting that I'm a massive GNOME fan ;)

Calling out GTK+ explicitly here does not serve any purpose, though, so I'll change it to a more neutral wording.

--
Andrea Bolognani / Red Hat / Virtualization

#5 lore raw

Re: [Qemu-devel] [PATCH v6 2/2] mach-virt: Provide sample configuration files

In reply to Laszlo Ersek

Hi,

Quoted 8 lines

Clearly, for reviewing both files, I applied your patches, and then diffed the two files created by this patch. :)

So, what speaks against adding "-serial mon:stdio" here too? Even with a graphical guest, the monitor is useful. And, if you care about firmware logs (who doesn't? ;)), seeing serial output is good. (Same applies to the guest kernel -- sooner or later everyone enables serial output for grub2 and kernel, for reporting bugs.)

Depends on the target audience. I'd expect users don't care much, developers probably do.

Yes, most of my virtual machines have a serial console too, even if they boot into graphic mode. If I screwed up graphics with a bad virtio-gpu patch it is very useful to have serial console to figure what exactly broke ...

Quoted 6 lines

* I'm a *huge* fan of saving disk space on the host. So, thin provisioning FTW! Virtio-scsi is definitely a step in the right direction, but for the disk drive, please add these wo properties:

discard = "unmap"
werror = "enospc"

Good idea!

cheers,
Gerd