summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2017-07-19 14:56:10 -0400
committerCole Robinson <crobinso@redhat.com>2017-07-20 17:28:38 -0400
commit55aa23b4000072e22e13e6e13ff4031cb75111af (patch)
tree836026b2371657081f664355c5eb74d19316aa23
parent4e4a6c817fc3f6945c5b5a20c822f04f0a326149 (diff)
downloadvirt-manager-55aa23b4000072e22e13e6e13ff4031cb75111af.tar.gz
connection: Return copys of cached object lists
Incase any users manipulate the lists, we don't want that to affect our caching. Could prevent future mistakes
-rw-r--r--tests/utils.py8
-rw-r--r--virtinst/connection.py8
2 files changed, 8 insertions, 8 deletions
diff --git a/tests/utils.py b/tests/utils.py
index cebe24d2..7d2774fb 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -93,20 +93,20 @@ def openconn(uri):
cache = _conn_cache[uri].copy()
def cb_fetch_all_guests():
- return cache["vms"]
+ return cache["vms"][:]
def cb_fetch_all_nodedevs():
- return cache["nodedevs"]
+ return cache["nodedevs"][:]
def cb_fetch_all_pools():
if "pools" not in cache:
cache["pools"] = conn._fetch_all_pools_raw()
- return cache["pools"]
+ return cache["pools"][:]
def cb_fetch_all_vols():
if "vols" not in cache:
cache["vols"] = conn._fetch_all_vols_raw()
- return cache["vols"]
+ return cache["vols"][:]
def cb_clear_cache(pools=False):
if pools:
diff --git a/virtinst/connection.py b/virtinst/connection.py
index ab37f569..b491054a 100644
--- a/virtinst/connection.py
+++ b/virtinst/connection.py
@@ -190,7 +190,7 @@ class VirtualConnection(object):
key = self._FETCH_KEY_GUESTS
if key not in self._fetch_cache:
self._fetch_cache[key] = self._fetch_all_guests_raw()
- return self._fetch_cache[key]
+ return self._fetch_cache[key][:]
def _fetch_all_pools_raw(self):
ignore, ignore, ret = pollhelpers.fetch_pools(
@@ -208,7 +208,7 @@ class VirtualConnection(object):
key = self._FETCH_KEY_POOLS
if key not in self._fetch_cache:
self._fetch_cache[key] = self._fetch_all_pools_raw()
- return self._fetch_cache[key]
+ return self._fetch_cache[key][:]
def _fetch_all_vols_raw(self):
ret = []
@@ -239,7 +239,7 @@ class VirtualConnection(object):
key = self._FETCH_KEY_VOLS
if key not in self._fetch_cache:
self._fetch_cache[key] = self._fetch_all_vols_raw()
- return self._fetch_cache[key]
+ return self._fetch_cache[key][:]
def _fetch_all_nodedevs_raw(self):
ignore, ignore, ret = pollhelpers.fetch_nodedevs(
@@ -257,7 +257,7 @@ class VirtualConnection(object):
key = self._FETCH_KEY_NODEDEVS
if key not in self._fetch_cache:
self._fetch_cache[key] = self._fetch_all_nodedevs_raw()
- return self._fetch_cache[key]
+ return self._fetch_cache[key][:]
#########################