How is an image virtual_size calculated ?

Asked by Rajiv Mucheli


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 :

the db value for all my images is [null]

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


Question information

English Edit question
Glance Edit question
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Brian Rosmaita (brian-rosmaita) said :

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.


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.