fix(host,glance): only target qcow2 set cluster size on image convert (#22981)

This commit is contained in:
wanyaoqi
2025-07-30 00:43:43 +08:00
committed by GitHub
parent 21867bde96
commit d559f2119e
+8 -6
View File
@@ -397,14 +397,16 @@ func convertOther(srcInfo, destInfo SImageInfo, compact bool, workerOpions []str
if destInfo.Format.String() == "vmdk" { // for esxi vmdk
options = append(options, vmdkOptions(compact)...)
}
if destInfo.ClusterSize > 0 {
options = append(options, fmt.Sprintf("cluster_size=%d", destInfo.ClusterSize))
} else if srcInfo.ClusterSize > 0 {
options = append(options, fmt.Sprintf("cluster_size=%d", srcInfo.ClusterSize))
if destInfo.Format == qemuimgfmt.QCOW2 {
if destInfo.ClusterSize > 0 {
options = append(options, fmt.Sprintf("cluster_size=%d", destInfo.ClusterSize))
} else if srcInfo.ClusterSize > 0 {
options = append(options, fmt.Sprintf("cluster_size=%d", srcInfo.ClusterSize))
}
}
if len(options) > 0 {
cmdline = append(cmdline, "-o")
cmdline = append(cmdline, options...)
cmdline = append(cmdline, "-o", strings.Join(options, ","))
}
cmdline = append(cmdline, srcInfo.Path, destInfo.Path)
log.Infof("XXXX qemu-img command: %s", cmdline)