[glance] Question about container_format and disk_format

Brian Rosmaita rosmaita.fossdev at gmail.com
Thu Jan 3 13:46:29 UTC 2019


On 1/3/19 3:07 AM, Andre Florath wrote:
> Hello!
> 
> After digging through the source code, I'd answer my own question:

Sorry you had to answer your own question, but glad you were willing to
dig into the source code!

> image disk_format and container_format are
> 
> (A) the formats of the image file that is passed in.

This is "sort of" correct.  In general, Glance does not verify either
the disk_format or container_format of the image data, so these values
are whatever the image owner has specified.  Glance doesn't verify these
because disk/container formats are developed independently of OpenStack,
and in the heady days of 2010, it seemed like a good idea that new
disk/container formats be usable without having to wait for a new Glance
release.  (There isn't much incentive for an image owner to lie about
the disk/container format, because specifying the wrong one could make
the image unusable by any consuming service that relies on these image
properties.)

> 
> Reasoning:
> 
> Glance's so called flows use those parameters as input
> like ovf_process.py [1]:
> 
>         if image.container_format == 'ova':
> 
> When there is a conversion done in the flow, the target
> format is the one from the configuration (like [2]):
> 
>         target_format = CONF.image_conversion.output_format
> 
> After a possible conversion, the new disk and container formats are
> set (e.g. [3]):
> 
>         image.disk_format = target_format
>         image.container_format = 'bare'
> 
> (At some points instead of using the disk and container format
> parameters, a call to 'qemu-img info' is done to extract those
> information from the image - like in [4]:
> 
> 
>         stdout, stderr = putils.trycmd("qemu-img", "info",
>                                        "--output=json", ...

Note to fans of CVE 2015-5162: the above call to qemu-img is time
restricted.

>         ...
>         metadata = json.loads(stdout)
>         source_format = metadata.get('format')
> )

Remember that the "flows" are optional, so in general you cannot rely
upon Glance setting these values correctly for you.

> 
> So it looks that the idea is, that the disk_format and
> container_format should always reflect the current format of the
> image.
> 
> Can anybody please confirm / comment?

Yes, the image properties associated with an image are meant to describe
the image data associated with that image record.

> Kind regards
> 
> Andre

Happy new year!
brian

> 
> 
> [1] https://git.openstack.org/cgit/openstack/glance/tree/glance/async_/flows/ovf_process.py#n87
> [2] https://git.openstack.org/cgit/openstack/glance/tree/glance/async_/flows/plugins/image_conversion.py#n78
> [3] https://git.openstack.org/cgit/openstack/glance/tree/glance/async_/flows/plugins/image_conversion.py#n129
> [4] https://git.openstack.org/cgit/openstack/glance/tree/glance/async_/flows/plugins/image_conversion.py#n87
> 
> 
> 
> On 12/18/18 11:07 AM, Andre Florath wrote:
>> Hello!
>>
>> I do not completely understand the parameters 'container_format'
>> and 'disk_format' as described in [1]. The documentation always
>> uses 'the format' but IMHO there might be two formats involved.
>>
>> Are those formats either
>>
>> (A) the formats of the image file that is passed in.
>>
>>     Like (from the official documentation [2])
>>
>>     $ openstack image create --disk-format qcow2 --container-format bare \
>>          --public --file ./centos63.qcow2 centos63-image
>>
>>     qcow2 / bare are the formats of the passed in image.
>>
>> or
>>
>> (B) the formats that are used internally to store the image
>>
>>     Like
>>
>>     $ openstack image create --disk-format vmdk --container-format ova \
>>          --public --file ./centos63.qcow2 centos63-image
>>
>>     vmdk / ova are formats that are used internally in OpenStack glance
>>     to store the image.
>>     In this case there must be an auto-detection of the image file format
>>     that is passed in and an automatic conversion into the new format.
>>
>> Kind regards
>>
>> Andre
>>
>>
>> [1] https://developer.openstack.org/api-ref/image/v2/index.html?expanded=create-image-detail#create-image
>> [2] https://docs.openstack.org/glance/pike/admin/manage-images.html
>>
> 
> 




More information about the openstack-discuss mailing list