mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Automatic merge from release/2.6.0 -> release/2.7.0
* commit 'dbab0d9c7c3fd67762c49a958186a4de160d6fc9': fix: cherry-pick hotfix/qj-recover-image-properties-at-startup
This commit is contained in:
@@ -1028,6 +1028,24 @@ func (self *SImage) DoCheckStatus(ctx context.Context, userCred mcclient.TokenCr
|
||||
}
|
||||
}
|
||||
}
|
||||
img, err := qemuimg.NewQemuImage(self.getLocalLocation())
|
||||
if err == nil {
|
||||
format := string(img.Format)
|
||||
virtualSizeMB := int32(img.SizeBytes / 1024 / 1024)
|
||||
if (len(format) > 0 && self.DiskFormat != format) || (virtualSizeMB > 0 && self.MinDiskMB != virtualSizeMB) {
|
||||
self.GetModelManager().TableSpec().Update(self, func() error {
|
||||
if len(format) > 0 {
|
||||
self.DiskFormat = format
|
||||
}
|
||||
if virtualSizeMB > 0 {
|
||||
self.MinDiskMB = virtualSizeMB
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
} else {
|
||||
log.Warningf("fail to check image size of %s(%s)", self.Id, self.Name)
|
||||
}
|
||||
} else {
|
||||
if self.Status != IMAGE_STATUS_QUEUED {
|
||||
self.SetStatus(userCred, IMAGE_STATUS_QUEUED, "check inactive")
|
||||
|
||||
Reference in New Issue
Block a user