From 1beca4d230112047b368135aa9365bfd2275926d Mon Sep 17 00:00:00 2001 From: shubham Date: Thu, 1 Jul 2021 15:12:26 +0530 Subject: [PATCH] add flag to gotgt command Signed-off-by: shubham --- cmd/daemon.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/daemon.go b/cmd/daemon.go index e9d0e9c..ca87535 100644 --- a/cmd/daemon.go +++ b/cmd/daemon.go @@ -37,22 +37,24 @@ func newDaemonCommand(cli *client.Client) *cobra.Command { var host string var driver string var logLevel string + var blockMultipleHosts bool var cmd = &cobra.Command{ Use: "daemon", Short: "Setup a daemon", Long: `Setup the Gotgt's daemon`, RunE: func(cmd *cobra.Command, args []string) error { - return createDaemon(host, driver, logLevel) + return createDaemon(host, driver, logLevel, blockMultipleHosts) }, } flags := cmd.Flags() flags.StringVar(&logLevel, "log", "info", "Log level of SCSI target daemon") flags.StringVar(&host, "host", "tcp://127.0.0.1:23457", "Host for SCSI target daemon") flags.StringVar(&driver, "driver", "iscsi", "SCSI low level driver") + flags.BoolVar(&blockMultipleHosts, "block-multiple-hosts", false, "Disable login from multiple hosts") return cmd } -func createDaemon(host, driver, level string) error { +func createDaemon(host, driver, level string, blockMultipleHosts bool) error { switch level { case "info": log.SetLevel(log.InfoLevel) @@ -88,6 +90,10 @@ func createDaemon(host, driver, level string) error { targetDriver.NewTarget(tgtname, config) } + if blockMultipleHosts { + targetDriver.EnableBlockMultipleHostLogin() + } + // comment this to avoid concurrent issue // runtime.GOMAXPROCS(runtime.NumCPU()) // run a service