mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-10-30 18:23:35 +08:00
磁盘大小向上取整 (#385)
This commit is contained in:
@@ -17,6 +17,7 @@ package guestdrivers
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -68,7 +69,7 @@ func (self *SManagedVirtualizedGuestDriver) GetJsonDescAtHost(ctx context.Contex
|
||||
if i == 0 {
|
||||
config.SysDisk.Name = disk.Name
|
||||
config.SysDisk.StorageType = storage.StorageType
|
||||
config.SysDisk.SizeGB = disk.DiskSize / 1024
|
||||
config.SysDisk.SizeGB = int(math.Ceil(float64(disk.DiskSize) / 1024))
|
||||
cache := storage.GetStoragecache()
|
||||
imageId := disk.GetTemplateId()
|
||||
//避免因同步过来的instance没有对应的imagecache信息,重置密码时引发空指针访问
|
||||
|
||||
@@ -1250,7 +1250,7 @@ func fillDiskConfigByImage(ctx context.Context, userCred mcclient.TokenCredentia
|
||||
}
|
||||
// diskConfig.ImageDiskFormat = image.DiskFormat
|
||||
CachedimageManager.ImageAddRefCount(image.Id)
|
||||
if diskConfig.SizeMb == 0 {
|
||||
if diskConfig.SizeMb < image.MinDiskMB {
|
||||
diskConfig.SizeMb = image.MinDiskMB // MB
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -433,7 +434,7 @@ func (self *SImage) SaveImageFromStream(reader io.Reader) error {
|
||||
self.DiskFormat = format
|
||||
}
|
||||
if virtualSizeBytes > 0 {
|
||||
self.MinDiskMB = int32(virtualSizeBytes / 1024 / 1024)
|
||||
self.MinDiskMB = int32(math.Ceil(float64(virtualSizeBytes) / 1024 / 1024))
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user