[Kimchi-devel] [PATCH] Choose disk image type in vm template - backend

Daniel H Barboza danielhb at linux.vnet.ibm.com
Wed Sep 17 01:54:05 UTC 2014


On 09/16/2014 08:58 PM, Aline Manera wrote:
>
> On 09/04/2014 05:50 PM, Daniel Henrique Barboza wrote:
>> These changes implements the backend support for setting the disk
>> image type in the VM template, by using a new parameter called
>> "type" in the 'disk' object of the template_create schema.
>>
>> If the parameter is not used, the template will use the default
>> disk type (qcow2).
>>
>> Signed-off-by: Daniel Henrique Barboza <danielhb at linux.vnet.ibm.com>
>> ---
>>   docs/API.md              |  1 +
>>   src/kimchi/API.json      | 12 ++++++++++++
>>   src/kimchi/i18n.py       |  1 +
>>   src/kimchi/vmtemplate.py |  5 ++++-
>>   4 files changed, 18 insertions(+), 1 deletion(-)
>>
>> diff --git a/docs/API.md b/docs/API.md
>> index 298441f..11dba67 100644
>> --- a/docs/API.md
>> +++ b/docs/API.md
>> @@ -195,6 +195,7 @@ Represents a snapshot of the Virtual Machine's 
>> primary monitor.
>>           * index: The device index
>>           * size: The device size in GB
>>           * base: Base image of this disk
>> +        * type: Type of the image (qcow2 or raw)
>
> From libvirt the supported formats are: "raw", "bochs", "qcow", 
> "qcow2", "qed", "vmdk"
> Shouldn't we support all those too?
 From libvirt doc:

http://libvirt.org/storage.html

When listing existing volumes all these formats are supported natively. 
When creating new volumes, only a subset may be available. The|raw|type 
is guaranteed always available. The|qcow2|type can be created if 
either|qemu-img|or|qcow-create|tools are present. The others are 
dependent on support of the|qemu-img|tool.

This is why I considered only raw and qcow2. The other types are 
dependent on qemu-img tool, which
can support different types according to distro and arch.
>
>>
>>       * graphics *(optional)*: The graphics paramenters of this template
>>           * type: The type of graphics. It can be VNC or spice or None.
>> diff --git a/src/kimchi/API.json b/src/kimchi/API.json
>> index 2e2f9b0..67ffaf7 100644
>> --- a/src/kimchi/API.json
>> +++ b/src/kimchi/API.json
>> @@ -419,6 +419,12 @@
>>                                   "type": "string",
>>                                   "pattern": "^/.+$",
>>                                   "error": "KCHTMPL0023E"
>> +                            },
>> +                            "type": {
>> +                                "description": "Type of the image of 
>> the disk",
>> +                                "type": "string",
>> +                                "pattern": "^qcow2|raw$",
>> +                                "error": "KCHTMPL0025E"
>>                               }
>>
>>                           }
>> @@ -590,6 +596,12 @@
>>                                   "type": "number",
>>                                   "minimum": 1,
>>                                   "error": "KCHTMPL0022E"
>> +                            },
>> +                            "type": {
>> +                                "description": "Type of the image of 
>> the disk",
>> +                                "type": "string",
>> +                                "pattern": "^qcow2|raw$",
>> +                                "error": "KCHTMPL0025E"
>>                               }
>>                           }
>>                       },
>> diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
>> index 1e8b47a..9c81ea0 100644
>> --- a/src/kimchi/i18n.py
>> +++ b/src/kimchi/i18n.py
>> @@ -130,6 +130,7 @@ messages = {
>>       "KCHTMPL0022E": _("Disk size must be greater than 1GB."),
>>       "KCHTMPL0023E": _("Template base image must be a valid local 
>> image file"),
>>       "KCHTMPL0024E": _("Cannot identify base image %(path)s format"),
>> +    "KCHTMPL0025E": _("Invalid disk image type. Types supported: 
>> 'qcow2', 'raw'"),
>>
>>       "KCHPOOL0001E": _("Storage pool %(name)s already exists"),
>>       "KCHPOOL0002E": _("Storage pool %(name)s does not exist"),
>> diff --git a/src/kimchi/vmtemplate.py b/src/kimchi/vmtemplate.py
>> index c5bb7b3..9b8349d 100644
>> --- a/src/kimchi/vmtemplate.py
>> +++ b/src/kimchi/vmtemplate.py
>> @@ -195,7 +195,10 @@ drive=drive-%(bus)s0-1-0,id=%(bus)s0-1-0'/>
>>               src = os.path.join(storage_path, volume)
>>               dev = "%s%s" % (self._bus_to_dev[self.info['disk_bus']],
>>                               string.lowercase[index])
>
>> -            fmt = 'raw' if self._get_storage_type() in ['logical'] 
>> else 'qcow2'
>> +            if self._get_storage_type() in ['logical']:
>> +                fmt = 'raw'
>> +            else:
>> +                fmt = disk.get('type', 'qcow2')
>
> If user passes a different type of 'raw' to a logical volume we should 
> raise an error.
>
>>               params = {'src': src, 'dev': dev, 'bus': 
>> self.info['disk_bus'],
>>                         'type': fmt}
>>               ret += """
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/kimchi-devel/attachments/20140916/e0db9e01/attachment.html>


More information about the Kimchi-devel mailing list