Skip to content

Commit dae6b1d

Browse files
committed
pkg/imgutil/nativeimgutil: Avoid resizing ASIF image
Signed-off-by: Norio Nomura <[email protected]>
1 parent 4a5c081 commit dae6b1d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pkg/imgutil/nativeimgutil/nativeimgutil.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,15 @@ func convertTo(destType image.Type, source, dest string, size *int64, allowSourc
104104
// destTmp != destTmpF.Name() because destTmpF is mounted ASIF device file.
105105
randomBase := fmt.Sprintf("%s.lima-%d.tmp.asif", filepath.Base(dest), rand.UintN(math.MaxUint))
106106
destTmp = filepath.Join(filepath.Dir(dest), randomBase)
107-
attachedDevice, destTmpF, err = asifutil.NewAttachedASIF(destTmp, srcImg.Size())
107+
// Since qcow2 image is smaller than expected size, we need to specify expected size to avoid resize later.
108+
// Resizing ASIF image is not supported by qemu-img which recognizes ASIF format as raw.
109+
var newSize int64
110+
if size != nil {
111+
newSize = *size
112+
} else {
113+
newSize = srcImg.Size()
114+
}
115+
attachedDevice, destTmpF, err = asifutil.NewAttachedASIF(destTmp, newSize)
108116
default:
109117
return fmt.Errorf("unsupported target image type: %q", destType)
110118
}

0 commit comments

Comments
 (0)