From b961368422d8ab828e230845bb5d0d2c5facf61c Mon Sep 17 00:00:00 2001 From: Michael Still Date: Thu, 16 Feb 2012 08:00:09 +1100 Subject: [PATCH] Rework base file checksums. The libvirt image cache manager wants to verify that the images it is managing have not become corrupt. We therefore write checksums for these images to disk and verify them as part of the cache management periodic task. This checksumming was originally done as part of the setup for a new virtual machine. This has been refactored so that generating a checksum on a large file will not delay the startup of a VM. Note that these checksums are intended for detecting corruption, not malicious system admins. Change-Id: I781877b342207cb2cf03eb48bd89456846cbf487 --- nova/tests/test_imagecache.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nova/tests/test_imagecache.py b/nova/tests/test_imagecache.py index 1df745cd..224d7c2a 100644 --- a/nova/tests/test_imagecache.py +++ b/nova/tests/test_imagecache.py @@ -284,6 +284,8 @@ class ImageCacheManagerTestCase(test.TestCase): 'operating system.') img = {'container_format': 'ami', 'id': '42'} + self.flags(checksum_base_images=True) + try: dirname = tempfile.mkdtemp() fname = os.path.join(dirname, 'aaa') @@ -318,6 +320,10 @@ class ImageCacheManagerTestCase(test.TestCase): res = image_cache_manager._verify_checksum(img, fname) self.assertEquals(res, None) + # Checksum requests for a file with no checksum now have the + # side effect of creating the checksum + self.assertTrue(os.path.exists('%s.sha1' % fname)) + finally: shutil.rmtree(dirname)