From 5421f370313964675c554e56bf4a012ce28da49a Mon Sep 17 00:00:00 2001 From: wanyaoqi <18528551+wanyaoqi@users.noreply.github.com> Date: Mon, 26 Aug 2024 17:29:08 +0800 Subject: [PATCH] fix(host): nbd worker count add options (#21096) --- pkg/cloudcommon/options/options.go | 1 + pkg/hostman/guestman/guestman.go | 11 +++++++---- pkg/hostman/host_services.go | 2 +- pkg/hostman/hostdeployer/deployserver/options.go | 1 - 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pkg/cloudcommon/options/options.go b/pkg/cloudcommon/options/options.go index 49ae129158c..cd3c1fed871 100644 --- a/pkg/cloudcommon/options/options.go +++ b/pkg/cloudcommon/options/options.go @@ -157,6 +157,7 @@ type HostCommonOptions struct { EnableIsolatedDeviceWhitelist bool `help:"enable isolated device white list" default:"false"` ExecutorConnectTimeoutSeconds int `help:"executor client connection timeout in seconds, default is 30" default:"30"` 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 f4c38d327a2..018c79ddd4e 100644 --- a/pkg/hostman/guestman/guestman.go +++ b/pkg/hostman/guestman/guestman.go @@ -68,7 +68,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 ( @@ -113,7 +113,10 @@ type SGuestManager struct { enableDirtyRecoveryFeature bool } -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 @@ -1751,9 +1754,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 52a9bd236fb..0ff1e71fb6c 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 d46e5f27acf..ac55019df19 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