Improve default machine type selection

Jim Fehlig jfehlig at suse.com
Wed Mar 15 14:22:51 UTC 2023


On 3/14/23 11:24, Andrea Bolognani wrote:
> On Mon, Mar 13, 2023 at 02:25:01PM -0600, Jim Fehlig wrote:
>> If an explicit machine type is not specified in the VM config, the qemu
>> driver will select the first machine type in the list of machine types for
>> the specified accelerator. See virQEMUCapsGetPreferredMachine
>>
>> https://gitlab.com/libvirt/libvirt/-/blob/master/src/qemu/qemu_capabilities.c#L6133
>>
>> On my test machines, this works reasonably well for x86_64 where the first
>> machine type is pc-i440fx-7.1. But for aarch64, the first machine is
>> integratorcp, which is not very useful with maxCpus=1 and other limitations.
> 
> What you're describing is the historical behavior, but these days
> it's a bit more complicated than that: we actually go out of our way
> to make sure that the default machine for an architecture is the one
> that QEMU *originally* listed first. See [1] for the implementation
> as well as the rationale.

Ah, thanks. Facepalm for missing that...

>> Would it be possible to select a "better" default machine type? E.g. 'pc'
>> for x86_64, 'virt' for aarch64, etc. I'm happy to work on this if folks deem
>> it's a reasonable improvement. It would benefit tools like the libvirt
>> terraform provider, which prefer to use something more generic like
>> <type>hvm</type>.
> 
> As much as I would *love* for virt to be the default aarch64 (and
> riscv64) machine type, unfortunately our strong backwards
> compatibility guarantees prevent us from changing this :(

Yep, understood.

> On the plus side, at least implementing more reasonable defaults at
> the application level should be quite straightforward. See [2] for
> virt-manager's take.

Nice! Thanks again for the details.

Regards,
Jim

> [1] https://gitlab.com/libvirt/libvirt/-/commit/26cfb1a3cd39d731099ee7d5d1c47b3730ebde16
> [2] https://github.com/virt-manager/virt-manager/blob/33ff193ee9fcfdb74f95d946a1b93239a1a12a61/virtinst/guest.py#L152-L180



More information about the libvir-list mailing list