fix daemon 's host flag
This commit is contained in:
@@ -23,13 +23,15 @@ import (
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/gostor/gotgt/pkg/apiserver"
|
||||
"github.com/gostor/gotgt/pkg/config"
|
||||
_ "github.com/gostor/gotgt/pkg/port/iscsit"
|
||||
"github.com/gostor/gotgt/pkg/scsi"
|
||||
_ "github.com/gostor/gotgt/pkg/scsi/backingstore"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func newDaemonCommand() *cobra.Command {
|
||||
@@ -41,7 +43,11 @@ func newDaemonCommand() *cobra.Command {
|
||||
Use: "daemon",
|
||||
Short: "Setup a daemon",
|
||||
Long: `Setup the Gotgt's daemon`,
|
||||
PreRun: func(cmd *cobra.Command, args []string) {
|
||||
viper.BindPFlags(cmd.Flags())
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
host = viper.GetString("host")
|
||||
return createDaemon(host, driver, logLevel, blockMultipleHosts)
|
||||
},
|
||||
}
|
||||
|
||||
@@ -339,7 +339,7 @@ func (s *ISCSITargetDriver) rxHandler(conn *iscsiConnection) {
|
||||
log.Debug("rx handler: IOSTATE_RX_BHS")
|
||||
length, err = conn.readData(buf)
|
||||
if err != nil {
|
||||
log.Error("read BHS failed:", err)
|
||||
log.Error("read BHS failed: ", err)
|
||||
conn.state = CONN_STATE_CLOSE
|
||||
return
|
||||
}
|
||||
|
||||
@@ -21,10 +21,11 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/gostor/gotgt/pkg/api"
|
||||
"github.com/gostor/gotgt/pkg/scsi"
|
||||
"github.com/gostor/gotgt/pkg/util"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -51,13 +52,10 @@ func new() (api.BackingStore, error) {
|
||||
}
|
||||
|
||||
func (bs *FileBackingStore) Open(dev *api.SCSILu, path string) error {
|
||||
var mode os.FileMode
|
||||
|
||||
var (
|
||||
mode os.FileMode
|
||||
finfo os.FileInfo
|
||||
)
|
||||
|
||||
if finfo, err := os.Stat(path); err != nil {
|
||||
finfo, err := os.Stat(path)
|
||||
if err != nil {
|
||||
return err
|
||||
} else {
|
||||
// determine file type
|
||||
@@ -75,6 +73,9 @@ func (bs *FileBackingStore) Open(dev *api.SCSILu, path string) error {
|
||||
}
|
||||
bs.DataSize = uint64(pos)
|
||||
} else {
|
||||
if finfo == nil {
|
||||
log.Infof("finfo is nil")
|
||||
}
|
||||
bs.DataSize = uint64(finfo.Size())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user