fix(host): losetup package initialization order (#22651)

This commit is contained in:
Zexi Li
2025-06-03 13:39:21 +08:00
committed by GitHub
parent 77daacdabc
commit 18805cfd37
2 changed files with 15 additions and 3 deletions
+2
View File
@@ -38,6 +38,7 @@ import (
"yunion.io/x/onecloud/pkg/hostman/storageman"
"yunion.io/x/onecloud/pkg/hostman/storageman/diskhandlers"
"yunion.io/x/onecloud/pkg/hostman/storageman/storagehandler"
losetupman "yunion.io/x/onecloud/pkg/util/losetup/manager"
"yunion.io/x/onecloud/pkg/util/procutils"
"yunion.io/x/onecloud/pkg/util/sysutils"
)
@@ -67,6 +68,7 @@ func (host *SHostService) InitService() {
execlient.SetTimeoutSeconds(options.HostOptions.ExecutorConnectTimeoutSeconds)
procutils.SetRemoteExecutor()
}
losetupman.Init()
}
func (host *SHostService) OnExitService() {}
+13 -3
View File
@@ -15,6 +15,8 @@
package manager
import (
"sync"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
@@ -22,10 +24,18 @@ import (
"yunion.io/x/onecloud/pkg/util/losetup"
)
var managerObj iManager
var (
managerObj iManager
managerInitLock sync.Mutex
)
func init() {
managerObj = newManager()
func Init() {
managerInitLock.Lock()
defer managerInitLock.Unlock()
if managerObj == nil {
managerObj = newManager()
}
}
func ListDevices() (*losetup.Devices, error) {