Pick guest CPU architecture based on host arch.

Registered by Kashyap Chamarthy

Currently, in many places, Nova's libvirt driver makes decisions on how
to configure guest XML based on *host* CPU architecture
("caps.host.cpu.arch"). That is not optimal in all cases. So all of
the said code needs to be reworked to make those decisions based on
*guest* CPU architecture (i.e. "guest.arch", which should be set based
on the image metadata property, `hw_architecture`). A related piece of
work is to distinguish between hosts that can do AArch64 (or PPC64, etc)
via KVM (which is hardware-accelerated) vs. those that can only do it
via plain emulation ("TCG") — this is to ensure that guests are not
arbitrarily scheduled on hosts that are incapable of hardware
acceleration, thus losing out on performance-related benefits.

This rework will make sure that we will: pick the correct QEMU binary
for a guest with different CPU architecture than the host; choose the
correct QEMU machine type for an x86_64 guest running on an AArch64
host; and so forth.

Blueprint information

Status:
Complete
Approver:
Balazs Gibizer
Priority:
Undefined
Drafter:
Kashyap Chamarthy
Direction:
Approved
Assignee:
Jonathan Race
Definition:
Approved
Series goal:
Accepted for yoga
Implementation:
Implemented
Milestone target:
None
Started by
Jonathan Race
Completed by
Jonathan Race

Related branches

Sprints

Whiteboard

http://lists.openstack.org/pipermail/openstack-operators/2018-August/015617.html.

Note from nova-victoria-ptg:
https://etherpad.opendev.org/p/nova-victoria-ptg
If you set the virt_type to qemu then nova will report all the supported archs as compute capability

2021 Addition:
https://review.opendev.org/c/openstack/nova/+/822053
Additional work is being done and has added initial support for performing this function through adding an additional image metadata value, hw_emulation_architecture, allowing for a simple check to be performed. This will ensure that nova core code can function as normal, and if emulation is required then you can set the value and the proper check will be performed.

Items to consider are to ensure your nova nodes have all desired qemu binaries installed for the support you want, and that set the appropriate values in the image metadata.

hw_emulation_architecture
hw_machine_type
hw_firmware_type (specific to aarch)
hw_video_type (specific to s390x)

Valid supported architectures on x86:
AARCH64
PPC64

Proposed Architecture support:
MIPS (Working on libvirt bug fix)
s390x (Troubleshooting kernel crashafter build)

2022 Additions:
Spec:
https://review.opendev.org/c/openstack/nova-specs/+/824044

Nova:
https://review.opendev.org/c/openstack/nova/+/828369
https://review.opendev.org/c/openstack/nova/+/822053
https://review.opendev.org/c/openstack/nova/+/828372

os-traits:
https://review.opendev.org/c/openstack/os-traits/+/824050

[20220113 bauzas] Spec was approved https://review.opendev.org/c/openstack/nova-specs/+/824044
[20200125 chateaulav] os-trait patch approved https://review.opendev.org/c/openstack/os-traits/+/824050

(?)

Work Items

Work items:
Add new traits: DONE
Update prefilter: DONE
Modify libvirt virt driver to perform checks for emulation architecture: DONE
Add new property to image_meta objects: DONE
Modify libvirt virt config to pull OS arch into LibvirtConfigGuest: DONE
Final Testing: DONE
Merge: DONE

This blueprint contains Public information 
Everyone can see this information.