diff options
author | Cole Robinson <crobinso@redhat.com> | 2022-02-16 12:13:16 -0500 |
---|---|---|
committer | Cole Robinson <crobinso@redhat.com> | 2022-02-16 14:03:44 -0500 |
commit | 2c477f330244e04614e174f50fbf37260c535705 (patch) | |
tree | d0d8cc0f2c5ede3e598fc0a1b55fef3263111c20 /virtinst/domcapabilities.py | |
parent | fc9a22afe0df6a9803d2510ab92aaf8ee3caf012 (diff) | |
download | virt-manager-2c477f330244e04614e174f50fbf37260c535705.tar.gz |
domain: cpu: Use host-passthrough by default on x86
When libvirt and qemu are new enough, use host-passthrough for the
CPU default. Nowadays this is recommended over host-model for most
end user usage where migration isn't a critical feature.
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Diffstat (limited to 'virtinst/domcapabilities.py')
-rw-r--r-- | virtinst/domcapabilities.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/virtinst/domcapabilities.py b/virtinst/domcapabilities.py index 4a217556..99a9a518 100644 --- a/virtinst/domcapabilities.py +++ b/virtinst/domcapabilities.py @@ -129,10 +129,9 @@ class _CPUModel(XMLBuilder): fallback = XMLProperty("./@fallback") -class _CPUMode(XMLBuilder): +class _CPUMode(_CapsBlock): XML_NAME = "mode" name = XMLProperty("./@name") - supported = XMLProperty("./@supported", is_yesno=True) models = XMLChildProperty(_CPUModel) def get_model(self, name): @@ -265,11 +264,20 @@ class DomainCapabilities(XMLBuilder): host-model in fact predates this support, however it wasn't general purpose safe prior to domcaps advertisement. """ - for m in self.cpu.modes: - if (m.name == "host-model" and m.supported and - m.models[0].fallback == "forbid"): - return True - return False + m = self.cpu.get_mode("host-model") + return (m and m.supported and + m.models[0].fallback == "forbid") + + def supports_safe_host_passthrough(self): + """ + Return True if host-passthrough is safe enough to use by default. + We limit this to domcaps new enough to report whether host-passthrough + is migratable or not, which also means libvirt is about new enough + to not taint the VM for using host-passthrough + """ + m = self.cpu.get_mode("host-passthrough") + return (m and m.supported and + "on" in m.get_enum("hostPassthroughMigratable").get_values()) def get_cpu_models(self): models = [] |