[Kimchi-devel] [PATCH V2] Fix disk format lock during VM creation

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Thu Apr 16 14:42:36 UTC 2015


Users are able to pass the disk format (qcow, raw, etc) in disk Template
information. However, Kimchi is ignoring this information and always
creating QCOW2 disk images (if the storagepool is not 'LOGICAL') when it
creates a VM based on a given Template.
This patch fixes this problem.

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
---
 src/kimchi/vmtemplate.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/kimchi/vmtemplate.py b/src/kimchi/vmtemplate.py
index ec477dd..62772e5 100644
--- a/src/kimchi/vmtemplate.py
+++ b/src/kimchi/vmtemplate.py
@@ -193,7 +193,6 @@ 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)
@@ -201,11 +200,16 @@ class VMTemplate(object):
 
             info = {'name': volume,
                     'capacity': d['size'],
-                    'format': fmt,
+                    'format': d.get('format', 'qcow2'),
                     'path': '%s/%s' % (storage_path, volume)}
 
+            # Validate disk format
+            if self._get_storage_type() in ['logical'] and \
+               info['format'] != 'raw':
+                info['format'] = 'raw'
+
             if 'logical' == self._get_storage_type() or \
-               fmt not in ['qcow2', 'raw']:
+               info['format'] not in ['qcow2', 'raw']:
                 info['allocation'] = info['capacity']
             else:
                 info['allocation'] = 0
-- 
2.1.0




More information about the Kimchi-devel mailing list