
On Thu, Jan 25, 2024 at 03:58:29PM +0100, Peter Krempa wrote:
On Wed, Jan 24, 2024 at 20:37:49 +0100, Andrea Bolognani wrote:
Most of the functions responsible for choosing architecture and machine specific defaults are already close to one another, with just a couple of strays. Having everything in one place will hopefully make it harder to miss updating any of the functions when new architectures are being introduced.
Too bad that the code is using a eclectic selection of ARCH_IS_* macros together with checkers such as qemuDomainIsRISCVVirt etc, because it's hard to create a proper fix which would be a properly typed switch statement, where the compiler would enforce what you want to achieve here.
Unfortunately that's needed because some architectures have wildly different machine types. On Arm, for example, the virt machine type is lean, modern and geared towards PCI/virtio, but you also have machine types implementing very old embedded boards where all controllers are hard-coded. The solution would be to restrict support to the small subset of virt-friendly machine types, one or two per architecture, that we actually test in any capacity, but since things have been free-for-all until now there is the expectation that even machine types that libvirt knows nothing about will keep working the same as they ever have.
Also too bad that the list of arches is *massive* to have it everywhere, despite the fac that we effectively ignore a half of them.
Yeah, my first instinct was to add switch()es everywhere, but as soon as I started I realized that unfortunately it just made the code much, much worse :( -- Andrea Bolognani / Red Hat / Virtualization