domcapabilities: fix detection if host-model is safe to use

According to libvirt documentation for host-model [1] it is safe to use
it only if 'fallback' attribute is set to 'forbid', this indicates that
the libvirt and QEMU are new enough and can safely filter list of cpu
features that will be guaranteed to be visible inside of the guest.

[1] <https://libvirt.org/formatdomain.html#elementsCPU>

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Pavel Hrdina 2019-03-13 14:18:14 +01:00
parent 74bbc3db15
commit 9fdbbca27f
1 changed files with 3 additions and 2 deletions

View File

@ -227,9 +227,10 @@ class DomainCapabilities(XMLBuilder):
"""
Return True if domcaps reports support for cpu mode=host-model.
host-model infact predates this support, however it wasn't
general purpose safe prior to domcaps advertisement
general purpose safe prior to domcaps advertisement.
"""
return [(m.name == "host-model" and m.supported)
return [(m.name == "host-model" and m.supported and
m.models[0].fallback == "forbid")
for m in self.cpu.modes]