File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -487,7 +487,16 @@ main() {
487487 local -r blob_name=" ${image_name} .vhd"
488488 # convert input image to fixed VHD blob with size rounded to 1 MB
489489 local -r blob_size=" $( get_rounded_size " ${INPUT_IMAGE} " ) "
490- execute qemu-img resize -q -f raw " ${INPUT_IMAGE} " " ${blob_size} "
490+ # Get actual image size in bytes
491+ local -r actual_size=" $( qemu-img info -f raw --output json " ${INPUT_IMAGE} " | jq ' .["virtual-size"]' ) "
492+
493+ # Only resize if needed
494+ if [ " $actual_size " -ne " $blob_size " ]; then
495+ execute qemu-img resize -q -f raw " ${INPUT_IMAGE} " " ${blob_size} "
496+ else
497+ echo " Image already aligned to $blob_size , skipping resize."
498+ fi
499+
491500 execute qemu-img convert -f raw -o subformat=fixed,force_size -O vpc \
492501 " ${INPUT_IMAGE} " " ${blob_name} "
493502 local -r blob_md5=" $( get_blob_md5 " ${blob_name} " ) "
You can’t perform that action at this time.
0 commit comments