mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #1227 in YUNIONIO/onecloud from ~QIUJIAN/onecloud:hotfix/qj-recover-image-properties-at-startup-2.6.0 to release/2.6.0
* commit '7e606b64d3ac957aee4edcb8cd138854476da708': 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