How is an image virtual_size calculated ?

Asked by Rajiv Mucheli on 2019-08-28

Hi,

I would like to know how an image virtual_size calculated ? I did refer the below links but had no luck to find the code :

https://github.com/openstack/glance/commit/e98576efaebf9ce4882de21f2a664b9f4bb09660
https://github.com/openstack/glance/blob/master/api-ref/source/v2/samples/schemas-image-show-response.json#L243-L248

the db value for all my images is [null]

Please share a link/info on how to calculate the virtual_size of an image.

Regards,
Rajiv

Question information

Language:
English Edit question
Status:
Answered
For:
Glance Edit question
Assignee:
No assignee Edit question
Last query:
2019-08-28
Last reply:
2019-08-28

Hello Rajiv,

The reason you couldn't find where the virtual_size is calculated in the Glance code is because Glance doesn't calculate it!

The Glance 'size' property tells you the number of bytes the image data consumes in storage and hence how many bytes will have to be transferred by services consuming the image. The 'virtual_size' was added back in Icehouse [0] to address a perceived need for knowing what size disk the image represents. (I say "perceived need" because code was never added to Glance to compute this, so I guess people didn't really need it.) So finding 'null' for this column in all rows of your database is the expected behavior.

The virtual_size can be populated by hand if you want to give it a value, though I'm not aware of any consuming OpenStack services that actually use it.

With the interoperable image import process introduced a few cycles ago, you have the opportunity to write a plugin that could introspect the image and determine its virtual size and populate the field if you have a use case that requires it.

[0] https://blueprints.launchpad.net/glance/+spec/split-image-size

Can you help with this problem?

Provide an answer of your own, or ask Rajiv Mucheli for more information if necessary.

To post a message you must log in.