summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
Diffstat (limited to 'nova')
-rw-r--r--nova/tests/test_virt.py4
-rw-r--r--nova/virt/libvirt_conn.py11
2 files changed, 8 insertions, 7 deletions
diff --git a/nova/tests/test_virt.py b/nova/tests/test_virt.py
index ec7498d72..113632a0c 100644
--- a/nova/tests/test_virt.py
+++ b/nova/tests/test_virt.py
@@ -57,7 +57,7 @@ class CacheConcurrencyTestCase(test.TestCase):
def test_same_fname_concurrency(self):
"""Ensures that the same fname cache runs at a sequentially"""
- conn = libvirt_conn.get_connection(False)
+ conn = libvirt_conn.LibvirtConnection
wait1 = eventlet.event.Event()
done1 = eventlet.event.Event()
eventlet.spawn(conn._cache_image, _concurrency,
@@ -78,7 +78,7 @@ class CacheConcurrencyTestCase(test.TestCase):
def test_different_fname_concurrency(self):
"""Ensures that two different fname caches are concurrent"""
- conn = libvirt_conn.get_connection(False)
+ conn = libvirt_conn.LibvirtConnection
wait1 = eventlet.event.Event()
done1 = eventlet.event.Event()
eventlet.spawn(conn._cache_image, _concurrency,
diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py
index 1a1f146d4..ecef7950a 100644
--- a/nova/virt/libvirt_conn.py
+++ b/nova/virt/libvirt_conn.py
@@ -511,9 +511,10 @@ class LibvirtConnection(object):
subprocess.Popen(cmd, shell=True)
return {'token': token, 'host': host, 'port': port}
- _image_semaphores = {}
+ _image_sems = {}
- def _cache_image(self, fn, target, fname, cow=False, *args, **kwargs):
+ @staticmethod
+ def _cache_image(fn, target, fname, cow=False, *args, **kwargs):
"""Wrapper for a method that creates an image that caches the image.
This wrapper will save the image into a common store and create a
@@ -533,9 +534,9 @@ class LibvirtConnection(object):
os.mkdir(base_dir)
base = os.path.join(base_dir, fname)
- if fname not in self._image_semaphores:
- self._image_semaphores[fname] = semaphore.Semaphore()
- with self._image_semaphores[fname]:
+ if fname not in LibvirtConnection._image_sems:
+ LibvirtConnection._image_sems[fname] = semaphore.Semaphore()
+ with LibvirtConnection._image_sems[fname]:
if not os.path.exists(base):
fn(target=base, *args, **kwargs)