One "smart way to implement default devices" could be an inclusion
mechanism where a machine can ask qemu to read other config files.
Then you'd have config files for the default serial/parallel/etc.
This could also be implemented on top of choices 2/3/4 though.
Defaults are tough because there are multiple ways to create devices
today. Here's something that could potentially address the problem.
I'll focus on -serial but it's equally applicable to the other default
devices.
We would introduce serial0, serial1, serial2, serial3 MachineCore
properties. These properties would be chardev names.
The pc machine types would do:
QOPT_VALUE("serial0", "__default_serial0");
In vl.c, we would always create a __default_serial0 chardev of 'vc'.
The -serial option would keep a counter and:
-serial mon:stdio -serial vc
Would be equivalent to:
-chardev mon:stdio,id=__serial0 -machine serial0=__serial0 \
-chardev vc,id=__serial1 -machine serial1=__serial1
-nodefaults simply suppresses the creation of the default serial devices.
It's the job of the MachineCore to try to find each of the serialN
properties and if the chardevs have been created, use qdev to create an
appropriate serial port device.
This would apply equally well to parallel and virtcon.
Networking is a bit of a nightmare as many boards simply ignore the
networking options. Floppy and cdrom can work in this way too.
Regards,
Anthony Liguori
Paolo