
These changes implements the backend support for setting the disk image format in an existing VM template, by using a new parameter called "format" in the 'disk' object of the template_update schema. Supported formats: 'bochs', 'cloop', 'cow', 'dmg', 'qcow', 'qcow2', 'qed', 'raw', 'vmdk', 'vpc'. Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com> --- docs/API.md | 6 ++++-- src/kimchi/API.json | 8 +++++++- src/kimchi/i18n.py | 3 ++- src/kimchi/vmtemplate.py | 5 ++++- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/docs/API.md b/docs/API.md index 1338e26..9c06f85 100644 --- a/docs/API.md +++ b/docs/API.md @@ -304,7 +304,8 @@ A interface represents available network interface on VM. * index: The device index * size: The device size in GB * volume: A volume name that contains the initial disk contents - * graphcis: A dict of graphics paramenters of this template + * format: Format of the image. Valid formats: bochs, cloop, cow, dmg, qcow, qcow2, qed, raw, vmdk, vpc. + * graphics: A dict of graphics paramenters of this template * type: The type of graphics. It can be VNC or spice or None. * vnc: Graphical display using the Virtual Network Computing protocol @@ -337,7 +338,8 @@ A interface represents available network interface on VM. * index: The device index * size: The device size in GB * volume: A volume name that contains the initial disk contents - * graphcis *(optional)*: A dict of graphics paramenters of this template + * format: Format of the image. Valid formats: bochs, cloop, cow, dmg, qcow, qcow2, qed, raw, vmdk, vpc. + * graphics *(optional)*: A dict of graphics paramenters of this template * type: The type of graphics. It can be VNC or spice or None. * vnc: Graphical display using the Virtual Network Computing protocol diff --git a/src/kimchi/API.json b/src/kimchi/API.json index a1156d5..0ad36ab 100644 --- a/src/kimchi/API.json +++ b/src/kimchi/API.json @@ -208,7 +208,7 @@ "format": { "description": "The format of the volume", "type": "string", - "pattern": "^qcow2|raw$", + "pattern": "^(bochs|cloop|cow|dmg|qcow|qcow2|qed|raw|vmdk|vpc)$", "error": "KCHVOL0015E" }, "url": { @@ -619,6 +619,12 @@ "type": "integer", "minimum": 1, "error": "KCHTMPL0022E" + }, + "format": { + "description": "Type of the image of the disk", + "type": "string", + "pattern": "^(bochs|cloop|cow|dmg|qcow|qcow2|qed|raw|vmdk|vpc)$", + "error": "KCHTMPL0027E" } } }, diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py index 74ea98e..f789259 100644 --- a/src/kimchi/i18n.py +++ b/src/kimchi/i18n.py @@ -145,6 +145,7 @@ messages = { "KCHTMPL0024E": _("Cannot identify base image %(path)s format"), "KCHTMPL0025E": _("When specifying CPU topology, VCPUs must be a product of sockets, cores, and threads."), "KCHTMPL0026E": _("When specifying CPU topology, each element must be an integer greater than zero."), + "KCHTMPL0027E": _("Invalid disk image format. Valid formats: bochs, cloop, cow, dmg, qcow, qcow2, qed, raw, vmdk, vpc."), "KCHPOOL0001E": _("Storage pool %(name)s already exists"), "KCHPOOL0002E": _("Storage pool %(name)s does not exist"), @@ -197,7 +198,7 @@ messages = { "KCHVOL0012E": _("Storage type %(type)s does not support volume create and delete"), "KCHVOL0013E": _("Storage volume name must be a string"), "KCHVOL0014E": _("Storage volume allocation must be an integer number"), - "KCHVOL0015E": _("Storage volume format not supported"), + "KCHVOL0015E": _("Storage volume format not supported. Valid formats: bochs, cloop, cow, dmg, qcow, qcow2, qed, raw, vmdk, vpc."), "KCHVOL0016E": _("Storage volume requires a volume name"), "KCHVOL0017E": _("Unable to update database with storage volume information due error: %(err)s"), "KCHVOL0018E": _("Only one of parameter %(param)s can be specified"), diff --git a/src/kimchi/vmtemplate.py b/src/kimchi/vmtemplate.py index 0541106..ff7ddb4 100644 --- a/src/kimchi/vmtemplate.py +++ b/src/kimchi/vmtemplate.py @@ -162,7 +162,10 @@ class VMTemplate(object): 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('format', 'qcow2') params = {'src': src, 'dev': dev, 'bus': self.info['disk_bus'], 'type': fmt} ret += """ -- 1.8.3.1