Skip to content

Commit 059c980

Browse files
authored
fix(glance): image disk_format use String2ImageFormat (#23989)
1 parent b0985f1 commit 059c980

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

pkg/image/models/images.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ func (self *SImage) SaveImageFromStream(reader io.Reader, totalSize int64, calCh
561561
if err != nil {
562562
return errors.Wrapf(err, "NewQemuImage %s", localPath)
563563
}
564-
format = string(img.Format)
564+
format = string(img.String2ImageFormat())
565565
virtualSizeBytes = img.SizeBytes
566566

567567
var fastChksum string
@@ -1475,7 +1475,7 @@ func (image *SImage) DoCheckStatus(ctx context.Context, userCred mcclient.TokenC
14751475
}
14761476
img, err := qemuimg.NewQemuImage(image.GetLocalLocation())
14771477
if err == nil {
1478-
format := string(img.Format)
1478+
format := string(img.String2ImageFormat())
14791479
virtualSizeMB := int32(img.SizeBytes / 1024 / 1024)
14801480
if (len(format) > 0 && image.DiskFormat != format) || (virtualSizeMB > 0 && image.MinDiskMB != virtualSizeMB) {
14811481
db.Update(image, func() error {

pkg/util/qemuimg/qemuimg.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,10 @@ func (img *SQemuImage) String() string {
914914
return fmt.Sprintf("Qemu %s %d(%d) %s", img.Format, img.GetSizeMB(), img.GetActualSizeMB(), img.Path)
915915
}
916916

917+
func (img *SQemuImage) String2ImageFormat() qemuimgfmt.TImageFormat {
918+
return qemuimgfmt.String2ImageFormat(string(img.Format))
919+
}
920+
917921
func (img *SQemuImage) WholeChainFormatIs(format string) (bool, error) {
918922
if img.Format.String() != format {
919923
return false, nil

0 commit comments

Comments
 (0)