[Kimchi-devel] [PATCHv3 6/8] Create volume based on backing store image

Aline Manera alinefm at linux.vnet.ibm.com
Mon Jul 21 18:16:06 UTC 2014


Reviewed-by: Aline Manera <alinefm at linux.vnet.ibm.com>

Question: Do you know what is needed to have it working for iscsi and 
scsi pools?

On 07/20/2014 12:08 PM, lvroyce0210 at gmail.com wrote:
> From: Royce Lv <lvroyce at linux.vnet.ibm.com>
>
> Creating volume base on backing store so that we can create
> vm from this cow volume. Also change volume xml generation method
> to lxml.
>
> Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
> ---
>   src/kimchi/i18n.py       |  1 +
>   src/kimchi/model/vms.py  |  1 +
>   src/kimchi/vmtemplate.py | 31 +++++++++++++++++++------------
>   3 files changed, 21 insertions(+), 12 deletions(-)
>
> diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
> index f872bee..1f70767 100644
> --- a/src/kimchi/i18n.py
> +++ b/src/kimchi/i18n.py
> @@ -126,6 +126,7 @@ messages = {
>       "KCHTMPL0021E": _("Unable to delete template due error: %(err)s"),
>       "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"),
>
>       "KCHPOOL0001E": _("Storage pool %(name)s already exists"),
>       "KCHPOOL0002E": _("Storage pool %(name)s does not exist"),
> diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
> index 8c0dcb1..7d975b2 100644
> --- a/src/kimchi/model/vms.py
> +++ b/src/kimchi/model/vms.py
> @@ -201,6 +201,7 @@ class VMsModel(object):
>           # the user from UI or manually.
>           vol_list = []
>           if t._get_storage_type() in ["iscsi", "scsi"]:
> +        # FIXME: iscsi and scsi storage work with base image needs to be fixed.
>               vol_list = []
>           else:
>               vol_list = t.fork_vm_storage(vm_uuid)
> diff --git a/src/kimchi/vmtemplate.py b/src/kimchi/vmtemplate.py
> index 9e8ed3d..b17e3ff 100644
> --- a/src/kimchi/vmtemplate.py
> +++ b/src/kimchi/vmtemplate.py
> @@ -265,19 +265,26 @@ drive=drive-%(bus)s0-1-0,id=%(bus)s0-1-0'/>
>                       'type': 'disk',
>                       'format': fmt,
>                       'path': '%s/%s' % (storage_path, volume)}
> -
>               info['allocation'] = 0 if fmt == 'qcow2' else info['capacity']
> -            info['xml'] = """
> -            <volume>
> -              <name>%(name)s</name>
> -              <allocation unit="G">%(allocation)s</allocation>
> -              <capacity unit="G">%(capacity)s</capacity>
> -              <target>
> -                <format type='%(format)s'/>
> -                <path>%(path)s</path>
> -              </target>
> -            </volume>
> -            """ % info
> +
> +            if 'base' in d:
> +                info['base'] = dict()
> +                base_fmt = probe_img_info(d['base'])['format']
> +                if base_fmt is None:
> +                    raise InvalidParameter("KCHTMPL0024E", {'path': d['base']})
> +                info['base']['path'] = d['base']
> +                info['base']['format'] = base_fmt
> +
> +            v_tree = E.volume(E.name(info['name']))
> +            v_tree.append(E.allocation(str(info['allocation']), unit='G'))
> +            v_tree.append(E.capacity(str(info['capacity']), unit='G'))
> +            target = E.target(
> +                E.format(type=info['format']), E.path(info['path']))
> +            if 'base' in d:
> +                v_tree.append(E.backingStore(
> +                    E.path(info['base']['path']), E.format(type=info['base']['format'])))
> +            v_tree.append(target)
> +            info['xml'] = etree.tostring(v_tree)
>               ret.append(info)
>           return ret
>




More information about the Kimchi-devel mailing list