diff --git a/pkg/cloudcommon/options/options.go b/pkg/cloudcommon/options/options.go index 9cddd5f601..c349b97983 100644 --- a/pkg/cloudcommon/options/options.go +++ b/pkg/cloudcommon/options/options.go @@ -155,6 +155,7 @@ type HostCommonOptions struct { ExecutorConnectTimeoutSeconds int `help:"executor client connection timeout in seconds, default is 30" default:"30"` EnableIsolatedDeviceWhitelist bool `help:"enable isolated device white list" default:"false"` ImageDeployDriver string `help:"Image deploy driver" default:"qemu-kvm" choices:"qemu-kvm|nbd|libguestfs"` + DeployConcurrent int `help:"qemu-kvm deploy driver concurrent" default:"5"` } type DBOptions struct { diff --git a/pkg/hostman/guestman/guestman.go b/pkg/hostman/guestman/guestman.go index 8001f9e882..a04bb97d20 100644 --- a/pkg/hostman/guestman/guestman.go +++ b/pkg/hostman/guestman/guestman.go @@ -67,7 +67,7 @@ var ( LAST_USED_PORT = 0 LAST_USED_NBD_SERVER_PORT = 0 LAST_USED_MIGRATE_PORT = 0 - NbdWorker = appsrv.NewWorkerManager("nbd_worker", 1, appsrv.DEFAULT_BACKLOG, false) + NbdWorker *appsrv.SWorkerManager ) const ( @@ -108,7 +108,10 @@ type SGuestManager struct { pythonPath string } -func NewGuestManager(host hostutils.IHost, serversPath string) (*SGuestManager, error) { +func NewGuestManager(host hostutils.IHost, serversPath string, workerCnt int) (*SGuestManager, error) { + // init nbd worker + NbdWorker = appsrv.NewWorkerManager("nbd_worker", workerCnt, appsrv.DEFAULT_BACKLOG, false) + manager := &SGuestManager{} manager.host = host manager.ServersPath = serversPath @@ -1715,9 +1718,9 @@ func Stop() { guestManager.ExitGuestCleanup() } -func Init(host hostutils.IHost, serversPath string) error { +func Init(host hostutils.IHost, serversPath string, workerCnt int) error { if guestManager == nil { - manager, err := NewGuestManager(host, serversPath) + manager, err := NewGuestManager(host, serversPath, workerCnt) if err != nil { return err } diff --git a/pkg/hostman/host_services.go b/pkg/hostman/host_services.go index 2dca47b29d..32f6db280a 100644 --- a/pkg/hostman/host_services.go +++ b/pkg/hostman/host_services.go @@ -95,7 +95,7 @@ func (host *SHostService) RunService() { var guestChan chan struct{} - if err := guestman.Init(hostInstance, options.HostOptions.ServersPath); err != nil { + if err := guestman.Init(hostInstance, options.HostOptions.ServersPath, options.HostOptions.DeployConcurrent); err != nil { log.Fatalf("guest manager init error: %s", err) } guestman.GetGuestManager().InitQemuMaxCpus( diff --git a/pkg/hostman/hostdeployer/deployserver/options.go b/pkg/hostman/hostdeployer/deployserver/options.go index d46e5f27ac..ac55019df1 100644 --- a/pkg/hostman/hostdeployer/deployserver/options.go +++ b/pkg/hostman/hostdeployer/deployserver/options.go @@ -45,7 +45,6 @@ type SDeployOptions struct { DeployAction string `help:"local deploy action"` DeployParams string `help:"params for deploy action"` DeployParamsFile string `help:"file store params for deploy action"` - DeployConcurrent int `help:"qemu-kvm deploy driver concurrent" default:"5"` } var DeployOption SDeployOptions