openmainframeproject / feilong

Feilong is a open source z/VM cloud connector project under the Open Mainframe Project umbrella that will accelerate the z/VM adoption, extending its ecosystem and its user experience. It provides a set of APIs to operate z/VM including guest, image, network, volume etc.
https://www.openmainframeproject.org/projects/feilong
Apache License 2.0
35 stars 70 forks source link

Fix memory resize failure due to not aligned to 256M #807

Closed zhshuj closed 5 months ago

zhshuj commented 5 months ago

Current code caculates an active VM's memory with the Total online memory value of lsmem command output when doing live resize.

This value is in Gigabytes, and is not precise to 2 digits, for example, lsmem should be reporting 2.75G, but instead it reports 2.8G; when target memory is 4G, then the to-be-increased memory is caculated to 1.2G, which is not aligned to 256M, then causes resize to fail.

To fix this problem, change to use the lsmem -b output, as it is in Bytes, so it is precise value, and always be aligned to 256M.

zhshuj commented 5 months ago

@jichenjc @bjhuangr @haoxy000 @SeanHQF can you help review?

jichenjc commented 5 months ago

/lgtm