mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(glance): image disk_format use String2ImageFormat (#23989)
This commit is contained in:
@@ -561,7 +561,7 @@ func (self *SImage) SaveImageFromStream(reader io.Reader, totalSize int64, calCh
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "NewQemuImage %s", localPath)
|
||||
}
|
||||
format = string(img.Format)
|
||||
format = string(img.String2ImageFormat())
|
||||
virtualSizeBytes = img.SizeBytes
|
||||
|
||||
var fastChksum string
|
||||
@@ -1475,7 +1475,7 @@ func (image *SImage) DoCheckStatus(ctx context.Context, userCred mcclient.TokenC
|
||||
}
|
||||
img, err := qemuimg.NewQemuImage(image.GetLocalLocation())
|
||||
if err == nil {
|
||||
format := string(img.Format)
|
||||
format := string(img.String2ImageFormat())
|
||||
virtualSizeMB := int32(img.SizeBytes / 1024 / 1024)
|
||||
if (len(format) > 0 && image.DiskFormat != format) || (virtualSizeMB > 0 && image.MinDiskMB != virtualSizeMB) {
|
||||
db.Update(image, func() error {
|
||||
|
||||
@@ -914,6 +914,10 @@ func (img *SQemuImage) String() string {
|
||||
return fmt.Sprintf("Qemu %s %d(%d) %s", img.Format, img.GetSizeMB(), img.GetActualSizeMB(), img.Path)
|
||||
}
|
||||
|
||||
func (img *SQemuImage) String2ImageFormat() qemuimgfmt.TImageFormat {
|
||||
return qemuimgfmt.String2ImageFormat(string(img.Format))
|
||||
}
|
||||
|
||||
func (img *SQemuImage) WholeChainFormatIs(format string) (bool, error) {
|
||||
if img.Format.String() != format {
|
||||
return false, nil
|
||||
|
||||
Reference in New Issue
Block a user