mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 02:37:24 +08:00
Merge pull request #450 from swordqiu/hotfix/qj-fix-kvm-force-use-qcow2-image
fix: 1. force use qcow2 format when creating kvm VM 2. add template lock
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
@@ -36,6 +37,7 @@ import (
|
||||
|
||||
var (
|
||||
templatesTable map[string]*template.Template
|
||||
templatesTableLock *sync.Mutex
|
||||
notifyClientWorkerMan *appsrv.SWorkerManager
|
||||
|
||||
notifyAdminUsers []string
|
||||
@@ -44,6 +46,7 @@ var (
|
||||
|
||||
func init() {
|
||||
notifyClientWorkerMan = appsrv.NewWorkerManager("NotifyClientWorkerManager", 1, 50, false)
|
||||
templatesTableLock = &sync.Mutex{}
|
||||
templatesTable = make(map[string]*template.Template)
|
||||
}
|
||||
|
||||
@@ -61,6 +64,9 @@ func getTemplateString(topic string, contType string, channel notify.TNotifyChan
|
||||
|
||||
func getTemplate(topic string, contType string, channel notify.TNotifyChannel) (*template.Template, error) {
|
||||
key := fmt.Sprintf("%s.%s.%s", topic, contType, channel)
|
||||
templatesTableLock.Lock()
|
||||
defer templatesTableLock.Unlock()
|
||||
|
||||
if _, ok := templatesTable[key]; !ok {
|
||||
cont, err := getTemplateString(topic, contType, channel)
|
||||
if err != nil {
|
||||
|
||||
@@ -120,7 +120,7 @@ func (self *SKVMHostDriver) CheckAndSetCacheImage(ctx context.Context, host *mod
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
format, _ := params.GetString("format")
|
||||
// format, _ := params.GetString("format")
|
||||
isForce := jsonutils.QueryBoolean(params, "is_force", false)
|
||||
obj, err := models.CachedimageManager.FetchById(imageId)
|
||||
if err != nil {
|
||||
@@ -142,7 +142,8 @@ func (self *SKVMHostDriver) CheckAndSetCacheImage(ctx context.Context, host *mod
|
||||
|
||||
content := contentStruct{}
|
||||
content.ImageId = imageId
|
||||
content.Format = format
|
||||
// content.Format = format
|
||||
content.Format = "qcow2"
|
||||
|
||||
if srcHostCacheImage != nil {
|
||||
err = srcHostCacheImage.AddDownloadRefcount()
|
||||
|
||||
@@ -127,9 +127,7 @@ func (c *SLocalImageCacheManager) PrefetchImageCache(ctx context.Context, data i
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// format, _ := body.GetString("format")
|
||||
// force qcow2 for KVM
|
||||
format := "qcow2"
|
||||
format, _ := body.GetString("format")
|
||||
srcUrl, _ := body.GetString("src_url")
|
||||
|
||||
if imgCache := c.AcquireImage(ctx, imageId, storageManager.GetZone(),
|
||||
|
||||
Reference in New Issue
Block a user