[Kimchi-devel] [PATCHv1 1/2] Fix storage volume format on logical pool for vm
lvroyce at linux.vnet.ibm.com
lvroyce at linux.vnet.ibm.com
Fri Mar 7 13:56:57 UTC 2014
From: Royce Lv <lvroyce at linux.vnet.ibm.com>
VM with LV as its disk will fail to start.
Root cause is volume format is set to be qcow2,
space of which is not allocated at creation time, just with metadata.
Data of files can be allocated through writes.
But LV cannot extend accordingly as file unless manually call 'lvextend'.
So create logical volume formated as 'raw' to allocate enough space,
This will prevent vm write access exceeds range.
Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
---
src/kimchi/vmtemplate.py | 8 +++++---
tests/test_storagepool.py | 2 +-
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/kimchi/vmtemplate.py b/src/kimchi/vmtemplate.py
index f380170..d3bd52e 100644
--- a/src/kimchi/vmtemplate.py
+++ b/src/kimchi/vmtemplate.py
@@ -149,10 +149,11 @@ class VMTemplate(object):
src = os.path.join(storage_path, volume)
dev = "%s%s" % (self._bus_to_dev[self.info['disk_bus']],
string.lowercase[index])
- params = {'src': src, 'dev': dev, 'bus': self.info['disk_bus']}
+ fmt = 'raw' if self._get_storage_type() in ['logical'] else 'qcow2'
+ params = {'src': src, 'dev': dev, 'bus': self.info['disk_bus'], 'type': fmt}
ret += """
<disk type='file' device='disk'>
- <driver name='qemu' type='qcow2' cache='none'/>
+ <driver name='qemu' type='%(type)s' cache='none'/>
<source file='%(src)s' />
<target dev='%(dev)s' bus='%(bus)s' />
</disk>
@@ -198,6 +199,7 @@ class VMTemplate(object):
def to_volume_list(self, vm_uuid):
storage_path = self._get_storage_path()
+ fmt = 'raw' if self._get_storage_type() in ['logical'] else 'qcow2'
ret = []
for i, d in enumerate(self.info['disks']):
index = d.get('index', i)
@@ -206,7 +208,7 @@ class VMTemplate(object):
info = {'name': volume,
'capacity': d['size'],
'type': 'disk',
- 'format': 'qcow2',
+ 'format': fmt,
'path': '%s/%s' % (storage_path, volume)}
info['xml'] = """
diff --git a/tests/test_storagepool.py b/tests/test_storagepool.py
index fcf24f8..22b4943 100644
--- a/tests/test_storagepool.py
+++ b/tests/test_storagepool.py
@@ -72,7 +72,7 @@ class storagepoolTests(unittest.TestCase):
<device path="/dev/hdb" />
</source>
<target>
- <path>/var/lib/kimchi/logical_mount/unitTestLogicalPool</path>
+ <path>/dev/unitTestLogicalPool</path>
</target>
</pool>
"""},
--
1.8.1.2
More information about the Kimchi-devel
mailing list