Correct disk's over committed size computing error

There's a error in the disk's over committed size computing for the
instance which using RAW type disk. This issue caused
disk_available_least resource counting increasing.

Fixes bug: 1167695

Change-Id: I4e6cf22a9cf66a757e3641e2a0be0b7699cae69d
Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
This commit is contained in:
Zhi Yan Liu
2013-04-12 12:00:47 +08:00
parent 1368105528
commit 5220590bf9

View File

@@ -2488,7 +2488,7 @@ class LibvirtConnTestCase(test.TestCase):
self.mox.StubOutWithMock(os.path, "getsize")
os.path.getsize('/test/disk').AndReturn((10737418240))
os.path.getsize('/test/disk.local').AndReturn((21474836480))
os.path.getsize('/test/disk.local').AndReturn((3328599655))
ret = ("image: /test/disk\n"
"file format: raw\n"
@@ -2512,10 +2512,12 @@ class LibvirtConnTestCase(test.TestCase):
self.assertEquals(info[0]['path'], '/test/disk')
self.assertEquals(info[0]['disk_size'], 10737418240)
self.assertEquals(info[0]['backing_file'], "")
self.assertEquals(info[0]['over_committed_disk_size'], 0)
self.assertEquals(info[1]['type'], 'qcow2')
self.assertEquals(info[1]['path'], '/test/disk.local')
self.assertEquals(info[1]['virt_disk_size'], 21474836480)
self.assertEquals(info[1]['backing_file'], "file")
self.assertEquals(info[1]['over_committed_disk_size'], 18146236825)
db.instance_destroy(self.context, instance_ref['uuid'])
@@ -3119,11 +3121,13 @@ class LibvirtConnTestCase(test.TestCase):
fake_disks = {'fake1': [{'type': 'qcow2', 'path': '/somepath/disk1',
'virt_disk_size': '10737418240',
'backing_file': '/somepath/disk1',
'disk_size':'83886080'}],
'disk_size':'83886080',
'over_committed_disk_size':'10653532160'}],
'fake2': [{'type': 'raw', 'path': '/somepath/disk2',
'virt_disk_size': '10737418240',
'virt_disk_size': '0',
'backing_file': '/somepath/disk2',
'disk_size':'10737418240'}]}
'disk_size':'10737418240',
'over_committed_disk_size':'0'}]}
def get_info(instance_name):
return jsonutils.dumps(fake_disks.get(instance_name))