mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Use json format when calling qemu-img
Switch from using the default human readable format to request the json format from qemu-img as this will provide disk sizes in bytes. This avoids assuming that the returned size is in GigaBytes. Fixes #743
This commit is contained in:
@@ -88,7 +88,7 @@ cd "$TMP_DIR"
|
||||
#Using the awk int function here to truncate the virtual image size to an
|
||||
#integer since the fog-libvirt library does not seem to properly handle
|
||||
#floating point.
|
||||
IMG_SIZE=$(qemu-img info "$TMP_IMG" | awk '/virtual size/{print int($3)+1;}' | tr -d 'G')
|
||||
IMG_SIZE=$(qemu-img info --output=json "$TMP_IMG" | awk '/virtual-size/{s=int($2)/(1024^3); print (s == int(s)) ? s : int(s)+1 }')
|
||||
|
||||
echo "{$IMG_SIZE}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user