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

Aline Manera alinefm at linux.vnet.ibm.com
Fri Apr 17 17:13:58 UTC 2015



On 16/04/2015 11:42, Rodrigo Trujillo wrote:
> 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'

I suggest to raise an error with the pool is logical and the format is 
anything else different from 'raw'

Otherwise, the user pass 'qcow2' for a logical volume and we 
automatically change it to 'raw' without informing him/her.


> +
>               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




More information about the Kimchi-devel mailing list