diff options
author | Pavel Hrdina <phrdina@redhat.com> | 2019-04-03 15:17:08 +0200 |
---|---|---|
committer | Pavel Hrdina <phrdina@redhat.com> | 2019-04-04 13:40:45 +0200 |
commit | 00f8dea370ae0874dc655d3718978a6a8e397a34 (patch) | |
tree | a33aa7e6e50633106d33f41e7091d959f1502a83 /virtinst/domcapabilities.py | |
parent | 22342ef7ee526f8a5b5a65266363c33c70c8be43 (diff) | |
download | virt-manager-00f8dea370ae0874dc655d3718978a6a8e397a34.tar.gz |
domcapabilities: add caching of CPU security features
We will call this function multiple times so it makes sense to cache the
result so we don't have to call libvirt APIs every time we will check
what security features are available on the host.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Diffstat (limited to 'virtinst/domcapabilities.py')
-rw-r--r-- | virtinst/domcapabilities.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/virtinst/domcapabilities.py b/virtinst/domcapabilities.py index 3e203c5a..922a4c21 100644 --- a/virtinst/domcapabilities.py +++ b/virtinst/domcapabilities.py @@ -272,6 +272,8 @@ class DomainCapabilities(XMLBuilder): return DomainCpu(self.conn, expandedXML) + _features = None + def get_cpu_security_features(self): sec_features = [ 'spec-ctrl', @@ -279,7 +281,10 @@ class DomainCapabilities(XMLBuilder): 'ibpb', 'virt-ssbd'] - features = [] + if self._features: + return self._features + + self._features = [] for m in self.cpu.modes: if m.name != "host-model" or not m.supported: @@ -293,9 +298,9 @@ class DomainCapabilities(XMLBuilder): for feature in cpu.features: if feature.name in sec_features: - features.append(feature.name) + self._features.append(feature.name) - return features + return self._features XML_NAME = "domainCapabilities" |