forked from openstack/nova
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit f1426d1
libvirt: harden Host.get_domain_capabilities()
Previously get_domain_capabilities() in nova.virt.libvirt.host.Host
assumed that 'q35' would be an acceptable fallback default for any
architecture if no default machine type was hardcoded in nova for that
architecture. This was incorrect on two levels:
1. q35 is specific to x86 architectures.
2. Even on x86 architectures, nova's current default is 'pc'.
(There is an initiative to update it to q35, but that has
not landed yet.)
Furthermore, we need to be able to cope with situations where nova
has no default machine type hardcoded, by relying on the default
returned from calling libvirt's getDomainCapabilities() API with
no machine type specified.[0]
So this commit makes the following changes:
- Convert nova.virt.libvirt.host.Host._get_domain_capabilities() to
take all arguments as optional kwargs which match the signature of
libvirt's getDomainCapabilities() function, allowing it to be called
with unspecified machine type.
- Refactor libvirt_utils.get_default_machine_type() to use a dictionary
of default arch to machine_type mappings, and default i686 and
x86_64 to 'pc'.
- Extend get_domain_capabilities() to register domcaps by both the
versioned name returned by libvirt (e.g. 'pc-i440fx-2.11') and the
alias that was requested (e.g. 'pc').
- Extend the LibvirtConfigDomainCaps class with machine_type and
machine_type_alias properties.
- Factor out the domain cap test data into a separate
fake_libvirt_data module, and add valid examples for several
architectures such as armv7, i686 and sparc. These will all be
included in the return value from Host.get_domain_capabilities()
since the list of architectures for which to call the API come from
fakelibvirt's getCapabilities() which already returns multiple guest
architectures.
- Add more test cases to validate the changes above.
[0] To work around a bug in older versions of the libvirt-python API,
it is necessary to explicitly pass None as the machine type
parameter:
https://www.mail-archive.com/[email protected]/msg182746.html
libvirt/libvirt-python@5004b4a
Co-Authored-By: Adam Spiers <[email protected]>
Related-Blueprint: blueprint image-metadata-prefiltering
Related-Blueprint: blueprint amd-sev-libvirt-support
Change-Id: Id86c6b23a32a66564c2e7c794104e3a553df947d1 parent 1599e3c commit f1426d1Copy full SHA for f1426d1
File tree
Expand file treeCollapse file tree
6 files changed
+966
-155
lines changedFilter options
- nova
- tests/unit/virt/libvirt
- virt/libvirt
Expand file treeCollapse file tree
6 files changed
+966
-155
lines changed
0 commit comments