Skip to content

Commit

Permalink
fix(host): nbd worker count add options (#21096)
Browse files Browse the repository at this point in the history
  • Loading branch information
wanyaoqi authored Aug 26, 2024
1 parent 4b34838 commit 5421f37
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions pkg/cloudcommon/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 7 additions & 4 deletions pkg/hostman/guestman/guestman.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/hostman/host_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 0 additions & 1 deletion pkg/hostman/hostdeployer/deployserver/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5421f37

Please sign in to comment.