fix(glance): image disk_format use String2ImageFormat (#23991)

This commit is contained in:
wanyaoqi
2025-12-29 11:01:22 +08:00
committed by GitHub
parent 532f4eb1db
commit 5eae491d47
2 changed files with 6 additions and 2 deletions
+2 -2
View File
@@ -546,7 +546,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
@@ -1458,7 +1458,7 @@ func (self *SImage) DoCheckStatus(ctx context.Context, userCred mcclient.TokenCr
}
img, err := qemuimg.NewQemuImage(self.GetLocalLocation())
if err == nil {
format := string(img.Format)
format := string(img.String2ImageFormat())
virtualSizeMB := int32(img.SizeBytes / 1024 / 1024)
if (len(format) > 0 && self.DiskFormat != format) || (virtualSizeMB > 0 && self.MinDiskMB != virtualSizeMB) {
db.Update(self, func() error {
+4
View File
@@ -910,6 +910,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