mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
fix(glance): image disk_format use String2ImageFormat (#23991)
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user