On 5/9/23 13:37, Alex Bennée wrote:
Then, an accurate description that uses "functional" in that sense
could be as follows:
The Kconfig system will include any devices and subsystems that are
mandatory for a given machine type, and will flag any configuration
conflicts. However, the person doing the configuration still needs to
know which devices are needed (on top of the mandatory ones) to obtain
a functional guest, and Kconfig will not provide any hints in this
respect.
So I thought that was the model I was following in adding devices but it
seems I don't understand the no-defaults behaviour. What is the
difference between a device that is added in the machine.c that makes it
required or expendable with -nodefaults?
First of all let's look at softmmu/vl.c, which is what creates the
backends of the default devices. These backends are basically automatic
command line options of the "old" kind that directs both the creation of
a backend and how it's associated to a device.
For example, if you have neither a -serial option nor a "-device
isa-serial" option, vl.c's qemu_create_default_devices() will create the
machine as if you specified one of "-serial mon:stdio", "-serial stdio"
or "-serial vc:80Cx24C"; if you have none of -netdev/nic/-net, it will
literally add two "-net" command line options corresponding to "-net nic
-net user"; and so on for many other devices unless the board opts out
(CD-ROM, floppy, SD card, parallel). There's also a default monitor
which is a bit out of topic here.
In any case, the effect of these "old" command line options is to
populate various arrays, for example serial_hds[] for serial ports and
nd_table[] for NIC backends.
There are then two ways that a board can process these arrays. It can
either _always_ create the device and possibly leave it not connected to
any backend, or it can create the device only if the backend exists.
Looking at qemu-system-aarch64's "-M virt", pl011 is always created with
create_uart(), i.e. even with "-nodefaults"; NICs instead are only
created if the backend exists (search for "nd_table" in hw/arm/virt.c).
In the former case, the device will have to be select-ed in Kconfig. In
the latter case, instead, the device will have an "imply" directive, and
will be left out by --without-default-devices.
Paolo