Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mmguero committed Jan 3, 2024
2 parents 83fc8f0 + a94ce0d commit 69bf0fc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tools/create_box.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ 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 --output=json "$TMP_IMG" | awk '/virtual-size/{s=int($2)/(1024^3); print (s == int(s)) ? s : int(s)+1 }')
#floating point. Regex in awk function takes in account only "virtual-size"
#value on the first level of JSON (since QEMU v8 there are multiple
#"virtual-size"s in disk info).
IMG_SIZE=$(qemu-img info --output=json "$TMP_IMG" | awk '/^\s{0,4}"virtual-size/{s=int($2)/(1024^3); print (s == int(s)) ? s : int(s)+1 }')

echo "{$IMG_SIZE}"

Expand Down

0 comments on commit 69bf0fc

Please sign in to comment.