[pve-devel] [PATCH storage] fix #3894: file 'size' and 'used' are not integers

Mira Limbeck m.limbeck at proxmox.com
Thu Feb 17 14:33:39 CET 2022


On 2/17/22 14:24, Fabian Ebner wrote:
> Am 17.02.22 um 13:55 schrieb Mira Limbeck:
>> 'qemu-img info' with output format 'json' returns the size and used values as
>> integers, but the regex match converts them to strings.
>> As we know they only contain digits, we can simply cast them back to integers
>> after the regex.
>>
>> The API requires them to be integers.
>>
> Any reason for not doing it in the API call itself? That would cover all
> plugins and future changes.

The main reason is that we call volume_size_info (which forwards to 
file_size_info in most cases) and file_size_info in other parts of our 
code as well. Wouldn't it be more consistent for `size` and `used` to be 
integers in every context, rather than just in that specific API call?

We could add an additional cast in the API call as well to make sure 
other and future plugins don't run into the same issues.






More information about the pve-devel mailing list