From 07ea05365d6ff7243c2bd79b9b2affb947cf0be3 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Sun, 29 Sep 2013 09:26:03 -0400 Subject: [PATCH] connection: Cache _all_ support checks This could cause issues if something like a domain support check returns NOSUPPORT for one domain on a connection but not for another domain, but honestly I'd call that a libvirt bug since NOSUPPORT should be usable like we want it. --- virtinst/connection.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/virtinst/connection.py b/virtinst/connection.py index 0b17f5e1f..82c81ccd9 100644 --- a/virtinst/connection.py +++ b/virtinst/connection.py @@ -341,28 +341,30 @@ class VirtualConnection(object): _supportname.startswith("SUPPORT_")]: locals()[_supportname] = getattr(support, _supportname) - def check_conn_support(self, feature): + def _check_support(self, feature, data): key = feature + if type(data) is str: + key = (feature, data) if key not in self._support_cache: - self._support_cache[key] = support.check_support(self, - feature, self) + self._support_cache[key] = support.check_support( + self, feature, data) return self._support_cache[key] + + def check_conn_support(self, feature): + return self._check_support(feature, self) def check_conn_hv_support(self, feature, hv): - key = (feature, hv) - if key not in self._support_cache: - self._support_cache[key] = support.check_support(self, feature, hv) - return self._support_cache[key] + return self._check_support(feature, hv) def check_domain_support(self, dom, feature): - return support.check_support(self, feature, dom) + return self._check_support(feature, dom) def check_pool_support(self, pool, feature): - return support.check_support(self, feature, pool) + return self._check_support(feature, pool) def check_interface_support(self, iface, feature): - return support.check_support(self, feature, iface) + return self._check_support(feature, iface) def check_stream_support(self, feature): return (self.check_conn_support(self.SUPPORT_CONN_STREAM) and - support.check_support(self, feature, self)) + self._check_support(feature, self)) def check_net_support(self, net, feature): - return support.check_support(self, feature, net) + return self._check_support(feature, net) ###################