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
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user